Solved

geting application executable name

Posted on 2004-03-21
7
1,164 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
7 Comments
 

Expert Comment

by:tadoox
Comment Utility
ExtractFileName(Application.ExeName)
0
 

Author Comment

by:andrezzz
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

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

Expert Comment

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

Expert Comment

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

Accepted Solution

by:
Bobcsi earned 75 total points
Comment Utility

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now