请问一个问题:
我在dll中创建 一个全局共享变量。a ,dllmain函数中 先 messagebox (a的值 然后在赋予a=111exe1 加载的 时候 提示 messagebox a=0
然后我exe2 也加载这个dll 为什么也提示 messagebox a=0
哪里错误了
这有个小程序
/////////////exe,cpp
#include "windows.h"int main()
{
HMODULE h=NULL;
h=LoadLibrary("dll.DLL");
InstHOOK insthook;
while(1)
{
Sleep(100);
}
return 0;
}
// dll.cpp : Defines the entry point for the DLL application.
//#include "stdafx.h"
#include "stdio.h"
#pragma data_seg ("ashared")
DWORD aa=2;
#pragma data_seg ()
#pragma comment(linker,"section:ashared,rws")
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
char ssw[22];
memset(ssw,0,sizeof(ssw));
sprintf(ssw,"aa : %d",aa);
MessageBox(NULL,ssw,NULL,MB_OK);
aa=1111;
return TRUE;
}为什么 全局变量没有变化? 第一次调用以后 第二次调用应该发生变化啊!
我在dll中创建 一个全局共享变量。a ,dllmain函数中 先 messagebox (a的值 然后在赋予a=111exe1 加载的 时候 提示 messagebox a=0
然后我exe2 也加载这个dll 为什么也提示 messagebox a=0
哪里错误了
这有个小程序
/////////////exe,cpp
#include "windows.h"int main()
{
HMODULE h=NULL;
h=LoadLibrary("dll.DLL");
InstHOOK insthook;
while(1)
{
Sleep(100);
}
return 0;
}
// dll.cpp : Defines the entry point for the DLL application.
//#include "stdafx.h"
#include "stdio.h"
#pragma data_seg ("ashared")
DWORD aa=2;
#pragma data_seg ()
#pragma comment(linker,"section:ashared,rws")
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
char ssw[22];
memset(ssw,0,sizeof(ssw));
sprintf(ssw,"aa : %d",aa);
MessageBox(NULL,ssw,NULL,MB_OK);
aa=1111;
return TRUE;
}为什么 全局变量没有变化? 第一次调用以后 第二次调用应该发生变化啊!
#pragma comment(linker,"/section:ashared,rws")