//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
//先加载DLL
//
//然后找到函数并且换皮肤
//
//////////////////////////////////////
#define IDI_WIN32 107
#define IDI_SMALL 108
#define IDC_WIN32 109
#pragma comment(linker, "/subsystem:windows")
#include<windows.h>
#include <windef.h>
#include <stdlib.h>
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
////添加的
HWND hEdit;
HWND hEdit2;
HWND hEdit3;
HWND hBtn;
HWND hBtn2;
HMODULE hMod = LoadLibrary("skinH.dll");//当前路径下的skinH.dll
//ApiAdd myfun=0;
//myfun = (ApiAdd)GetProcAddress(hMod,"SkinH_AttachEx");
typedef int (__stdcall *FUNA)(LPCTSTR,LPCTSTR);//dll函数中的类型
bool captureCursor=false;
//
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
// HACCEL hAccelTable;
//自己写
POINT p;
POINT tp;
char str1[25];
char str2[25];
//
// Initialize global strings
//LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
//LoadString(hInstance, IDC_WIN32, Class, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
//hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_WIN32);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
//if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
// {
TranslateMessage(&msg);
DispatchMessage(&msg);
// }
tp=p;
GetCursorPos(&p);
if (captureCursor&&( tp.x!=p.x || tp.y!=p.y)){
itoa(p.x,str1,10);
itoa(p.y,str2,10);
SetWindowText(hEdit2,str1);
SetWindowText(hEdit3,str2);
}
}
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_WIN32);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName =(LPCSTR)IDC_WIN32;
wcex.lpszClassName = "WIN32";
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow("WIN32", "win32", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, 600, 400, NULL, NULL, hInstance, NULL);
hBtn = CreateWindow(TEXT("BUTTON"), TEXT("捕捉鼠标位置"), WS_CHILD|WS_VISIBLE, 200, 250, 100, 40, hWnd, NULL, NULL, NULL);
hBtn2 = CreateWindow(TEXT("BUTTON"), TEXT("按钮2"), WS_CHILD|WS_VISIBLE, 300, 250, 100, 40, hWnd, NULL, NULL, NULL);
hEdit = CreateWindow(TEXT("EDIT"), TEXT("text1"), WS_CHILD|WS_VISIBLE|WS_BORDER, 200, 150, 100, 40, hWnd, NULL, NULL, NULL);
hEdit2 = CreateWindow(TEXT("EDIT"), TEXT(""), WS_CHILD|WS_VISIBLE|WS_BORDER, 50, 50, 45, 30, hWnd, NULL, NULL, NULL);
hEdit3 = CreateWindow(TEXT("EDIT"), TEXT(""), WS_CHILD|WS_VISIBLE|WS_BORDER, 100, 50, 45, 30, hWnd, NULL, NULL, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//找到函数并且换皮肤
if (hMod){
FUNA SkinH_AttachEx = (FUNA)GetProcAddress(hMod, TEXT("SkinH_AttachEx"));
if (SkinH_AttachEx != NULL)
{
SkinH_AttachEx("real.she",NULL);
}
else
{
MessageBox(0,"ERROR on GetProcAddress","ERROR",0);
}
}else
MessageBox(0,"ERROR on LoadLibrary","ERROR",0);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
char str1[10]="abcdef";
char str2[25];
char str3[25];
char str4[100];
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
// LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
//SetWindowText(hWnd,str1);
itoa(lParam,str2,10);
itoa((int)hBtn ,str3,10);
//MessageBox(NULL, str2,str3,1);
// MessageBox(NULL, str2,str3,1);
switch (wmId)
{
//case IDM_ABOUT:
// DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
// break;
// case IDM_EXIT:
// DestroyWindow(hWnd);
// break;
default:
if ((int)lParam==(int)hBtn){
SetWindowText(hEdit,"设置字符串");
captureCursor=!captureCursor;
//MessageBox(NULL, str4,"输入的内容为",1);
break;
}
if ((int)lParam==(int)hBtn2){
GetWindowText(hEdit,str4,100);
MessageBox(NULL, str4,"输入的内容为",1);
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
//DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
//DrawText(hdc, str1, strlen(str1), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_QUIT:
if (hMod) FreeLibrary(hMod);
break;
case WM_DESTROY:
//if (hMod) FreeLibrary(hMod);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}