Solved

geting application executable name

Posted on 2004-03-21
7
1,166 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
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

16 Experts available now in Live!

Get 1:1 Help Now