Get external app name from .exe

Hi! This is my first thread here. I have been searching half of the day now trying to find a way to get the name of an application trough its .exe.

I am able to get the name of the exe easly.

For example, if I have the path to an application that is:
C:\Program Files\AVG\AVG10\avgtray.exe

I would like to get the name of the application (not avgtray but AVG Antivirus).

Another example is:
C:\Program Files\SRS Labs\Audio Sandbox\SRSSSC.exe /hideme

I would like to get: SRS Audio Sandbox.

I am able to use this:
1
2
3
4
5
6
7
    char szAppPath[MAX_PATH] = "";
    string strAppName;

    ::GetModuleFileName(NULL, szAppPath, MAX_PATH);

    strAppName = szAppPath;
    strAppName = strAppName.substr(strAppName.rfind("\\") + 1);

And from that get the name of the file (not the app). Even tought it is the name of the file of the application oppened and not a specified application.

Q: So, is there a way I can get the name of the application (not name of .exe file) from the .exe file?

Even better would be a way to get into strings the information that you can see of an .exe in Properties>Details.

Thanks in advanced. (Sorry if I make a post mistake)
The title of an application can be changed at any time during its runtime. The task of getting its name without launching it to check its title would involve digging through the machine code and looking for one of many possible ways to change the title.
Last edited on
Isn't there a way to accesse the info found in Properties>Details? Because the info I want is found there.

Thanks again.
You could check the specific program in registry to see if the (partial) name is stored there.
I went to check the registry and it does not contains the name of the program equal to the one in Properties>Details (that is AVG Internet Security). Maybe this Details are stored somewere else in the registry. I'll search a bit more in the registry to see what I can find.
No, I could not find anything in the registry.

So, isn't there a way to get this info from the .exe file?

Thanks.
Do you want the "File Description" field or the "Product Name" field?
The "Product Name" field is the most important. All of the fields would be better, but I need at least the "Product Name".

Thanks.
I found this:
1
2
3
4
public:
static property String^ ProductName {
	String^ get ();
}

And an exmaple code:
1
2
3
4
5
6
private:
   void PrintProductName()
   {
      textBox1->Text = "The product name is: {0}",
         Application::ProductName;
   }

In this web page: http://msdn.microsoft.com/en-us/library/system.windows.forms.application.productname%28v=VS.100%29.aspx

The problem is I don't see how I can use that.
I want with a string, that is a path to an application, get the product name.
With: "C:\Program Files\AVG\AVG10\avgtray.exe"
Get: "AVG Internet Security"
That can be found in: avgtray.exe>properties>details>Product Name.

Thanks again for your help.
That looks like C#, which isn't C++. You'd need to look for C++ windows commands that do it - I know there are some because I wrote an app once that could get all these properties - unfortunately I used a C++ DLL that got the info, so I don't know how it did it.
Hm, that is what I was expecting, that this code was C# and not C++.

Here was the solution that I got:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;

int main()
{
     string Description;

     FileVersionInfo::GetVersion(Path::Combine(Enviroment::SystemDirectory, "Notepad.exe"));
     FileVersionInfo^ myFileVersionInfo = FileVersionInfo::GetVersionInfo(Environment::SystemDirectory + "\\Notepad.exe");
     Description = myFileVersionInfo->FileDescription;

     // Display result in console.
     cout << Description << endl;
}


One thing about a library for this, I will have to include it with the final app(same directory has my app's exe)?

Do you recall the name of the DLL? I really need to do this or my app will not be very friendly for the other users.
Last edited on
Topic archived. No new replies allowed.