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