⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keydll.cpp

📁 visual c++ 实例编程
💻 CPP
字号:
// keydll.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "keydll.h"
//#include "resource.h"
HINSTANCE ghInstance=NULL;
#pragma data_seg("Shared")
HHOOK g_hook=NULL,m_hook=NULL;
	
//LRESULT CALLBACK	About(HWND, UINT, WPARAM, LPARAM);

#pragma data_seg()
#pragma comment(linker,"/section:Shared,rws")
LRESULT WINAPI KeyProc(int nCode,WPARAM wParam,LPARAM lParam)
{
HWND hwnd,hWnd;
	hWnd=::GetFocus();

//	HDC hdc;
	char str[255],strp[255];
	hwnd=::GetActiveWindow();
//	PROPENUMPROC prop;
   ::GetWindowText(hwnd,strp,255);
 //   hdc=::GetWindowDC(hwnd);
	//::SetBkColor(hdc,RGB(192,192,192));
//	::TextOut(hdc,5,5,strp,strlen(strp));
	
	if((::GetKeyState(VK_F9)<0)&&(wParam==WM_LBUTTONDOWN))
	{   
	//::PostQuitMessage(WM_CLOSE);
   ::DestroyWindow(hwnd);
//	DialogBox(ghInstance,(LPCTSTR)IDD_ABOUTBOX,hwnd,(DLGPROC)About);
	::SystemParametersInfo(SPI_SCREENSAVERRUNNING,FALSE,0,0);	
  ::ClipCursor(NULL);
	}
    	if((::GetKeyState(VK_F8)<0)&&(wParam==WM_LBUTTONDOWN))
	{   
	//::PostQuitMessage(WM_CLOSE);
		
//	DialogBox(ghInstance,(LPCTSTR)IDD_ABOUTBOX,hwnd,(DLGPROC)About);
		
			::SendMessage(hWnd,EM_SETPASSWORDCHAR,0,0);
			::GetWindowText(hWnd,str,255);
		    ::MessageBox(hWnd,str,"输入密码:",MB_OK|MB_ICONINFORMATION);
		
	}
	
	
		
	return FALSE;
} 
BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
			ghInstance=(HINSTANCE)hModule;
			break;
		case DLL_THREAD_ATTACH:
		case DLL_THREAD_DETACH:
		case DLL_PROCESS_DETACH:
			break;
    }
    return TRUE;
}
BOOL WINAPI Start()
{
//	::SystemParametersInfo(SPI_SCREENSAVERRUNNING,TRUE,0,0);
	if(g_hook!=NULL)
return FALSE;
	g_hook=::SetWindowsHookEx(WH_MOUSE,KeyProc,ghInstance,0);
  //  m_hook=::SetWindowsHookEx(WH_MOUSE,KeyProc,ghInstance,0);
	return g_hook!=NULL;
}
void WINAPI Stop()
{
::SystemParametersInfo(SPI_SCREENSAVERRUNNING,FALSE,0,0);
		::UnhookWindowsHookEx(g_hook);
//	 ::UnhookWindowsHookEx(m_hook);
}
// This is an example of an exported variable
KEYDLL_API int nKeydll=0;

// This is an example of an exported function.
KEYDLL_API int fnKeydll(void)
{
	return 42;
}

// This is the constructor of a class that has been exported.
// see keydll.h for the class definition
CKeydll::CKeydll()
{ 
	return; 
}
/*LRESULT CALLBACK	About(HWND hDlg, UINT message, WPARAM wParam, LPARAM  lParam)
{BOOL a=TRUE;
//LONG lStyle;
char pass[255];
	switch (message)
	{
		case WM_INITDIALOG:
			::GetWindowText(hwnd,pass,255);
			::SetWindowText(::GetDlgItem(hDlg,IDC_EDIT1),pass);
        return TRUE;

		case WM_COMMAND:
			if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
			{
				EndDialog(hDlg, LOWORD(wParam));
				return TRUE;
			}
			break;
	}
    return FALSE;

}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -