Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Application's "real" (full) name

Posted on 2004-11-01
5
Medium Priority
?
734 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
Comment
Question by:vukotic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:vacerose
ID: 12462972
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 46

Expert Comment

by:Kent Olsen
ID: 12462996

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:
vacerose earned 600 total points
ID: 12463116
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
Cayce earned 600 total points
ID: 12463893
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
ID: 12470877
Thanks! :)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

636 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