OSDN Git Service

import the last version of the original mayu extracted by following command:
[yamy/yamy.git] / mayuipc.h
1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 // mayuipc.h - mayu inter process communication
3
4 #ifndef _MAYUIPC_H
5 #  define _MAYUIPC_H
6
7 #  include <windows.h>
8
9 #  ifdef __cplusplus
10 extern "C" {
11 #  endif // __cplusplus
12
13 /// 
14 #  define WM_MayuIPC_NAME _T("MayuIPC{46269F4D-D560-40f9-B38B-DB5E280FEF47}")
15
16 enum MayuIPCCommand
17 {
18         // enable or disable Mayu
19         MayuIPCCommand_Enable = 1,
20 };
21
22 BOOL MayuIPC_PostMessage(MayuIPCCommand i_wParam, LPARAM i_lParam);
23 BOOL MayuIPC_Enable(BOOL i_isEnabled);
24
25 #  ifdef _MAYUIPC_H_DEFINE_FUNCTIONS
26
27 BOOL MayuIPC_PostMessage(MayuIPCCommand i_command, LPARAM i_lParam)
28 {
29         static UINT WM_MayuIPC;
30         HWND hwnd;
31         
32         if (WM_MayuIPC == 0)
33         {
34                 WM_MayuIPC = RegisterWindowMessage(WM_MayuIPC_NAME);
35                 if (WM_MayuIPC == 0)
36                 {
37                         return FALSE;
38                 }
39         }
40         
41         hwnd = FindWindow(_T("mayuTasktray"), NULL);
42         if (hwnd == NULL)
43         {
44                 return FALSE;
45         }
46         PostMessage(hwnd, WM_MayuIPC, i_command, i_lParam);
47         return TRUE;
48 }
49
50 BOOL MayuIPC_Enable(BOOL i_isEnabled)
51 {
52         return MayuIPC_PostMessage(MayuIPCCommand_Enable, i_isEnabled);
53 }
54
55 #  endif // _MAYUIPC_H_DEFINE_FUNCTIONS
56
57 #  ifdef __cplusplus
58 }
59 #  endif // __cplusplus
60 #endif // !_MAYUIPC_H