Application's "real" (full) name

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
vukoticAsked:
Who is Participating?
 
vaceroseCommented:
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
 
vaceroseCommented:
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
 
Kent OlsenData Warehouse Architect / DBACommented:

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
 
CayceCommented:
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
 
vukoticAuthor Commented:
Thanks! :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.