Problem with VerQueryValue

This is a discussion on Problem with VerQueryValue within the Windows Programming forums, part of the Platform Specific Boards category; I'm using the VerQueryVal to obtain the company name from a data structure acquired by GetFileVersionInfo, but it's returning strange ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    123

    Problem with VerQueryValue

    I'm using the VerQueryVal to obtain the company name from a data structure acquired by GetFileVersionInfo, but it's returning strange results. Here is the code snippet:

    Code:
    res2 = VerQueryValue(fdata, "\\VarFileInfo\\Translation", &lpXlate, &lpXlatelen); // Get translation details
    found = 0; // Not found a company name yet
    i = 0;
    while (found == 0 && i < (lpXlatelen / sizeof(LANGANDCODEPAGE)))
    {
    	hr = sprintf(workbuf, "\\StringFileInfo\\%04x%04x\\CompanyName", lpXlate.wLanguage, lpXlate.wCodePage); // Get the Company Name request string
    	if (hr > 0)
    	{
    		// Get company name details (returns non-zero if successful)
    		found = VerQueryValue(fdata, workbuf, &fcompany, &fcompanylen);
    	}
    	i ++; // Next iteration
    }
    If I put a debug in at the sprintf line, I notice that for the file C:\Windows\System\sti.dll (manufactured by Microsoft, and according to the properties is in US English), I get a code of 08d00041.

    The next file, C:\Windows\System\ole32.dll (also in US English, made by M$) gives a translation and code page of 0c740041.

    The VerQueryValue to return the company name in each case gives me nothing at all.

    Any ideas why I'm getting strange results? This is on my Win98 box; I'll test on my XP laptop later today but I do need this to work on both platforms.

    There is only one iteration each time, so it's not as if there are multiple languages and I'm only seeing the first one.
    I think you can put a signature here.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You're not retrieving the information correctly. lpXlate needs to be a pointer and you need to access its information using lpXlate[i].wLanguage. This is shown in the example provided by the documentation.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    123

    Thumbs up

    Thanks anonytmouse ....

    I had defined the structure slightly differently, which caused me to use it incorrectly as you pointed out.

    Once I realised that, I tried what you suggested there with perfect results

    Thanks again!
    I think you can put a signature here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21