While working on com interop ,i followed the tutorial on this link.The code runs fine but the problem comes while dealing with the string.Although i have some knowledge about BSTR string type but unable to execute code on c++ section where the fuctions are being called. On c# side, the fuction is as follows:
public void ShowDialog([MarshalAs(UnmanagedType.BStr)] string stringToPrint)
how do i call this fuction from c++ while passing the string value from here?
here is the c++ code section
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
MyInterop::IMyDotNetInterfacePtr pDotNetCOMPtr;
HRESULT hRes = pDotNetCOMPtr.CreateInstance(MyInterop::CLSID_MyDotNetClass);
if (hRes == S_OK)
{
BSTR s;
pDotNetCOMPtr->ShowDialog(s);
}
CoUninitialize();
}
the requirement is the that string needs to to passed from c++ just like e.g
string abc
cin>abc
now this abc String needs to passed in the calling fuction ie
ShowDialog()
but i am unable to do that..any help would be appricated.thankyou.
Comments
Post a Comment