1
1
#include " framework.h"
2
2
#include " MateBook-E-Pen.h"
3
3
4
- #define version " 2.1.0 "
5
- #define dev_mode false
4
+ #define version " 2.1.1 "
5
+ #define dev_mode true
6
6
7
7
// ///////////////////////////////////////////
8
8
// /////////////// /////////////////
@@ -22,9 +22,25 @@ void init(HWND hWnd)
22
22
hDll_PenService = LoadLibrary (L" C:\\ Program Files\\ Huawei\\ PCManager\\ components\\ accessories_center\\ accessories_app\\ AccessoryApp\\ Lib\\ Plugins\\ Depend\\ PenService.dll" );
23
23
if (hDll_PenService == NULL )
24
24
{
25
- MessageBox (hWnd, L" 请检查华为电脑管家和手写笔相关驱动是否正确安装!" , L" 出错啦!" , MB_OK);
26
- SendMessage (hWnd, WM_CLOSE, 0 , 0 );
27
- return ;
25
+ HRSRC hRes = FindResource (hInst, MAKEINTRESOURCE (IDR_DLL1), L" DLL" );
26
+ DWORD dwSize = SizeofResource (hInst, hRes);
27
+ HGLOBAL hGlob = LoadResource (hInst, hRes);
28
+ void * pRes = LockResource (hGlob);
29
+ wchar_t szPath[MAX_PATH];
30
+ GetTempPath (MAX_PATH, szPath);
31
+ wcscat_s (szPath, L" PenService.dll" );
32
+ HANDLE hFile = CreateFile (szPath, GENERIC_WRITE, 0 , NULL , CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
33
+ DWORD dwWrite;
34
+ WriteFile (hFile, pRes, dwSize, &dwWrite, NULL );
35
+ CloseHandle (hFile);
36
+ FreeResource (hGlob);
37
+ hDll_PenService = LoadLibrary (szPath);
38
+
39
+ if (hDll_PenService == NULL )
40
+ {
41
+ SendMessage (hWnd, WM_CLOSE, 0 , 0 );
42
+ return ;
43
+ }
28
44
}
29
45
}
30
46
CommandSendSetPenKeyFunc = (int2void)GetProcAddress (hDll_PenService, " CommandSendSetPenKeyFunc" );
@@ -125,13 +141,13 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
125
141
HWND handle = FindWindow (NULL , szTitle);
126
142
if (handle != NULL )
127
143
{
128
- DialogBox (hInst , MAKEINTRESOURCE (IDD_OPENED), NULL , show_error);
144
+ DialogBox (hInstance , MAKEINTRESOURCE (IDD_OPENED), NULL , show_error);
129
145
return 0 ;
130
146
}
131
147
132
148
MyRegisterClass (hInstance);
133
149
134
- if (!InitInstance (hInstance, nCmdShow)) return FALSE ;
150
+ if (!InitInstance (hInstance, nCmdShow)) return FALSE ;
135
151
136
152
HACCEL hAccelTable = LoadAccelerators (hInstance, MAKEINTRESOURCE (IDC_MATEBOOKEPEN));
137
153
0 commit comments