Click here to Skip to main content
15,897,273 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ON_NOTIFY_REFLECT_EX called twice Pin
enhzflep28-Jun-11 5:04
enhzflep28-Jun-11 5:04 
GeneralRe: ON_NOTIFY_REFLECT_EX called twice Pin
_Flaviu28-Jun-11 8:06
_Flaviu28-Jun-11 8:06 
GeneralRe: ON_NOTIFY_REFLECT_EX called twice Pin
enhzflep28-Jun-11 9:12
enhzflep28-Jun-11 9:12 
GeneralRe: ON_NOTIFY_REFLECT_EX called twice Pin
David Crow28-Jun-11 16:57
David Crow28-Jun-11 16:57 
GeneralRe: ON_NOTIFY_REFLECT_EX called twice Pin
enhzflep28-Jun-11 21:19
enhzflep28-Jun-11 21:19 
QuestionHow to get clsid from GUID of a class Pin
gtag27-Jun-11 21:21
gtag27-Jun-11 21:21 
QuestionRe: How to get clsid from GUID of a class Pin
CPallini27-Jun-11 21:34
mveCPallini27-Jun-11 21:34 
QuestionDispatchID Failed... Pin
yaxiya27-Jun-11 16:25
yaxiya27-Jun-11 16:25 
 #include <windows.h>
 #include <stdio.h>
 
void PlayWithAccess(IUnknown *p);
void CallOpenDatabase(IDispatch *d);
int main(int argc, char* argv[])
{
 
   HRESULT hRet;
   CLSID clsid;
   IUnknown *p=NULL;
   hRet=CoInitialize(NULL);
	
   if(FAILED(hRet)) {
	   printf("It Failed...\n");  
       return 1;
   }
   hRet=CLSIDFromProgID(L"Access.Application",&clsid);
 
   if(FAILED(hRet)){
	   printf("CLSID Illegal...\n");  
	   CoUninitialize(); 
	   return 1; 
   }
 
  hRet=CoCreateInstance(&clsid, NULL, CLSCTX_ALL, &IID_IUnknown, (IUnknown **)&p);
  if(FAILED(hRet)) { 
	  printf("Create Failed...."); 
	  CoUninitialize();  
	  return 2;
  }
   PlayWithAccess(p);  //////// Play with Access Application Com Object
   p->lpVtbl->Release(p);
   CoUninitialize();
   return 0;
} 
 void PlayWithAccess(IUnknown *p)
	{
	char buf[100];  
	IDispatch *d=NULL; 
	HRESULT hret;
	hret=p->lpVtbl->QueryInterface(p,&IID_IDispatch,(void **)&d);
	if(FAILED(hret)){
		printf("DispatchID Failed...\n");  
	    sprintf(buf,"DispatchID failed w/err 0x%08lx", hret);
        MessageBox(NULL, buf, "DispatchID", 0x10010);
	 return; 
	}

	printf("Got the IDispatch Interface from Object...\n");
    CallOpenDatabase(d);  
	printf("Enter Return:"); 
	gets(buf);
    d->lpVtbl->Release(d);// Release Reference
 
	}

 void CallOpenDatabase(IDispatch *d)  // Call Open database through IDispatch Interface
	{	// Late IDispatch Binding....
	 VARIANTARG args[2];  
	 
	BSTR DBLocation=SysAllocString(L"D:/project/C/c_ado/connDB02/Example.mdb"); 
	OLECHAR *MethodName=L"OpenCurrentDatabase";   // Got The Method Name from Type Library
	DISPID dispid=0;   
	HRESULT hret;
    DISPPARAMS params; 
	DISPID ids[2]={1,0};
	hret=d->lpVtbl->GetIDsOfNames(d,&IID_NULL,&MethodName,1,LOCALE_USER_DEFAULT,&dispid);

	printf("Got a Dispatch Identifier....%x\n",dispid);
    memset(args,0,sizeof(args));   // Build Up arguments
	
	args[0].vt=VT_BOOL;   // Last Argument is Optional
	args[0].boolVal=FALSE;
	args[1].vt=VT_BSTR;		// First argument is DB Location
	args[1].bstrVal=DBLocation;
    memset(&params,0,sizeof(params));
  	params.cArgs=2;  
    params.rgvarg=args; 	

	hret=d->lpVtbl->Invoke(d,dispid,&IID_NULL,LOCALE_USER_DEFAULT,DISPATCH_METHOD,&params,NULL,NULL,NULL);
	if(FAILED(hret)) {
		printf("Invoke Failed....\n"); 
	}
	SysFreeString(DBLocation);
	}

How to do?thanks!
AnswerRe: DispatchID Failed... Pin
barneyman27-Jun-11 17:40
barneyman27-Jun-11 17:40 
GeneralRe: DispatchID Failed... Pin
yaxiya27-Jun-11 19:32
yaxiya27-Jun-11 19:32 
QuestionStopping Morse code - overriding pending event function - how to? Pin
Vaclav_27-Jun-11 14:28
Vaclav_27-Jun-11 14:28 
AnswerRe: Stopping Morse code - overriding pending event function - how to? Pin
Albert Holguin27-Jun-11 15:18
professionalAlbert Holguin27-Jun-11 15:18 
GeneralRe: Stopping Morse code - overriding pending event function - how to? Pin
Vaclav_27-Jun-11 17:01
Vaclav_27-Jun-11 17:01 
GeneralRe: Stopping Morse code - overriding pending event function - how to? Pin
Albert Holguin28-Jun-11 4:49
professionalAlbert Holguin28-Jun-11 4:49 
AnswerRe: Stopping Morse code - overriding pending event function - how to? Pin
Vaclav_28-Jun-11 3:43
Vaclav_28-Jun-11 3:43 
GeneralRe: Stopping Morse code - overriding pending event function - how to? Pin
Albert Holguin28-Jun-11 4:51
professionalAlbert Holguin28-Jun-11 4:51 
GeneralRe: Stopping Morse code - overriding pending event function - how to? Pin
Vaclav_28-Jun-11 6:08
Vaclav_28-Jun-11 6:08 
GeneralRe: Stopping Morse code - overriding pending event function - how to? Pin
Albert Holguin28-Jun-11 8:24
professionalAlbert Holguin28-Jun-11 8:24 
AnswerSome thread questions Pin
Vaclav_1-Jul-11 3:22
Vaclav_1-Jul-11 3:22 
QuestionProblems with MFC Ribbon edit with spin button Pin
Dansveen27-Jun-11 11:04
Dansveen27-Jun-11 11:04 
QuestionRe: Problems with MFC Ribbon edit with spin button Pin
Albert Holguin27-Jun-11 15:43
professionalAlbert Holguin27-Jun-11 15:43 
AnswerRe: Problems with MFC Ribbon edit with spin button Pin
Peter_in_278027-Jun-11 16:49
professionalPeter_in_278027-Jun-11 16:49 
GeneralRe: Problems with MFC Ribbon edit with spin button Pin
Dansveen28-Jun-11 3:28
Dansveen28-Jun-11 3:28 
GeneralRe: Problems with MFC Ribbon edit with spin button Pin
Albert Holguin28-Jun-11 3:44
professionalAlbert Holguin28-Jun-11 3:44 
GeneralRe: Problems with MFC Ribbon edit with spin button Pin
Dansveen28-Jun-11 4:03
Dansveen28-Jun-11 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.