[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

geting application executable name

Posted on 2004-03-21
7
Medium Priority
?
1,175 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 300 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

650 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