Results 1 to 3 of 3

Thread: error

  1. #1

    Thread Starter
    Hyperactive Member Cmdr0Sunburn's Avatar
    Join Date
    May 2001
    Location
    g0t r00t?
    Posts
    461

    error

    i get this error error C2440: '=' : cannot convert from 'int' to 'char *', the code is
    Code:
    char *M_y;
    M_y = LoadString(hInst, IDS_STRING1, pcString, MAX_LOADSTRING);
    how can i make the error go away?
    I know a lot oF Vb, expert in C++, and i think in assembly.
    MSVC++6.NET
    vb6
    masm
    Windowz Xp
    I find my self using this a lot in C++

    __asm {
    }

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    LoadString returns the length of the string copied, not a pointer.
    LoadString
    The LoadString function loads a string resource from the executable file associated with a specified module, copies the string into a buffer, and appends a terminating null character.

    int LoadString(
    HINSTANCE hInstance, // handle to resource module
    UINT uID, // resource identifier
    LPTSTR lpBuffer, // resource buffer
    int nBufferMax // size of buffer
    );
    Parameters
    hInstance
    [in] Handle to an instance of the module whose executable file contains the string resource.
    uID
    [in] Specifies the integer identifier of the string to be loaded.
    lpBuffer
    [out] Pointer to the buffer to receive the string.
    nBufferMax
    [in] Specifies the size of the buffer, in TCHARs. This refers to bytes for ANSI versions of the function or WCHARs for Unicode versions. The string is truncated and null terminated if it is longer than the number of characters specified.
    Return Values
    If the function succeeds, the return value is the number of TCHARs copied into the buffer, not including the null-terminating character, or zero if the string resource does not exist. To get extended error information, call GetLastError.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    as parksie mention, the LoadString will copy the string from string table into the provided buffer (pcString) and if succeed, it will return the total number of string have been copied (for example iCnt)

    PHP Code:
    int iCnt=0;
    iCnt LoadString(hInstIDS_STRING1pcStringMAX_LOADSTRING); 
    Perhaps, you need the (LPCTSTR) too...
    PHP Code:
    int iCnt=0;
    iCnt LoadString(hInst, (LPCTSTR)IDS_STRING1pcStringstrlen(pcString)); 

    regards,

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