473,473 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

GetModuleHandle() function (API Programming)

5 New Member
Hi All,

I wish you could help me with this one...
my simple code uses this:
GetModuleHandle("E:\\winxp\\system32\\calc.exe");
and the return value of the function is error number 126. which is "module could not be found". and when I try this for example :
GetModuleHandle("kernel32.dll"); IT WORS !!
I do not understand where the problem is ,I have been trying for more than hour :(
Thanks,
JupeMarsInc
Nov 8 '06 #1
8 27129
sicarie
4,677 Recognized Expert Moderator Specialist
Hi All,

I wish you could help me with this one...
my simple code uses this:
GetModuleHandle("E:\\winxp\\system32\\calc.exe");
and the return value of the function is error number 126. which is "module could not be found". and when I try this for example :
GetModuleHandle("kernel32.dll"); IT WORS !!
I do not understand where the problem is ,I have been trying for more than hour :(
Thanks,
JupeMarsInc
It sounds like your path is wrong. Try "C:\\WINDOWS\\system32\\calc.exe", unless your computer is set up to use the E drive as your hd, and for some reason your WINDOWS folder was renamed to winxp. Did you put that path into Windows Explorer to verify the file is there?
Nov 8 '06 #2
JupeMarsInc
5 New Member
It sounds like your path is wrong. Try "C:\\WINDOWS\\system32\\calc.exe", unless your computer is set up to use the E drive as your hd, and for some reason your WINDOWS folder was renamed to winxp. Did you put that path into Windows Explorer to verify the file is there?
Yes ofcourse. the path is valid and the file exists...any other suggestions ?
I'd like to get some help
Nov 8 '06 #3
sicarie
4,677 Recognized Expert Moderator Specialist
JupeMarsInc-

Sorry, just had to check the basics ;). Can we see the full code?
Nov 8 '06 #4
JupeMarsInc
5 New Member
JupeMarsInc-

Sorry, just had to check the basics ;). Can we see the full code?

no problem :)

The code:

#include <stdio.h>
#include <windows.h>


Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.     HMODULE GetModH;
  4.     LPCTSTR FileMod="E:\\WINXP\\system32\\calc.exe";
  5.  
  6.  
  7.     if ((GetModH = GetModuleHandle(FileMod))==NULL)
  8.         printf("GetModuleHandle failed (%d)\n", GetLastError());
  9.  
  10.     return 0;
  11. }
and instead of "FileMod" you can just write the string as the argument to the function.

Thanks.
Nov 8 '06 #5
JupeMarsInc
5 New Member
anyone ?? :S ..
Nov 8 '06 #6
sivadhas2006
142 New Member
Can I know why u want to get the module handle of the calc.exe.

Regards,
M.Sivadhas.
Nov 9 '06 #7
Banfa
9,065 Recognized Expert Moderator Expert
From the help pages for GetModuleHandle

The GetModuleHandle function returns a module handle for the specified module if the file has been mapped into the address space of the calling process.
Kernel32.dll will have been mapped into the address space of the calling process, calc.exe wont.

What are you trying to achieve that made you think you needed the module handle of calc.exe?
Nov 9 '06 #8
sushilvanve
1 New Member
To use GetModuleHandle; the module must have been loaded by the calling process.
Sep 7 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: David Shaw | last post by:
I am studying API programming using C++ and am seeking a away to pass data to a child program opened using CreateProcess. I would appreciate being told whether this is possible and where I can...
3
by: kman3048 | last post by:
Hello, as a relative newcomer to Python API programming I've got a problem: To extend Python: - there is an API C call to create a module - there is also a API C call to create a method -...
3
by: Jason | last post by:
Hi, I am new to windows api programming and I wanted to create a little utility program for myself in c using the mini gw compiler. I bought petzold's book, programming windows 5th edition. I...
0
by: pei_world | last post by:
I am doing a project with Access through a Bluetooth channel, anyone know how to programming with the Bluetooth? or any provided API that I can use? thanks in advance
3
by: Michael C | last post by:
MS API help is still geared towards C programmers only despite that fact that programmers from other languages have been using them for 10+ years now. When looking up an API it can be a real pain...
1
by: James | last post by:
I would like to get a user's first name and last name instead of just their username. According to this link, http://msdn.microsoft.com/library/default.asp?url=/library/en-...
0
by: Nishini | last post by:
I am using "FtpFindFirstFile" function of wininet.dll in my application. I had the Declare statement for this function in my code but when I executed my applicaiton, it gave me an error saying...
2
by: thangviet | last post by:
Hey guys, I have a function which needs to read a file and use the pointer parameter given. the pointer is a structure with five members; int points, float *time, *dhdt, *drate and *diff. The .dat...
5
by: rajatchhibber | last post by:
I am using GetModuleHandle in my function. That function gets called every time I do an operation. I want to know if that function gets called again and again, will the GetModuleHandle cause stack...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.