how to pass Cstring to vb dll fuction in vc++
-
hi friend, i have vb dll..in the vb dll one fuction f1; Public Function f1(SendString As String) As String - this function taking as argument and return string... how i will call in vc++; CoInitialize(NULL); hresult=CLSIDFromProgID(OLESTR("prjdll.clsdll"), &clsid); _clsdll *t; hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_clsdll),(LPVOID *) &t); CString str= "000001"; t->f1(str); // this is crasing.... please help any body.
-
hi friend, i have vb dll..in the vb dll one fuction f1; Public Function f1(SendString As String) As String - this function taking as argument and return string... how i will call in vc++; CoInitialize(NULL); hresult=CLSIDFromProgID(OLESTR("prjdll.clsdll"), &clsid); _clsdll *t; hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_clsdll),(LPVOID *) &t); CString str= "000001"; t->f1(str); // this is crasing.... please help any body.
You need to pass this as a BSTR (or possibly a BSTR encapsulated in a VARIANT). Open the VB DLL in the OLE/COM Object Viewer (use the File->View TypeLib... command) to see what parameter type the VB DLL is expecting to see for this call.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!
-
hi friend, i have vb dll..in the vb dll one fuction f1; Public Function f1(SendString As String) As String - this function taking as argument and return string... how i will call in vc++; CoInitialize(NULL); hresult=CLSIDFromProgID(OLESTR("prjdll.clsdll"), &clsid); _clsdll *t; hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_clsdll),(LPVOID *) &t); CString str= "000001"; t->f1(str); // this is crasing.... please help any body.
You cannot pass a
CString
's instance, you've to pass aBSTR
. Anyway, theMember 3653751 wrote:
t->f1(str);
call seems wrong (what is
_clsdll
type?) :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]