CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2002
    Posts
    1,798

    Problem using wstring converted from char * in dll class

    I have attached a demo app. A lengthy post was lost by the server.

    Edit:

    I figured it out when I built a simple demo project. Problem arose because of trying to access a c-wrapper dll from the app class whereas the wrapper class had not been initialized there but rather in the main dialog class - so naturally it didn't work!!! Anyway, I've attached the demo for any who might be interested, but I regard the problem as resolved. Shows the value of building simple projects to isolate a problem. I failed to appreciate the order in which such a program initializes - I guess it's always App first, then MainFrame, then Doc and View (I think).

    Thanks.
    Last edited by Mike Pliam; June 17th, 2013 at 02:38 PM.
    mpliam

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Problem using wstring converted from char * in dll class

    >> I have attached a demo app.
    I don't see it.

    gg

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Problem using wstring converted from char * in dll class

    Code:
    CMyClass * g_pMyClass;
    
    MY_API void StartUpMY()
    {
        g_pMyClass = new CMyClass();
    }
        
    MY_API void CleanUpMY()
    {
        delete g_pMyClass;
    }
    Is there any point to construct CMyClass instance explicitly with new? The code does not show any reason why that wouldn't be just:
    Code:
    CMyClass g_myClass;
    Best regards,
    Igor

  4. #4
    Join Date
    May 2002
    Posts
    1,798

    Re: Problem using wstring converted from char * in dll class

    Quote Originally Posted by Igor Vartanov View Post
    Code:
    CMyClass * g_pMyClass;
    
    MY_API void StartUpMY()
    {
        g_pMyClass = new CMyClass();
    }
        
    MY_API void CleanUpMY()
    {
        delete g_pMyClass;
    }
    Is there any point to construct CMyClass instance explicitly with new? The code does not show any reason why that wouldn't be just:
    Code:
    CMyClass g_myClass;
    Good point, Igor. I'll give it a try. It's just a habit that I have fallen into and had never questioned it. Thanks for your suggestion.
    mpliam

  5. #5
    Join Date
    May 2002
    Posts
    1,798

    Re: Problem using wstring converted from char * in dll class

    Quote Originally Posted by Codeplug View Post
    >> I have attached a demo app.
    I don't see it.

    gg
    Everything is t- t- t- timing!
    mpliam

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Problem using wstring converted from char * in dll class

    Quote Originally Posted by Mike Pliam View Post
    Good point, Igor. I'll give it a try. It's just a habit that I have fallen into and had never questioned it. Thanks for your suggestion.
    It's just a habit to analyze every variable life cycle and everything else that might conflict with or benefit from the one. Most of the times it's trivial. But sometimes it can spare a couple of dll exports. Or couple days of debugging.
    Last edited by Igor Vartanov; June 18th, 2013 at 02:06 PM.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured