how to use GetModuleHandle 
Author Message
 how to use GetModuleHandle

i want to get HMODULE of some exe file,i.e.

 HMODULE  hModule;
 hModule = GetModuleHandle("Studio Manager.exe");

but hModule is always NULL. i want to know how to know the exactly name of
some application?

If  u know about this question ,please tell me ,thanks a lot !



Sat, 05 Jun 2004 12:55:24 GMT  
 how to use GetModuleHandle
I think you can use GetLastError() to know why???


Quote:
> i want to get HMODULE of some exe file,i.e.

>  HMODULE  hModule;
>  hModule = GetModuleHandle("Studio Manager.exe");

> but hModule is always NULL. i want to know how to know the exactly name of
> some application?

> If  u know about this question ,please tell me ,thanks a lot !



Fri, 04 Jun 2004 22:16:40 GMT  
 how to use GetModuleHandle
Note that this would make sense only if you are running a program called "Studio
Manager.exe", since the documentation states "the name is compared (case independently) to
the names of modules CURRENTLY MAPPED INTO THE ADDRESS SPACE OF THE CALLING PROCESS"
(emphasis added). Since you specified a .exe file, and only one .exe file can be mapped
into the address space, this cannot work unless the name you use is the name of the
executable. Note that this has absolutely nothing to do with the name of the application;
that's GetModuleFileName. There are many ways to get process handles of another process,
but GetModuleHandle clearly is not among them. Look at EnumProcesses,
GetWindowThreadProcessId. Also check out KB article Q119163.
                        joe

Quote:

>i want to get HMODULE of some exe file,i.e.

> HMODULE  hModule;
> hModule = GetModuleHandle("Studio Manager.exe");

>but hModule is always NULL. i want to know how to know the exactly name of
>some application?

>If  u know about this question ,please tell me ,thanks a lot !

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Sat, 05 Jun 2004 00:15:05 GMT  
 how to use GetModuleHandle
Hi,

GetModuleName will not work for module in other process.  The
GetModuleHandle function retrieves a module handle for the specified module
if the file has been mapped into the address space of the calling process.

Best regards,
Billy Zhang
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
reserved.



Sun, 06 Jun 2004 14:33:30 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. GetModuleHandle crashing IE

2. GetModuleHandle() Fails Under Debug Mode??

3. GetModuleHandle

4. Using types in a different assembly given that the type may be used or not used

5. using using

6. How to encrypt (RSA) using private key and decrypt using public key

7. On using "using"

8. Lattice C anyone using/used it ?

9. Help with writing and using DLL using Borland 3.1

10. Problem Hosting ActiveX Controls Using ATL AXHost (CAxWindow2) using VC7

11. Problem using Requery() using DAO

12. Beginner: Problems Using OLE Forms using VC++ 4.0

 

 
Powered by phpBB® Forum Software