Rev 235 | Rev 268 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 235 | Rev 259 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | This file is part of a common library |
2 | This file is part of a common library |
3 | Copyright (C) 2002-6 Toby Thain, toby@telegraphics.com.au |
3 | Copyright (C) 2002-6 Toby Thain, toby@telegraphics.com.au |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, |
10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. |
13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License |
15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software |
16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | */ |
18 | */ |
19 | 19 | ||
20 | #include <windows.h> |
20 | #include <windows.h> |
21 | 21 | ||
22 | #include "compat_win.h" |
22 | #include "compat_win.h" |
23 | 23 | ||
24 | Boolean isWin32NT(void){ |
24 | Boolean isWin32NT(void){ |
25 | OSVERSIONINFO osv; |
25 | OSVERSIONINFO osv; |
26 | 26 | ||
27 | osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
27 | osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
28 | #pragma warning(suppress : 4996 28159) |
28 | #pragma warning(suppress : 4996 28159) |
29 | return GetVersionEx(&osv) && osv.dwPlatformId == VER_PLATFORM_WIN32_NT; |
29 | return GetVersionEx(&osv) && osv.dwPlatformId == VER_PLATFORM_WIN32_NT; |
30 | } |
30 | } |
31 | 31 | ||
32 | // --------------------------------- |
32 | // --------------------------------- |
33 | 33 | ||
34 | typedef ULONGLONG(__stdcall* f_GetTickCount64)(); |
34 | typedef ULONGLONG(__stdcall* f_GetTickCount64)(); |
35 | ULONGLONG _GetTickCount64() { |
35 | ULONGLONG _GetTickCount64() { |
36 | HMODULE hLib; |
36 | HMODULE hLib; |
37 | f_GetTickCount64 fGetTickCount64; |
37 | f_GetTickCount64 fGetTickCount64; |
38 | ULONGLONG res; |
38 | ULONGLONG res; |
39 | 39 | ||
40 | hLib = LoadLibraryA("KERNEL32.DLL"); |
40 | hLib = LoadLibraryA("KERNEL32.DLL"); |
41 | if (!hLib) return 0; |
41 | if (!hLib) return 0; |
42 | fGetTickCount64 = (f_GetTickCount64)(void*)GetProcAddress(hLib, "GetTickCount64"); |
42 | fGetTickCount64 = (f_GetTickCount64)(void*)GetProcAddress(hLib, "GetTickCount64"); |
43 | if (fGetTickCount64 != 0) { |
43 | if (fGetTickCount64 != 0) { |
44 | res = fGetTickCount64(); |
44 | res = fGetTickCount64(); |
45 | FreeLibrary(hLib); |
45 | FreeLibrary(hLib); |
46 | } else { |
46 | } else { |
47 | #pragma warning(suppress : 28159) |
47 | #pragma warning(suppress : 28159) |
48 | res = (ULONGLONG)GetTickCount(); |
48 | res = (ULONGLONG)GetTickCount(); |
49 | } |
49 | } |
50 | 50 | ||
51 | return res; |
51 | return res; |
52 | } |
52 | } |
53 | 53 | ||
54 | typedef HANDLE(__stdcall *f_BeginUpdateResourceA)( |
54 | typedef HANDLE(__stdcall *f_BeginUpdateResourceA)( |
55 | LPCSTR pFileName, |
55 | LPCSTR pFileName, |
56 | BOOL bDeleteExistingResources |
56 | BOOL bDeleteExistingResources |
57 | ); |
57 | ); |
58 | HANDLE _BeginUpdateResource/*A*/( |
58 | HANDLE _BeginUpdateResource/*A*/( |
59 | LPCSTR pFileName, |
59 | LPCSTR pFileName, |
60 | BOOL bDeleteExistingResources |
60 | BOOL bDeleteExistingResources |
61 | ) { |
61 | ) { |
62 | HMODULE hLib; |
62 | HMODULE hLib; |
63 | f_BeginUpdateResourceA fBeginUpdateResourceA; |
63 | f_BeginUpdateResourceA fBeginUpdateResourceA; |
64 | HANDLE res; |
64 | HANDLE res; |
65 | 65 | ||
66 | hLib = LoadLibraryA(isWin32NT() ? "KERNEL32.DLL" : "UNICOWS.DLL"); |
66 | hLib = LoadLibraryA(isWin32NT() ? "KERNEL32.DLL" : "UNICOWS.DLL"); |
67 | if (!hLib) return 0; |
67 | if (!hLib) return 0; |
68 | fBeginUpdateResourceA = (f_BeginUpdateResourceA)(void*)GetProcAddress(hLib, "BeginUpdateResourceA"); |
68 | fBeginUpdateResourceA = (f_BeginUpdateResourceA)(void*)GetProcAddress(hLib, "BeginUpdateResourceA"); |
69 | res = fBeginUpdateResourceA(pFileName, bDeleteExistingResources); |
69 | res = fBeginUpdateResourceA(pFileName, bDeleteExistingResources); |
70 | FreeLibrary(hLib); |
70 | FreeLibrary(hLib); |
71 | 71 | ||
72 | return res; |
72 | return res; |
73 | } |
73 | } |
74 | 74 | ||
75 | // --------------------------------- |
75 | // --------------------------------- |
76 | 76 | ||
77 | typedef BOOL(__stdcall *f_EndUpdateResourceA)( |
77 | typedef BOOL(__stdcall *f_EndUpdateResourceA)( |
78 | HANDLE hUpdate, |
78 | HANDLE hUpdate, |
79 | BOOL fDiscard |
79 | BOOL fDiscard |
80 | ); |
80 | ); |
81 | 81 | ||
82 | BOOL _EndUpdateResource/*A*/( |
82 | BOOL _EndUpdateResource/*A*/( |
83 | HANDLE hUpdate, |
83 | HANDLE hUpdate, |
84 | BOOL fDiscard |
84 | BOOL fDiscard |
85 | ) { |
85 | ) { |
86 | HMODULE hLib; |
86 | HMODULE hLib; |
87 | f_EndUpdateResourceA fEndUpdateResourceA; |
87 | f_EndUpdateResourceA fEndUpdateResourceA; |
88 | BOOL res; |
88 | BOOL res; |
89 | 89 | ||
90 | hLib = LoadLibraryA(isWin32NT() ? "KERNEL32.DLL" : "UNICOWS.DLL"); |
90 | hLib = LoadLibraryA(isWin32NT() ? "KERNEL32.DLL" : "UNICOWS.DLL"); |
91 | if (!hLib) return 0; |
91 | if (!hLib) return 0; |
92 | fEndUpdateResourceA = (f_EndUpdateResourceA)(void*)GetProcAddress(hLib, "EndUpdateResourceA"); |
92 | fEndUpdateResourceA = (f_EndUpdateResourceA)(void*)GetProcAddress(hLib, "EndUpdateResourceA"); |
93 | res = fEndUpdateResourceA(hUpdate, fDiscard); |
93 | res = fEndUpdateResourceA(hUpdate, fDiscard); |
94 | FreeLibrary(hLib); |
94 | FreeLibrary(hLib); |
95 | 95 | ||
96 | return res; |
96 | return res; |
97 | } |
97 | } |
98 | 98 | ||
99 | // --------------------------------- |
99 | // --------------------------------- |
100 | 100 | ||
101 | typedef BOOL(__stdcall *f_UpdateResourceA)( |
101 | typedef BOOL(__stdcall *f_UpdateResourceA)( |
102 | HANDLE hUpdate, |
102 | HANDLE hUpdate, |
103 | LPCSTR lpType, |
103 | LPCSTR lpType, |
104 | LPCSTR lpName, |
104 | LPCSTR lpName, |
105 | WORD wLanguage, |
105 | WORD wLanguage, |
106 | LPVOID lpData, |
106 | LPVOID lpData, |
107 | DWORD cb |
107 | DWORD cb |
108 | ); |
108 | ); |
109 | BOOL _UpdateResource/*A*/( |
109 | BOOL _UpdateResource/*A*/( |
110 | HANDLE hUpdate, |
110 | HANDLE hUpdate, |
111 | LPCSTR lpType, |
111 | LPCSTR lpType, |
112 | LPCSTR lpName, |
112 | LPCSTR lpName, |
113 | WORD wLanguage, |
113 | WORD wLanguage, |
114 | LPVOID lpData, |
114 | LPVOID lpData, |
115 | DWORD cb |
115 | DWORD cb |
116 | ) { |
116 | ) { |
117 | HMODULE hLib; |
117 | HMODULE hLib; |
118 | f_UpdateResourceA fUpdateResourceA; |
118 | f_UpdateResourceA fUpdateResourceA; |
119 | BOOL res; |
119 | BOOL res; |
120 | 120 | ||
121 | hLib = LoadLibraryA(isWin32NT() ? "KERNEL32.DLL" : "UNICOWS.DLL"); |
121 | hLib = LoadLibraryA(isWin32NT() ? "KERNEL32.DLL" : "UNICOWS.DLL"); |
122 | if (!hLib) return 0; |
122 | if (!hLib) return 0; |
123 | fUpdateResourceA = (f_UpdateResourceA)(void*)GetProcAddress(hLib, "UpdateResourceA"); |
123 | fUpdateResourceA = (f_UpdateResourceA)(void*)GetProcAddress(hLib, "UpdateResourceA"); |
124 | res = fUpdateResourceA(hUpdate, lpType, lpName, wLanguage, lpData, cb); |
124 | res = fUpdateResourceA(hUpdate, lpType, lpName, wLanguage, lpData, cb); |
125 | FreeLibrary(hLib); |
125 | FreeLibrary(hLib); |
126 | 126 | ||
127 | return res; |
127 | return res; |
128 | } |
128 | } |