geting application executable name

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
andrezzzAsked:
Who is Participating?
 
BobcsiConnect With a Mentor Commented:

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
 
tadooxCommented:
ExtractFileName(Application.ExeName)
0
 
andrezzzAuthor Commented:
ExtractFileName cut out only directory path... but i need executable file name of dll or executable file name of windows hook...
0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
MadshiCommented:
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
 
andrezzzAuthor Commented:
I DON'T WANT TO GET DLL NAME, I WANT EXECUTABLE FILENAME...
0
 
MadshiCommented:
Just read my comment again before shouting. I gave you the solution.
0
 
MadshiCommented:
If you don't believe it, just try it.
0
All Courses

From novice to tech pro — start learning today.