Solved

geting application executable name

Posted on 2004-03-21
7
1,169 Views
Last Modified: 2007-12-19
I have hooks on windows (HCBT_ACTIVATE, HCBT_CREATEWND , HCBT_DESTROYWND)
To get aplication name I trie  GetWindowModuleFileName(Wnd, filename, 255);
But in many cases the result is dll file.
How I can get in all cases executable file name ?
for example if there are runngin Microsoft Explorer, then i must get iexplore.exe in all cases,but not some BROWSEUI.dll
0
Comment
Question by:andrezzz
[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
7 Comments
 

Expert Comment

by:tadoox
ID: 10644049
ExtractFileName(Application.ExeName)
0
 

Author Comment

by:andrezzz
ID: 10644068
ExtractFileName cut out only directory path... but i need executable file name of dll or executable file name of windows hook...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 10644374
var arrCh : array [0..MAX_PATH] of char;
begin
  GetModuleFileName(0, arrCh, MAX_PATH);

This will give you the path+name of the current application. If you want to have the path of the current dll, use "HInstance" instead of "0".
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:andrezzz
ID: 10644382
I DON'T WANT TO GET DLL NAME, I WANT EXECUTABLE FILENAME...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 10644389
Just read my comment again before shouting. I gave you the solution.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 10644391
If you don't believe it, just try it.
0
 
LVL 2

Accepted Solution

by:
Bobcsi earned 75 total points
ID: 10656082

Function ProcessList():Tstrings;
var
 h: HWND;
 s: tagPROCESSENTRY32;
 a:string;
 ret: Tstrings;
 i:integer;
begin
 ret:=TstringList.Create;
 h:=CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0);
 s.dwSize:=sizeof(tagPROCESSENTRY32);
 Process32First(h, s);
 i:=0;
 While Process32Next(h, s) do
 begin
  a:=s.szExeFile;
  a:=a+'  '+IntToStr(s.th32ProcessID);
  ret.add(a);
  inc(i);
 end;
 ProcessList:=ret;
end;

It lists the running process, and it is get back the exe filenames...
e.g.:
iexplorer.exe
notepad.exe
winword.exe


Bobcsi
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…

726 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