#include "stdafx.h"
#include "abcde.h"#pragma comment(linker,"section:share,rws")
#pragma data_seg("share")
HINSTANCE hins=NULL;
HHOOK hook=NULL;
int ftime=1;
DWORD pid=0;
#pragma data_seg()LRESULT CALLBACK hookp(int ncode ,WPARAM wparam,LPARAM lparam);BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
//hins=(HINSTANCE)hModule;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
if(hook!=NULL)
ninstall();
break;
}
return TRUE;
}DLL void install()
{
pid=0;
HWND hWnd=NULL;
ftime=1;
hWnd = ::FindWindow(NULL,"Form1");
GetWindowThreadProcessId(hWnd,&pid); if(hook==NULL && pid>0)
{
MessageBox(NULL,"找到窗口","Yes",MB_OK);
hook=(HHOOK)::SetWindowsHookEx(WH_GETMESSAGE,hookp,0,pid);
if(hook!=NULL)
MessageBox(NULL,"挂钩成功","Yes",MB_OK);
else
MessageBox(NULL,"挂钩失败","Yes",MB_OK); }
}
DLL void ninstall()
{
ftime=0;
if(hook!=NULL)
::UnhookWindowsHookEx(hook);
}
LRESULT CALLBACK hookp(int ncode,WPARAM wparam,LPARAM lparam)
{
if(ftime)
{
ftime=0;
MessageBox(NULL,"抓到你了","Yes",MB_OK);
}
return ::CallNextHookEx(hook,ncode,wparam,lparam);
}我想把这个dll挂到一个 Form1的程序上
为什么挂不上去?
#include "abcde.h"#pragma comment(linker,"section:share,rws")
#pragma data_seg("share")
HINSTANCE hins=NULL;
HHOOK hook=NULL;
int ftime=1;
DWORD pid=0;
#pragma data_seg()LRESULT CALLBACK hookp(int ncode ,WPARAM wparam,LPARAM lparam);BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
//hins=(HINSTANCE)hModule;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
if(hook!=NULL)
ninstall();
break;
}
return TRUE;
}DLL void install()
{
pid=0;
HWND hWnd=NULL;
ftime=1;
hWnd = ::FindWindow(NULL,"Form1");
GetWindowThreadProcessId(hWnd,&pid); if(hook==NULL && pid>0)
{
MessageBox(NULL,"找到窗口","Yes",MB_OK);
hook=(HHOOK)::SetWindowsHookEx(WH_GETMESSAGE,hookp,0,pid);
if(hook!=NULL)
MessageBox(NULL,"挂钩成功","Yes",MB_OK);
else
MessageBox(NULL,"挂钩失败","Yes",MB_OK); }
}
DLL void ninstall()
{
ftime=0;
if(hook!=NULL)
::UnhookWindowsHookEx(hook);
}
LRESULT CALLBACK hookp(int ncode,WPARAM wparam,LPARAM lparam)
{
if(ftime)
{
ftime=0;
MessageBox(NULL,"抓到你了","Yes",MB_OK);
}
return ::CallNextHookEx(hook,ncode,wparam,lparam);
}我想把这个dll挂到一个 Form1的程序上
为什么挂不上去?
解决方案 »
- VC如何使用javascrip引擎
- "EnableWindow' : function does not take 2 parameters?
- WIN32 父子窗口输入问题
- 请教,我在ATL写的IE Bar插件中的ComboBox框无法下拉,而且也无法输入中文,这是什么原因?
- 请问切分窗口的问题?
- 求数据类型转换的问题
- VC编译COM组件的奇怪问题,高手帮忙,在线
- 关于激活Button的问题
- 请问如何获得窗口里编辑的文件?
- 怎样把多个字符串合并成一个字符串?
- List Control问题!定义了LV_ITEM lvitem,但lvitem却没有属性?
- 如何将图片中指定的颜色变为白色,其他的地方都变为黑色?(在线)
LPCTSTR lpClassName, // pointer to class name
LPCTSTR lpWindowName // pointer to window name
);
你把用SPY++找到VB窗体的ClassName,把ClassName加上,试一下.
还有你程序写得太难看了.