Using BSTR* for Object method of an Automation server
Xavier PILLONS -- 100335.221@compuserve.com Wednesday, August 28, 1996 Environment: Win95, VC++ 4.2 When using a BSTR* as a parameter of an OLE Automation server, I have the following message when calling this method in the client software : First-chance exception in Client.exe (OLEAUT32.DLL): 0xC0000005: Access Violation. Here is the code of the server : void CServerDoc::GetDataValue(BSTR FAR* lpbstr) { // TODO: Add your dispatch handler code here CString strData1; strData1 = "Nom Champ 1"; *lpbstr = strData1.AllocSysString(); } This method have been created using class wizard. Here is the code of the client : COleServer* pOleServer; pOleServer = new COleServer; if (!pOleServer) return; BSTR bstr1, bstr2; pOleServer->GetDataValue(&bstr1); // It hang on this call strData1 = bstr1; if (bstr1) ::SysFreeString( bstr1 ); The COleServer class have been imported from the TypeLib using class wizard. Any help would be appreciate, Xavier Pillons SETE Inc.
Benny -- blee@filenet.com Friday, August 30, 1996 >>Environment: Win95, VC++ 4.2 >> >>When using a BSTR* as a parameter of an OLE Automation server, I have the >>following message when calling this method in the client software : >>First-chance exception in Client.exe (OLEAUT32.DLL): 0xC0000005: Access >>Violation. I am not positive on this. Try CoTaskMemFree instead of SysFreeString. I bumped into this problem a while back ago. Benny
Xavier PILLONS -- 100335.221@compuserve.com Monday, September 02, 1996 I've found my mistake, because of the non initialisation of BSTR pointers. They must be NULL before calling my OLE method because they are allocated by the OLE automation. Thanks for your answer. Xavier. ---------- Lee Benny wrote : >>Environment: Win95, VC++ 4.2 >> >>When using a BSTR* as a parameter of an OLE Automation server, I have the >>following message when calling this method in the client software : >>First-chance exception in Client.exe (OLEAUT32.DLL): 0xC0000005: Access >>Violation. I am not positive on this. Try CoTaskMemFree instead of SysFreeString. I bumped into this problem a while back ago. Benny
| Вернуться в корень Архива |