473,322 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Finding parent process of a DLL

Hi,

Probably an easy one if you know how, but I'm stumped...

I've got a function in a DLL and I need to be able to find out the
application path of the application that's called it. From my searches there
seems to be some stuff that allows you to list currently running processes
but this isn't quite what I need. Any help appreciated.

Steve
Nov 17 '05 #1
5 2721
Steve McLellan wrote:
Hi,

Probably an easy one if you know how, but I'm stumped...

I've got a function in a DLL and I need to be able to find out the
application path of the application that's called it. From my
searches there seems to be some stuff that allows you to list
currently running processes but this isn't quite what I need. Any
help appreciated.


THCAR szName[MAX_PATH]
::GetModuleFileName(0,szName,MAX_PATH);

-cd
Nov 17 '05 #2
> Steve McLellan wrote:
Hi,

Probably an easy one if you know how, but I'm stumped...

I've got a function in a DLL and I need to be able to find out the
application path of the application that's called it. From my
searches there seems to be some stuff that allows you to list
currently running processes but this isn't quite what I need. Any
help appreciated.


THCAR szName[MAX_PATH]
::GetModuleFileName(0,szName,MAX_PATH);

-cd


That sounds like it'll do the trick, thanks :-)

What's classed as a 'module'? Aren't DLLs considered modules themselves?
From what I picked up from the documentation, it seemed like applications
are considered processes, and processes can have more than one module under
their command. The example I've got is a plug-in DLL running inside a host
application, and I need the filename of the application.

Thanks,

Steve
Nov 17 '05 #3

"Steve McLellan" <sj*@fixerlabs.com.NOSPAM> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Steve McLellan wrote:
Hi,

Probably an easy one if you know how, but I'm stumped...

I've got a function in a DLL and I need to be able to find out the
application path of the application that's called it. From my
searches there seems to be some stuff that allows you to list
currently running processes but this isn't quite what I need. Any
help appreciated.
THCAR szName[MAX_PATH]
::GetModuleFileName(0,szName,MAX_PATH);

-cd


That sounds like it'll do the trick, thanks :-)

What's classed as a 'module'? Aren't DLLs considered modules themselves?
From what I picked up from the documentation, it seemed like applications
are considered processes, and processes can have more than one module

under their command. The example I've got is a plug-in DLL running inside a host
application, and I need the filename of the application.

DLLs, EXEs, Drivers (which are really DLLs) are Modules. The HMODULE for a
module is simply the base address of the module image cast to DWORD (e.g.
EXEs are typically based at 0x40000 so their HMODULE is 0x40000).

The documentation for GetModuleFileName is a bit misleading since it says
that passing NULL as the HMODULE will return the name of the "current
module". What it doesn't say is that the "current module" is in fact the
module from which the calling process was created - i.e. the EXE file.

-cd
Nov 17 '05 #4
"Steve McLellan" <sj*@fixerlabs.com.NOSPAM> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
What's classed as a 'module'? Aren't DLLs considered modules themselves?


Yes, they are. But by passing zero for the module handle as Carl suggests,
you are asking the function to return the "main" module.

Regards,
Will
Nov 17 '05 #5
OK, cheers both of you - that's a lot clearer than the documentation.

Thanks!

Steve

"William DePalo [MVP VC++]" <wi***********@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
"Steve McLellan" <sj*@fixerlabs.com.NOSPAM> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
What's classed as a 'module'? Aren't DLLs considered modules themselves?


Yes, they are. But by passing zero for the module handle as Carl suggests,
you are asking the function to return the "main" module.

Regards,
Will

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: gnutuxy | last post by:
Hi, I am newbie in the Unix system programming and in learning phase. I usually read the libc manual and then try to implement small programs to test/check the learnt thing. I read the libc...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
4
by: Phil Mc | last post by:
Say for example you have a application running on a windows 2003 server (that is on server, not from). This application needs to start child applications (must be stand alone console applications),...
5
by: Manish | last post by:
This is the print_r() for a variable $categories. $categories :: Array ( =Array ( =Array (
3
by: bp4444 | last post by:
On a HPUX, a CPP program. In main() defined a variable as int x = 900, called fork(), changed value of x as 89 in child process. Printed the address of x and value of x in child process and also...
1
by: hrubesh | last post by:
Hi, I am having a problem finding the right location of a control if it is found on a form that is on an MDI parent. On mouse click, i want to bring out a "pop up window" that will display extra...
2
by: Karthik Gurusamy | last post by:
Hi, Wondering if there is a way to measure a child process's cpu usage (sys and user) when the child is still running. I see os.times() working fine in my system (Linux 2.6.9-42.7.ELsmp), but it...
4
by: jewel87 | last post by:
Hi everyone! I'm writing some code in C under UNIX, which should give some output like this: PARENT: pid = 10063 CHILD: my pid = 10064 CHILD: my parent's pid = 10063 CHILD: Sleeping... PARENT:...
1
by: KakaICE | last post by:
Hi, I am using Visual Studio 2005 The problem is: The parent.exe launches a child.exe executible. In the child.exe process I want to know the commandline with which parent.exe was originally...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.