Click here to Skip to main content
15,797,721 members
Home / Discussions / COM
   

COM

 
QuestionQuestion about VARIANT deallocation Pin
GuimaSun10-Aug-09 5:53
GuimaSun10-Aug-09 5:53 
AnswerRe: Question about VARIANT deallocation Pin
Hristo-Bojilov10-Aug-09 7:12
Hristo-Bojilov10-Aug-09 7:12 
GeneralRe: Question about VARIANT deallocation Pin
GuimaSun10-Aug-09 7:27
GuimaSun10-Aug-09 7:27 
GeneralRe: Question about VARIANT deallocation Pin
Hristo-Bojilov10-Aug-09 7:45
Hristo-Bojilov10-Aug-09 7:45 
GeneralRe: Question about VARIANT deallocation Pin
GuimaSun10-Aug-09 8:08
GuimaSun10-Aug-09 8:08 
AnswerRe: Question about VARIANT deallocation Pin
Stuart Dootson10-Aug-09 9:21
professionalStuart Dootson10-Aug-09 9:21 
GeneralRe: Question about VARIANT deallocation Pin
GuimaSun10-Aug-09 9:43
GuimaSun10-Aug-09 9:43 
AnswerRe: Question about VARIANT deallocation Pin
Vi210-Aug-09 23:01
Vi210-Aug-09 23:01 
How CallService is defined in IDL file? If it's "CallService([in] VARIANT *p1)", then you cannot change the parameter. If it's "CallService([in,out] VARIANT *p1), then you cannot receive the parameter in Integer.

IAC, VB passes myInt variable as VT_BYREF | VT_I2 to be possible to change the myInt value. It's made only during call some method. Inside VB don't store variant by this manner.

STDMETHODIMP CDCSClient::CallService( VARIANT *p )
{
VariantClear( p );
p->vt = VT_BSTR;
p->bstrVal = SysAllocString( L"abc" );
return S_OK;
}

If you desire to pass BSTR by reference, you should keep out this address and make sure to free this BSTR after using.

BSTR g_pBSTR = NULL; // global scope, so somewhere should be "if (!g_pBSTR) SysFreeString(g_pBSTR);"

STDMETHODIMP CDCSClient::CallService( VARIANT *p )
{
VariantClear( p );
p->vt = VT_BSTR | VT_BYREF;
if (!g_pBSTR) g_pBSTR = SysAllocString( L"abc" );
p->pbstrVal = &g_pBSTR;
return S_OK;
}

With best wishes,
Vita

GeneralRe: Question about VARIANT deallocation Pin
GuimaSun12-Aug-09 5:12
GuimaSun12-Aug-09 5:12 
GeneralRe: Question about VARIANT deallocation Pin
Vi212-Aug-09 22:37
Vi212-Aug-09 22:37 
GeneralRe: Question about VARIANT deallocation Pin
Vi213-Aug-09 1:20
Vi213-Aug-09 1:20 
Questioncalling messagebox funtion from a c# code Pin
nicetohaveyou8-Aug-09 9:22
nicetohaveyou8-Aug-09 9:22 
AnswerRe: calling messagebox funtion from a c# code Pin
Hristo-Bojilov10-Aug-09 4:27
Hristo-Bojilov10-Aug-09 4:27 
QuestionInvalidCastException by registering events on Office Add-In Pin
maesi19808-Aug-09 6:54
maesi19808-Aug-09 6:54 
AnswerRe: InvalidCastException by registering events on Office Add-In [modified] Pin
maesi198010-Aug-09 1:45
maesi198010-Aug-09 1:45 
QuestionCom Component Pin
sekannak7-Aug-09 0:58
sekannak7-Aug-09 0:58 
AnswerRe: Com Component Pin
Randor 9-Aug-09 10:53
professional Randor 9-Aug-09 10:53 
GeneralRe: Com Component Pin
sekannak9-Aug-09 19:57
sekannak9-Aug-09 19:57 
QuestionWMP loop playing - black between each play Pin
pimb26-Aug-09 3:46
pimb26-Aug-09 3:46 
AnswerRe: WMP loop playing - black between each play --- found a solution Pin
pimb26-Aug-09 3:53
pimb26-Aug-09 3:53 
Questioninvoke output parameters to javascript? Pin
Hongjun Ge5-Aug-09 7:11
Hongjun Ge5-Aug-09 7:11 
AnswerRe: invoke output parameters to javascript? Pin
Vi25-Aug-09 21:49
Vi25-Aug-09 21:49 
GeneralRe: invoke output parameters to javascript? Pin
Hongjun Ge6-Aug-09 4:54
Hongjun Ge6-Aug-09 4:54 
GeneralRe: invoke output parameters to javascript? Pin
Vi26-Aug-09 21:24
Vi26-Aug-09 21:24 
GeneralRe: invoke output parameters to javascript? Pin
Hongjun Ge7-Aug-09 6:57
Hongjun Ge7-Aug-09 6:57 

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.