Click here to Skip to main content
15,903,203 members
Home / Discussions / COM
   

COM

 
GeneralRe: COM interface: EnumFormatEtc Pin
Stefan Pedersen27-Dec-03 10:59
Stefan Pedersen27-Dec-03 10:59 
GeneralRe: COM interface: EnumFormatEtc Pin
Jörgen Sigvardsson6-Jan-04 6:25
Jörgen Sigvardsson6-Jan-04 6:25 
GeneralRegister an exe COM server Pin
User 78226222-Dec-03 22:58
professionalUser 78226222-Dec-03 22:58 
GeneralRe: Register an exe COM server Pin
valikac26-Dec-03 5:39
valikac26-Dec-03 5:39 
Generalextern "C" DllExport Function crashing Pin
Kishor Morkhandikar22-Dec-03 19:56
Kishor Morkhandikar22-Dec-03 19:56 
GeneralRe: extern "C" DllExport Function crashing Pin
Sebastián Benítez23-Dec-03 0:24
Sebastián Benítez23-Dec-03 0:24 
GeneralRe: extern "C" DllExport Function crashing Pin
Lim Bio Liong26-Dec-03 20:17
Lim Bio Liong26-Dec-03 20:17 
GeneralProblems passing a DISPPARAMS structure to IDispatch::Invoke Pin
Dark Magus22-Dec-03 17:39
Dark Magus22-Dec-03 17:39 
I desesperatly need help for passing a DISPPARAMS strucutre to IDispatch::Invoke.

Here is the calling code, in C++:
<br />
	HRESULT hr;<br />
	OLECHAR FAR* szMember = L"MyFunction";<br />
	DISPID DispatchID;<br />
<br />
	int i = 10; // The variable I use for testing<br />
<br />
	DISPPARAMS DispatchParams;<br />
	DispatchParams.cArgs=1;<br />
	DispatchParams.rgvarg = new VARIANTARG[1];<br />
	DispatchParams.rgvarg[0].vt = VT_BYREF|VT_INT;<br />
	DispatchParams.rgvarg[0].pintVal = &i;<br />
	DispatchParams.rgdispidNamedArgs=NULL;<br />
	DispatchParams.cNamedArgs=0;<br />
<br />
	CoInitialize(NULL);<br />
<br />
	if (FAILED(hr = CoCreateInstance(MyCLSID, NULL, CLSCTX_SERVER, IID_IUnknown, (void FAR* FAR*)&pUnknown))) return hr;<br />
	if (FAILED(hr = pUnknown->QueryInterface(IID_IDispatch, (void FAR* FAR*)&pDispatch))) return hr;<br />
	if (FAILED(hr = pDispatch->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_USER_DEFAULT, &DispatchID))) return hr;<br />
<br />
<br />
	hr = pDispatch->Invoke(DispatchID, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &DispatchParams, NULL, NULL, NULL);<br />
<br />


And this is the function I'm trying to call, in VB:
<br />
	Public Function MyFunction(ByRef Parameter As Integer)<br />
		MsgBox Str(Parameter), , "Parameter:"<br />
	End Function<br />


When I run the calling code, IDispatch::Invoke returns a type mismatch error. However, if I enlarge the rgvarg field of the DispatchParams structure and write the parameter into rgvarg[1] instead of rgvarg[0] (while cArg is still 1), it does not return any error and MyFunction does show the message box, but it shows the value is 0, while it is supposed to be 10. I would add that I have no problems when using IDispatch::Invoke for calling functions that have no parameters.

I've spent hours trying to figure out what was wrong but it went nowhere. Would someone please help me ?
GeneralRe: Problems passing a DISPPARAMS structure to IDispatch::Invoke Pin
Vi223-Dec-03 23:36
Vi223-Dec-03 23:36 
GeneralRe: Problems passing a DISPPARAMS structure to IDispatch::Invoke Pin
Dark Magus25-Dec-03 11:34
Dark Magus25-Dec-03 11:34 
GeneralRe: Problems passing a DISPPARAMS structure to IDispatch::Invoke Pin
Vi225-Dec-03 19:21
Vi225-Dec-03 19:21 
GeneralRe: Problems passing a DISPPARAMS structure to IDispatch::Invoke Pin
Dark Magus26-Dec-03 10:03
Dark Magus26-Dec-03 10:03 
Generalabout LocalServer COM Register Pin
yingkou22-Dec-03 15:05
yingkou22-Dec-03 15:05 
GeneralRe: about LocalServer COM Register Pin
User 78226222-Dec-03 23:16
professionalUser 78226222-Dec-03 23:16 
GeneralRe: about LocalServer COM Register Pin
Vi223-Dec-03 23:29
Vi223-Dec-03 23:29 
GeneralCOM Apartments and Marshalling Pin
Jörgen Sigvardsson22-Dec-03 14:03
Jörgen Sigvardsson22-Dec-03 14:03 
GeneralNo, that sucked Pin
Jörgen Sigvardsson23-Dec-03 7:07
Jörgen Sigvardsson23-Dec-03 7:07 
GeneralRe: No, that sucked Pin
geo_m30-Dec-03 0:32
geo_m30-Dec-03 0:32 
GeneralAll COM that expose a specific interface Pin
IreneVassileva22-Dec-03 0:00
IreneVassileva22-Dec-03 0:00 
GeneralRe: All COM that expose a specific interface Pin
Abhishek Srivastava22-Dec-03 1:01
Abhishek Srivastava22-Dec-03 1:01 
GeneralYahoo messenger login interface. Urgent Pin
SiddharthAtw21-Dec-03 18:35
SiddharthAtw21-Dec-03 18:35 
QuestionHow to access COM objects during runtime? Pin
dapipi21-Dec-03 17:13
dapipi21-Dec-03 17:13 
AnswerRe: How to access COM objects during runtime? Pin
Anonymous21-Dec-03 18:47
Anonymous21-Dec-03 18:47 
AnswerRe: How to access COM objects during runtime? Pin
Anonymous21-Dec-03 18:52
Anonymous21-Dec-03 18:52 
AnswerRe: How to access COM objects during runtime? Pin
Abhishek Srivastava21-Dec-03 19:07
Abhishek Srivastava21-Dec-03 19:07 

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.