64,654
社区成员
发帖
与我相关
我的任务
分享
#include <stdlib.h>
#include "stdafx.h"
#include "org_csj_hotkey_Hotkey.h"
LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved){
return TRUE;
}
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_registerHotKey(JNIEnv *, jobject){
printf("进入\n");
RegisterHotKey(NULL,GlobalAddAtom("Ctrl+Alt+w"),MOD_CONTROL ¦MOD_ALT,'w');
}
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_unregisterHotKey(JNIEnv *, jobject){
printf("退出\n");
UnregisterHotKey(NULL,GlobalAddAtom("Ctrl+Alt+w"));
}
LRESULT CALLBACK WndProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message
parameter
LPARAM lParam) // second message parameter
{
printf("调用\n");
switch (uMsg){
case WM_CREATE:
// Initialize the window.
printf("dll输出:WM_CREATE\n");
return 0;
case WM_PAINT:
printf("dll输出:WM_PAINT\n");
// Paint the window's client area.
return 0;
case WM_SIZE:
// Set the size and position of the window.
printf("dll输出:WM_SIZE\n");
return 0;
case WM_HOTKEY: //处理WM_HOTKEY消息
printf("dll输出:d按了?\n");
return 0;
case WM_DESTROY:
printf("dll输出:WM_DESTROY\n");
// Clean up window-specific data objects.
return 0;
default:
// Process other messages.
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_registerHotKey(HWND hWnd,JNIEnv *, jobject)
{
printf("进入\n");
RegisterHotKey(hWnd,GlobalAddAtom("Ctrl+Alt+w"),MOD_CONTROL |MOD_ALT,'w');
}
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_unregisterHotKey(HWND hWnd,JNIEnv *, jobject)
{
printf("退出\n");
UnregisterHotKey(hWnd,GlobalAddAtom("Ctrl+Alt+w"));
}
// dllHotKey.cpp : Defines the entry point for the DLL application.
//
#include <stdlib.h>
#include "stdafx.h"
#include "org_csj_hotkey_Hotkey.h"
LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_registerHotKey(JNIEnv *, jobject)
{
printf("进入\n");
RegisterHotKey(NULL,GlobalAddAtom("Ctrl+Alt+w"),MOD_CONTROL |MOD_ALT,'w');
}
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_unregisterHotKey(JNIEnv *, jobject)
{
printf("退出\n");
UnregisterHotKey(NULL,GlobalAddAtom("Ctrl+Alt+w"));
}
LRESULT CALLBACK WndProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message
parameter
LPARAM lParam) // second message parameter
{
printf("调用\n");
switch (uMsg){
case WM_CREATE:
// Initialize the window.
printf("dll输出:WM_CREATE\n");
return 0;
case WM_PAINT:
printf("dll输出:WM_PAINT\n");
// Paint the window's client area.
return 0;
case WM_SIZE:
// Set the size and position of the window.
printf("dll输出:WM_SIZE\n");
return 0;
case WM_HOTKEY: //处理WM_HOTKEY消息
printf("dll输出:d按了?\n");
return 0;
case WM_DESTROY:
printf("dll输出:WM_DESTROY\n");
// Clean up window-specific data objects.
return 0;
case WM_HOTKEY:
if ( wParam == GlobalAddAtom("Ctrl+Alt+w") )
{
//...热键执行动作
}
default:
// Process other messages.
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
/* DO NOT EDIT THIS FILE - it is machine generated */
#include "jni.h"
/* Header for class org_csj_hotkey_Hotkey */
#ifndef _Included_org_csj_hotkey_Hotkey
#define _Included_org_csj_hotkey_Hotkey
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_csj_hotkey_Hotkey
* Method: registerHotKey
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_registerHotKey
(JNIEnv *, jobject);
/*
* Class: org_csj_hotkey_Hotkey
* Method: unregisterHotKey
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_unregisterHotKey
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif