Click here to Skip to main content
16,017,297 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerTry to post you question in the C++/CLI forum. Pin
CPallini22-May-07 4:44
mveCPallini22-May-07 4:44 
GeneralRe: Try to post you question in the C++/CLI forum. Pin
Hamid_RT22-May-07 7:52
Hamid_RT22-May-07 7:52 
GeneralRe: Try to post you question in the C++/CLI forum. Pin
CPallini22-May-07 7:56
mveCPallini22-May-07 7:56 
GeneralRe: Try to post you question in the C++/CLI forum. Pin
Hamid_RT22-May-07 8:20
Hamid_RT22-May-07 8:20 
GeneralRe: Try to post you question in the C++/CLI forum. Pin
CPallini22-May-07 9:32
mveCPallini22-May-07 9:32 
GeneralRe: Try to post you question in the C++/CLI forum. Pin
Hamid_RT22-May-07 9:58
Hamid_RT22-May-07 9:58 
QuestionTab order and active x control Pin
amyvt22-May-07 3:43
amyvt22-May-07 3:43 
QuestionIDispatch::Invoke() function Pin
Syamlal S Nair22-May-07 2:27
Syamlal S Nair22-May-07 2:27 
hi all,

I am not much familiar with COM and COM dlls, Neway i am trying to use a COM dll (that is written in Vb) in a VC++ win32 application. I used the functions CoInitialize(), CoCreateInstance() etc.

Now in order to invoke a member function of the class, what should i do? suppose the method has 2 params ,one a string value and the other an integer.

Sample code is here, pls suggest the corrections:

//*************start*************************
if(CoInitialize(NULL)==S_OK)
{

HRESULT hr;
IDispatch* pIUk;
CLSID clsid;


CLSIDFromProgID(L"MyDll.MyClass", &clsid);
hr=CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDispatch, (void**) &pIUk);
if(SUCCEEDED ( hr ))
{

DISPID dispid;
DISPPARAMS dispparameters;


//invoke method "MyMethod"

char filename[]="D:\\FrameWork.xls";
int count=1;
char FAR* szMember = "MyMethod";

hr = pIUk->GetIDsOfNames(IID_NULL,(unsigned short **)&szMember, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
pIUk->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dispparameters, NULL, NULL, NULL);

pIUk->Release();
}

CoUninitialize();

}
//*************end****************************


I am confused about filling the DISPPARAMS structure and lot more doubts ...

Thanks in advance

SYAMLAL

AnswerRe: IDispatch::Invoke() function Pin
Arman S.22-May-07 3:32
Arman S.22-May-07 3:32 
AnswerRe: IDispatch::Invoke() function Pin
CPallini22-May-07 4:13
mveCPallini22-May-07 4:13 
GeneralRe: IDispatch::Invoke() function Pin
Syamlal S Nair22-May-07 23:19
Syamlal S Nair22-May-07 23:19 
GeneralRe: IDispatch::Invoke() function Pin
CPallini23-May-07 0:16
mveCPallini23-May-07 0:16 
QuestionFile operation problem. Pin
sandeepkavade22-May-07 1:57
sandeepkavade22-May-07 1:57 
QuestionRe: File operation problem. Pin
David Crow22-May-07 2:47
David Crow22-May-07 2:47 
QuestionWorker threads and GUI Pin
iayd22-May-07 1:21
iayd22-May-07 1:21 
AnswerRe: Worker threads and GUI Pin
Arman S.22-May-07 1:59
Arman S.22-May-07 1:59 
AnswerRe: Worker threads and GUI Pin
Roger Stoltz22-May-07 2:56
Roger Stoltz22-May-07 2:56 
GeneralRe: Worker threads and GUI Pin
iayd22-May-07 3:25
iayd22-May-07 3:25 
GeneralRe: Worker threads and GUI Pin
Manoj Kumar Rai22-May-07 4:18
professionalManoj Kumar Rai22-May-07 4:18 
GeneralRe: Worker threads and GUI Pin
Roger Stoltz22-May-07 5:05
Roger Stoltz22-May-07 5:05 
QuestionButton control Pin
saisp22-May-07 1:13
saisp22-May-07 1:13 
AnswerRe: Button control Pin
josip cagalj22-May-07 1:15
josip cagalj22-May-07 1:15 
AnswerRe: Button control Pin
Hamid_RT22-May-07 1:21
Hamid_RT22-May-07 1:21 
AnswerRe: Button control Pin
Hamid_RT22-May-07 1:25
Hamid_RT22-May-07 1:25 
GeneralRe: Button control Pin
saisp22-May-07 1:56
saisp22-May-07 1:56 

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.