-
Notifications
You must be signed in to change notification settings - Fork 1
/
osspecific.h
226 lines (177 loc) · 6.88 KB
/
osspecific.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
// osspecific.h - Declaration of CVolumeApi, CRecycleBinApi, CPsapi, CMapi32Api
//
// WinDirStat - Directory Statistics
// Copyright (C) 2003-2004 Bernhard Seifert
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Author: bseifert@users.sourceforge.net, bseifert@daccord.net
//
// Last modified: $Date: 2005/04/17 12:27:21 $
// I try not to blow up such classes; they shall _only_ hide away the dynamic linking.
#pragma once
//
// CVolumeApi. Supported with Windows 2000 or higher.
//
class CVolumeApi
{
public:
CVolumeApi();
~CVolumeApi();
bool IsSupported();
BOOL GetVolumeNameForVolumeMountPoint(LPCTSTR lpszVolumeMountPoint, LPTSTR lpszVolumeName, DWORD cchBufferLength);
HANDLE FindFirstVolume(LPTSTR lpszVolumeName, DWORD cchBufferLength);
BOOL FindNextVolume(HANDLE hFindVolume, LPTSTR lpszVolumeName, DWORD cchBufferLength);
BOOL FindVolumeClose(HANDLE hFindVolume);
HANDLE FindFirstVolumeMountPoint(LPCTSTR lpszRootPathName, LPTSTR lpszVolumeMountPoint, DWORD cchBufferLength);
BOOL FindNextVolumeMountPoint(HANDLE hFindVolumeMountPoint, LPTSTR lpszVolumeMountPoint, DWORD cchBufferLength);
BOOL FindVolumeMountPointClose(HANDLE hFindVolumeMountPoint);
private:
typedef BOOL (WINAPI *TypeGetVolumeNameForVolumeMountPoint)(LPCTSTR lpszVolumeMountPoint, LPTSTR lpszVolumeName, DWORD cchBufferLength);
typedef HANDLE (WINAPI *TypeFindFirstVolume)(LPTSTR lpszVolumeName, DWORD cchBufferLength);
typedef BOOL (WINAPI *TypeFindNextVolume)(HANDLE hFindVolume, LPTSTR lpszVolumeName, DWORD cchBufferLength);
typedef BOOL (WINAPI *TypeFindVolumeClose)(HANDLE hFindVolume);
typedef HANDLE (WINAPI *TypeFindFirstVolumeMountPoint)(LPCTSTR lpszRootPathName, LPTSTR lpszVolumeMountPoint, DWORD cchBufferLength);
typedef BOOL (WINAPI *TypeFindNextVolumeMountPoint)(HANDLE hFindVolumeMountPoint, LPTSTR lpszVolumeMountPoint, DWORD cchBufferLength);
typedef BOOL (WINAPI *TypeFindVolumeMountPointClose)(HANDLE hFindVolumeMountPoint);
HMODULE m_dll;
bool m_UnloadDll;
TypeGetVolumeNameForVolumeMountPoint m_GetVolumeNameForVolumeMountPoint;
TypeFindFirstVolume m_FindFirstVolume;
TypeFindNextVolume m_FindNextVolume;
TypeFindVolumeClose m_FindVolumeClose;
TypeFindFirstVolumeMountPoint m_FindFirstVolumeMountPoint;
TypeFindNextVolumeMountPoint m_FindNextVolumeMountPoint;
TypeFindVolumeMountPointClose m_FindVolumeMountPointClose;
};
//
// CRecycleBinApi. Not always supported on NT and W95/98.
//
class CRecycleBinApi
{
public:
CRecycleBinApi();
~CRecycleBinApi();
bool IsSupported();
HRESULT SHEmptyRecycleBin(HWND hwnd, LPCTSTR pszRootPath, DWORD dwFlags);
HRESULT SHQueryRecycleBin(LPCTSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo);
private:
typedef HRESULT (STDAPICALLTYPE *TypeSHEmptyRecycleBin)(HWND hwnd, LPCTSTR pszRootPath, DWORD dwFlags);
typedef HRESULT (STDAPICALLTYPE *TypeSHQueryRecycleBin)(LPCTSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo);
HMODULE m_dll;
bool m_UnloadDll;
TypeSHEmptyRecycleBin m_SHEmptyRecycleBin;
TypeSHQueryRecycleBin m_SHQueryRecycleBin;
};
//
// CPsapi. Not Supported on W95/W98/me.
//
class CPsapi
{
public:
CPsapi();
~CPsapi();
bool IsSupported();
BOOL GetProcessMemoryInfo(HANDLE Process, PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb);
private:
typedef BOOL (WINAPI *TypeGetProcessMemoryInfo)(HANDLE Process, PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb);
HMODULE m_dll;
TypeGetProcessMemoryInfo m_GetProcessMemoryInfo;
};
//
// CMapi32Api. CDocument::OnFileSendMail() loads mapi32.dll dynamically.
// So we do, too.
//
class CMapi32Api
{
public:
CMapi32Api();
~CMapi32Api();
static bool IsDllPresent();
bool IsSupported();
ULONG MAPISendMail(LHANDLE lhSession, ULONG ulUIParam, lpMapiMessage lpMessage, FLAGS flFlags, ULONG ulReserved);
private:
typedef ULONG (FAR PASCAL *TypeMAPISendMail)(LHANDLE lhSession, ULONG ulUIParam, lpMapiMessage lpMessage, FLAGS flFlags, ULONG ulReserved);
HMODULE m_dll;
TypeMAPISendMail m_MAPISendMail;
};
//
// QueryDosDevice. Supported with W98 and higher.
//
class CQueryDosDeviceApi
{
public:
CQueryDosDeviceApi();
~CQueryDosDeviceApi();
bool IsSupported();
DWORD QueryDosDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax);
private:
typedef DWORD (WINAPI *TypeQueryDosDevice)(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax);
HMODULE m_dll;
bool m_UnloadDll;
TypeQueryDosDevice m_QueryDosDevice;
};
//
// GetCompressedFileSize. Only supported on the NT platform
//
class CGetCompressedFileSizeApi
{
public:
CGetCompressedFileSizeApi();
~CGetCompressedFileSizeApi();
bool IsSupported();
DWORD GetCompressedFileSize(LPCTSTR lpFileName, LPDWORD lpFileSizeHigh);
ULONGLONG GetCompressedFileSize(LPCTSTR lpFileName);
private:
typedef DWORD (WINAPI *TypeGetCompressedFileSize)(LPCTSTR lpFileName, LPDWORD lpFileSizeHigh);
HMODULE m_dll;
bool m_UnloadDll;
TypeGetCompressedFileSize m_GetCompressedFileSize;
};
//
// GetSecurityDescriptorOwner. Only supported on the NT platform
//
class CSecurityApi
{
public:
CSecurityApi();
~CSecurityApi();
bool IsSupported();
BOOL IsOwnedBy(LPCTSTR lpFileName, PSID lpSid);
BOOL IsOwnedBy(LPCTSTR lpFileName, CList<PSID> &sids);
private:
typedef BOOL (WINAPI *TypeGetFileSecurity)(LPCTSTR lpFileName, SECURITY_INFORMATION RequestedInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength, LPDWORD lpnLengthNeeded);
typedef BOOL (WINAPI *TypeGetSecurityDescriptorOwner)(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID* pOwner, LPBOOL lpbOwnerDefaulted);
typedef BOOL (WINAPI *TypeEqualSid)(PSID pSid1, PSID pSid2);
HMODULE m_dll;
bool m_UnloadDll;
TypeGetFileSecurity m_GetFileSecurity;
TypeGetSecurityDescriptorOwner m_GetSecurityDescriptorOwner;
TypeEqualSid m_EqualSid;
};
// $Log: osspecific.h,v $
// Revision 1.7 2005/04/17 12:27:21 assarbad
// - For details see changelog of 2005-04-17
//
// Revision 1.6 2004/11/28 14:40:06 assarbad
// - Extended CFileFindWDS to replace a global function
// - Now packing/unpacking the file attributes. This even spares a call to find encrypted/compressed files.
//
// Revision 1.5 2004/11/07 20:14:31 assarbad
// - Added wrapper for GetCompressedFileSize() so that by default the compressed file size will be shown.
//
// Revision 1.4 2004/11/05 16:53:07 assarbad
// Added Date and History tag where appropriate.
//