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 ......
以前在VC里面建一个工程,都只用一个 .c 文件,昨天在一个工程里用了两个 .c文件了,遇到问题了,请大家指点。比如:
File1.c Fil ......
编译普通的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/../../. ......
6月5日消息,XX网站日前评出了10项大势已去的计算机技术。其中,有些技术已经被淘汰,有些即将被淘汰。如著名的Cobol语言,以及IBM的OS/2系统。
以下为XX网站评出的被淘汰的10项计算机技术:
......
'\108'作为字符常量对不对?
转义字符'\ddd'表示3位8进制所代表的字符。 但是108不是正确的8进制表示方法,因此应该是错误的。
但是char a='\108'; 为什么编译不出错呢?
\108 没超过 ......