Solved

Application's "real" (full) name

Posted on 2004-11-01
728 Views
Last Modified: 2013-11-17
Hi :)
I will, once again, explain my problem thorugh an example:
File name of an application is, for example, "ttlcmd.exe"... When you run the program (or look at the file properties) you see it's full name: "Total commander"...
How can i extract this information without opening a file?

I have tried with
GetFileVersionInfoSize,
GetFileVersionInfo,
VerFindFile
combination, but, you guess, i wouldn't be asking this if i suceeded :)

Thanks in advance
0
Question by:vukotic
    5 Comments
     
    LVL 1

    Expert Comment

    by:vacerose
    The following works to get the Product Name from a Builder compiled app...

    AnsiString __fastcall TForm1::GetFileVersionString(AnsiString fname)
    {
      DWORD junk, size;
      Pointer pBuf, lpBuffer;
      Cardinal dwBytes;
      AnsiString Result="";

      pBuf=NULL;
      size=GetFileVersionInfoSize(fname.c_str(), &junk);

      if (size>0)
      {
             try
        {
                   pBuf=malloc(size);
          if (pBuf!=NULL)
          {
            GetFileVersionInfo(fname.c_str(), 0, size, pBuf);
            if (VerQueryValue(pBuf, "\\StringFileInfo\\040904E4\\ProductName", &lpBuffer, &dwBytes))
              Result=AnsiString(PChar(lpBuffer));
             
          }
        }
        __finally
        {
          if (pBuf!=NULL)
            free(pBuf);
        }
      }
      return Result;
    }
    0
     
    LVL 45

    Expert Comment

    by:Kdo

    Do you want Application->ExeName ?

    And of course, there's Application->Title and Application->Name, but I doubt that those are what you want.

    Kent
    0
     
    LVL 1

    Accepted Solution

    by:
    Here this is a little more general.

    AnsiString __fastcall TForm1::GetFileVersionString(AnsiString fname)
    {
      DWORD junk, size;
      Pointer pBuf, lpBuffer;
      Cardinal dwBytes;
      AnsiString lang="", Result="";

      pBuf=NULL;
      size=GetFileVersionInfoSize(fname.c_str(), &junk);

      if (size>0)
      {
             try
        {
                   pBuf=malloc(size);
          if (pBuf!=NULL)
          {
            GetFileVersionInfo(fname.c_str(), 0, size, pBuf);
            if (VerQueryValue(pBuf, "\\VarFileInfo\\Translation", &lpBuffer, &dwBytes))
            {
              lang=AnsiString::IntToHex((PWORD(lpBuffer))[0], 4);
              lang+=AnsiString::IntToHex((PWORD(lpBuffer))[1], 4);

              if (VerQueryValue(pBuf, AnsiString("\\StringFileInfo\\" + lang + "\\ProductName").c_str(), &lpBuffer, &dwBytes))
                Result=AnsiString(PChar(lpBuffer));
            }
          }
        }
        __finally
        {
          if (pBuf!=NULL)
            free(pBuf);
        }
      }
      return Result;
    }
    0
     
    LVL 9

    Assisted Solution

    by:Cayce
    You can download and use this component:

    http://www.imranweb.com/exever.cpp
    http://www.imranweb.com/ExeVer.h

    If you want to extract this information from _another_ program different from the one you are running, just change all the ocurrences of Applicaiton->ExeName in the above code to a String containing the file name of the executable whose information you want to extract.

    Luck
    0
     

    Author Comment

    by:vukotic
    Thanks! :)
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
    How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now