bucherren
bucherren

Reputation: 299

Got error 1813 when calling VerQueryValue

I want to get the version info of a dll or exe. To do this I call the function VerQueryValue.

Here is my code:

    UINT  dwBytes;

    DWORD  dwSize = GetFileVersionInfoSizeA(pszFile, (DWORD*)&dwBytes);
    if( dwSize == 0)
        return;

    struct LANGANDCODEPAGE {
        WORD wLanguage;
        WORD wCodePage;
    } *lpTranslate;

    UINT cbTranslate;

    LPVOID lpData = (LPVOID)malloc(dwSize);
    ZeroMemory(lpData, dwSize);       
    if(GetFileVersionInfoA(pszFile, 0, dwSize, lpData) )
    {       
        VerQueryValueA(lpData, 
            "\\VarFileInfo\\Translation",
            (LPVOID*)&lpTranslate,
            &cbTranslate);

        // Read the file description for each language and code page.
        char    strSubBlock[MAX_PATH] = {0};
        char* lpBuffer;

        for(int i=0; i < (cbTranslate/sizeof(struct LANGANDCODEPAGE)); i++ )
        {
            sprintf(strSubBlock, 
                "\\StringFileInfo\\%04x%04x\\FileDescription",
                lpTranslate[i].wLanguage,
                lpTranslate[i].wCodePage);


            // Retrieve file description for language and code page "i". 
            VerQueryValueA(lpData, 
                strSubBlock, 
                (void**)&lpBuffer, 
                &dwBytes); 
        }
    }
    free( lpData );

I got a 1813 error when calling VerQueryValueA. This code is almost same with with url http://msdn.microsoft.com/zh-cn/library/ms647464%28v=vs.85%29 .

I have tested the code under vc++6 and vc++2005 and got the same error. My windows is win7.

How should I fix it? Thanks in advanced.

Upvotes: 2

Views: 3763

Answers (1)

mox
mox

Reputation: 6314

According to MSDN, this error code maps to ERROR_RESOURCE_TYPE_NOT_FOUND. Thus I would conclude that the Resource you are looking for (FileDescription) does not exist in the image file.

Upvotes: 4

Related Questions