dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Problem with using visual C++ LoadString function

  1. #1
    Join Date
    Dec 2019
    Posts
    4

    Problem with using visual C++ LoadString function

    Hi There,

    I am using VS studio 2005 to build a dll project and I am facing a problem with "LoadString" function.

    For instance , my code seems like :
    IDRES = 250 ==> "SELECT * FROM TABLE wHERE Key=?"
    LoadString(hInst, IDRESOURCE, (LPWSTR)szReq, sizeof(szReq ) - 1);

    Where hInst is defined as HINSTANCE, IDRESOURCE as UID, szReq as char*.

    The result is that : Req is really filled with the above text. But, the text is brought back but with a null character after each character :
    szReq[0]='S'
    szReq[1]='\0'
    szReq[2]='E'
    szReq[3]='\0'
    szReq[4]='L'
    ....

    How to manage to get the full text string ?

    Regards
    Ambroise

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,580

    Re: Problem with using visual C++ LoadString function

    I guess the problem is the mixture of unicode anf ANSI: you are loading string as a UNICODE, but then trying to interpret it as an ANSI
    Victor Nijegorodov

  3. #3
    Join Date
    Dec 2019
    Posts
    4

    Re: Problem with using visual C++ LoadString function

    Good, it is working with you remmandations .
    Thank you very much !

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)