Hi,
I am trying to convert a std string to a BSTR. I am using Dev C++ with mingw on windows. As far as I am aware I cannot use the ATL libraries with Dev C++ so i cannot use A2BSTR etc. Here is my code:
Code:
string path = getImagePath(); //eg C:/T2
int location = 0;
while(path.find("/",0) != string::npos) //converts image path to C:\\T2
{
location = path.find("/",0);
path.replace(location,1,"\\\\");
}
OpenSlide(path.c_str()); //a function in a wrapper dll which takes a LPCSTR of format C:\\T2
The header for open slide function in the wrapper dll is:
Code:
// Open Slide
EXTERN_C __declspec(dllexport) BOOL WINAPI OpenSlide(LPCSTR SlideName);
This wrapper DLL calls a function from another DLL that has a header:
Code:
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE OpenSlide(
/* [in] */ BSTR SlideName) = 0;
This all compiles but crashes when OpenSlide() is called. If I hard code the correct path and pass it in it seems to work however ie path = "C:\\T2";
Any help would be greatly appreciated,
Alex