Can a prog find its own Name?

  • Thread starter Thread starter Barry Flynn
  • Start date Start date
B

Barry Flynn

Win Forms program - VB 2005.

I am converting a VB6 program to VB 2005.
The program wants to know its own name - ie the name of the .exe that has
been executed.
It gets this from App.exename

In VB 2005, I have replaced this with My.Application.Info.AssemblyName.
However, if the program has been renamed after it was Built, that returns
the name it was Built as, rather than the name of the .exe that has actually
been executed.

Is the name of the actual .exe available?

Thanks

Barry
 
Barry Flynn said:
Win Forms program - VB 2005.

I am converting a VB6 program to VB 2005.
The program wants to know its own name - ie the name of the .exe that has
been executed.
It gets this from App.exename

In VB 2005, I have replaced this with My.Application.Info.AssemblyName.
However, if the program has been renamed after it was Built, that returns
the name it was Built as, rather than the name of the .exe that has
actually been executed.

Is the name of the actual .exe available?

Thanks

Barry

Will this work?

[C#]
System.Diagnostics.Process p =
System.Diagnostics.Process.GetCurrentProcess();
String n = p.ProcessName;

-Scott
 
Looks good.

Thanks

Barry


Scott M. said:
Barry Flynn said:
Win Forms program - VB 2005.

I am converting a VB6 program to VB 2005.
The program wants to know its own name - ie the name of the .exe that has
been executed.
It gets this from App.exename

In VB 2005, I have replaced this with My.Application.Info.AssemblyName.
However, if the program has been renamed after it was Built, that returns
the name it was Built as, rather than the name of the .exe that has
actually been executed.

Is the name of the actual .exe available?

Thanks

Barry

Will this work?

[C#]
System.Diagnostics.Process p =
System.Diagnostics.Process.GetCurrentProcess();
String n = p.ProcessName;

-Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top