用Visual C++实现屏幕抓程序(3)
二、编程步骤
1、 启动Visual C++,生成一个DLL项目和一个基于对话框的应用程序项目,并将两个项目分别命名为"Hook"和"Capture";
2、 在"Hook"项目中导出AddHotkey()、DeleteHotkey()函数;
3、 在"Capture"项目中按照图一所示设置对话框的界面,具体设置参见代码部分;
4、 使用Class Wizard在"Capture"项目中添加按钮的鼠标单击消息响应函数,并重载对话框的WindowProc()函数;
5、 添加代码,编译运行程序。
三、程序代码
/////////////////////// Hook.h : main header file for the HOOK DLL
#if !defined(AFX_HOOK_H__AEBFF705_C93A_11D5_B7D6_0080C82BE86B__INCLUDED_)
#define AFX_HOOK_H__AEBFF705_C93A_11D5_B7D6_0080C82BE86B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include ’stdafx.h’ before including this file for PCH
#endif
#include "resource.h" // main symbols
class CHookApp : public CWinApp
{
public:
CHookApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHookApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL
//{{AFX_MSG(CHookApp)
// 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()
};
LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam, LPARAM lParam);
BOOL __declspec(dllexport)__stdcall AddHotkey(HWND,UCHAR key,UCHAR mask);
BOOL __declspec(dllexport)__stdcall DeleteHotkey(HWND,UCHAR key,UCHAR mask);
BOOL InitHotkey();
BOOL UnInit();
#endif
//////////////////////////////////////// Hook.cpp : Defines the initialization routines for the DLL.
#include "stdafx.h"
#include "hook.h"
#include
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
- 上一篇:VC++中实现以复杂线条为基础的图形绘图
- 下一篇:通过例程分析状态条用法