Thread: convert std string to bstr without ATL

  1. #1
    Registered User
    Join Date
    Nov 2006

    convert std string to bstr without ATL

    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:

    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);
    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:
    // Open Slide
    EXTERN_C __declspec(dllexport) BOOL WINAPI OpenSlide(LPCSTR SlideName);
    This wrapper DLL calls a function from another DLL that has a header:

    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,

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  3. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM
  4. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 11:06 PM
  5. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM