Click here to Skip to main content
15,921,467 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
the following code fails:

CString s;
dialogpointer->GetWindowText(s);
CComVariant(s).Detach(NameVariantPointer);

But the following works fine:

CString s;
dialogpointer->GetWindowText(s);
CComVariant var(s);
NameVariantPointer->bstrVal = var.bstrVal;
Posted

Thanks for the answer.Your solution worked perfectly.
 
Share this answer
 
0) The passed pointer may not be NULL :)
1) The referenced VARIANT must be initialized :) :
{
  VARIANT vTest = {0};
  CComVariant(_T("test")).Detach(&vTest);
...
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900