Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1178
  • Last Modified:

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
0
andrezzz
Asked:
andrezzz
1 Solution
 
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
 
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
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
 
BobcsiCommented:

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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now