extern "C" const ÎÊÌâ
³õѧWINDOWS API
extern "C" const IMAGE_DOS_HEADER __ImageBase;
void DumpModule(){
HMODULE hModule = GetModuleHandle(Null);
_tprintf(TEXT("with GetModuleHandle(NULL)= 0x%x\r\n"),hModule);
_tprintf(TEXT("with __ImageBase= 0x%x\r\n"),(HINSTANCE)&__ImageBase);
}
int main(int argc, char* argv[])
{
DumpModule();
return 0;
}
Àý×Ó±àÒë³ö´í£¬µÚÒ»¾ä¾ÍÓÐÎÊÌ⣬²»Ã÷°×Ϊʲô£¿£¿
C/C++ code:
#include<windows.h>
#include<tchar.h>
#include<stdio.h>
extern "C" const IMAGE_DOS_HEADER __ImageBase;
void DumpModule()
{
HMODULE hModule = GetModuleHandle( NULL );
_tprintf( TEXT( "with GetModuleHandle(NULL)= 0x%x\r\n" ),hModule );
_tprintf( TEXT( "with __ImageBase= 0x%x\r\n" ),( HINSTANCE )&__ImageBase );
}
int main( int argc, char* argv[] )
{
DumpModule();
return 0;
}
If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process (.exe file).
¸øGetModuleHandle£¨£©´«µÝnull »ñÈ¡calling processµÄ¾ä±úÊÇÄãµÄ±¾ÒâÂð Äã˵µÄ³ö´íÊÇÕâ¾äÂð£¿
__ImageBaseÔÚÄ͍ÒåµÄ
C/C++ code
Code
Ïà¹ØÎÊ´ð£º
#include <string.h>
#include <stdio.h>
void main()
{
int i;
char buf[]="abcde";
strncpy(buf,"abc",3);
for(i=0;i <5;i++)
printf(&q ......
±àÒëÆÕͨµÄcûÎÊÌâ°¡£¬µ«±àÒëjavahÉú³ÉµÄ¾Í±¨´í£º
gcc -O0 -g3 -Wall -c -fmessage-length=0 -oHelloWorld.o ..\HelloWorld.c
gcc -otest.exe HelloWorld.o
d:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../. ......
µØµãÔÚÉîÛÚÄÏɽ
¡¡¡¡×öCÈí¼þ¡£ÊÔÓÃ2K£¬²»ÖªµÀתÕý¸ø¹«Ë¾Ì¸¶àÉÙºÏÊʰ¡£¿
¡¡¡¡ÁíÍ⣬±¾ÈËС±¾£¬Ó¢ÓïÁù¼¶£¬ÊÔÓÃÈý¸öÔ±íÏÖµÃÒ²ËãÖÐÉÏˮƽ¡£µ«ÊÇÏÖÔÚ»¹²»ÄÜ×öÏîÄ¿¡£ÁíÍâ±ÏҵѧУûÓÐÃûÆø¡£
¡¡¡¡×ªÕý¸ø¹«Ë¾Ì¸¶àÉ ......
ÏÖÔÚÌ·ºÆÇ¿µÄCÓïÑÔÒѾ¿ìѧÍüÁË£¬µ«¶¼ÊǺܻù´¡µÄ¶«Î÷¸Ð¾õ£¬²»ÄܸÉʲô£¬ÒªÏëÔÙÌáÉý½ÓÏÂÀ´¸ÉµãɶºÃ
ÕÒ±¾¡¶Cר¼Ò±à³Ì¡·¿´¿´¡£ÄDZ¾ÊéÀïµÄ¶«Î÷²ÅÕæÕý½Ð»ù´¡¡£
¶¯ÊÖ
ѧÊý¾Ý½á¹¹
²¢±à³ÌʵÏÖ
Ì ......
VC ++ 6.0 visual studio 2003 ÓëC ++ ÓÐÊ²Ã´Çø±ð <ѧVC֮ǰһ¶¨ÒªÑ§C++Âð£¿
²»¹ýÎÒÂòµÄÊ鶼ЩºÚ¿Í±à³ÌµÄ,ºÜÉÙÌáµ½MFCµÄ,ÊéÉϵÄÔ´ÂëÄ ......