1
{******************************************************************************}
3
{ Disk Quota's API interface Unit for Object Pascal }
5
{ Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
6
{ Corporation. All Rights Reserved. }
8
{ The original file is: dskquota.h, released June 2000. The original Pascal }
9
{ code is: DskQuota.pas, released December 2000. The initial developer of the }
10
{ Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
12
{ Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
13
{ Marcel van Brakel. All Rights Reserved. }
15
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
17
{ You may retrieve the latest version of this file at the Project JEDI }
18
{ APILIB home page, located at http://jedi-apilib.sourceforge.net }
20
{ The contents of this file are used with permission, subject to the Mozilla }
21
{ Public License Version 1.1 (the "License"); you may not use this file except }
22
{ in compliance with the License. You may obtain a copy of the License at }
23
{ http://www.mozilla.org/MPL/MPL-1.1.html }
25
{ Software distributed under the License is distributed on an "AS IS" basis, }
26
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
27
{ the specific language governing rights and limitations under the License. }
29
{ Alternatively, the contents of this file may be used under the terms of the }
30
{ GNU Lesser General Public License (the "LGPL License"), in which case the }
31
{ provisions of the LGPL License are applicable instead of those above. }
32
{ If you wish to allow use of your version of this file only under the terms }
33
{ of the LGPL License and not to allow others to use your version of this file }
34
{ under the MPL, indicate your decision by deleting the provisions above and }
35
{ replace them with the notice and other provisions required by the LGPL }
36
{ License. If you do not delete the provisions above, a recipient may use }
37
{ your version of this file under either the MPL or the LGPL License. }
39
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
41
{******************************************************************************}
43
// $Id: JwaDskQuota.pas,v 1.7 2005/09/03 13:12:10 marquardt Exp $
54
JwaActiveX, JwaWindows;
57
{$HPPEMIT '#include "DskQuota.h"'}
65
// {7988B571-EC89-11cf-9C00-00AA00A14F56}
67
CLSID_DiskQuotaControl: TGUID = (
68
D1:$7988b571; D2:$ec89; D3:$11cf; D4:($9c, $0, $0, $aa, $0, $a1, $4f, $56));
69
{$EXTERNALSYM CLSID_DiskQuotaControl}
74
// {7988B572-EC89-11cf-9C00-00AA00A14F56}
76
IID_IDiskQuotaControl: TGUID = (
77
D1:$7988b572; D2:$ec89; D3:$11cf; D4:($9c, $0, $0, $aa, $0, $a1, $4f, $56));
78
{$EXTERNALSYM IID_IDiskQuotaControl}
80
// {7988B574-EC89-11cf-9C00-00AA00A14F56}
82
IID_IDiskQuotaUser: TGUID = (
83
D1:$7988b574; D2:$ec89; D3:$11cf; D4:($9c, $0, $0, $aa, $0, $a1, $4f, $56));
84
{$EXTERNALSYM IID_IDiskQuotaUser}
86
// {7988B576-EC89-11cf-9C00-00AA00A14F56}
88
IID_IDiskQuotaUserBatch: TGUID = (
89
D1:$7988b576; D2:$ec89; D3:$11cf; D4:($9c, $0, $0, $aa, $0, $a1, $4f, $56));
90
{$EXTERNALSYM IID_IDiskQuotaUserBatch}
92
// {7988B577-EC89-11cf-9C00-00AA00A14F56}
94
IID_IEnumDiskQuotaUsers: TGUID = (
95
D1:$7988b577; D2:$ec89; D3:$11cf; D4:($9c, $0, $0, $aa, $0, $a1, $4f, $56));
96
{$EXTERNALSYM IID_IEnumDiskQuotaUsers}
98
// {7988B579-EC89-11cf-9C00-00AA00A14F56}
100
IID_IDiskQuotaEvents: TGUID = (
101
D1:$7988b579; D2:$ec89; D3:$11cf; D4:($9c, $0, $0, $aa, $0, $a1, $4f, $56));
102
{$EXTERNALSYM IID_IDiskQuotaEvents}
105
// Definitions for value and bits in DWORD returned by
106
// IDiskQuotaControl::GetQuotaState.
109
DISKQUOTA_STATE_DISABLED = $00000000;
110
{$EXTERNALSYM DISKQUOTA_STATE_DISABLED}
111
DISKQUOTA_STATE_TRACK = $00000001;
112
{$EXTERNALSYM DISKQUOTA_STATE_TRACK}
113
DISKQUOTA_STATE_ENFORCE = $00000002;
114
{$EXTERNALSYM DISKQUOTA_STATE_ENFORCE}
115
DISKQUOTA_STATE_MASK = $00000003;
116
{$EXTERNALSYM DISKQUOTA_STATE_MASK}
117
DISKQUOTA_FILESTATE_INCOMPLETE = $00000100;
118
{$EXTERNALSYM DISKQUOTA_FILESTATE_INCOMPLETE}
119
DISKQUOTA_FILESTATE_REBUILDING = $00000200;
120
{$EXTERNALSYM DISKQUOTA_FILESTATE_REBUILDING}
121
DISKQUOTA_FILESTATE_MASK = $00000300;
122
{$EXTERNALSYM DISKQUOTA_FILESTATE_MASK}
125
// Helper macros for setting and testing state value.
128
function DISKQUOTA_SET_DISABLED(var s: DWORD): DWORD;
129
{$EXTERNALSYM DISKQUOTA_SET_DISABLED}
130
function DISKQUOTA_SET_TRACKED(var s: DWORD): DWORD;
131
{$EXTERNALSYM DISKQUOTA_SET_TRACKED}
132
function DISKQUOTA_SET_ENFORCED(var s: DWORD): DWORD;
133
{$EXTERNALSYM DISKQUOTA_SET_ENFORCED}
134
function DISKQUOTA_IS_DISABLED(s: DWORD): BOOL;
135
{$EXTERNALSYM DISKQUOTA_IS_DISABLED}
136
function DISKQUOTA_IS_TRACKED(s: DWORD): BOOL;
137
{$EXTERNALSYM DISKQUOTA_IS_TRACKED}
138
function DISKQUOTA_IS_ENFORCED(s: DWORD): BOOL;
139
{$EXTERNALSYM DISKQUOTA_IS_ENFORCED}
142
// These file state flags are read-only.
145
function DISKQUOTA_FILE_INCOMPLETE(s: DWORD): BOOL;
146
{$EXTERNALSYM DISKQUOTA_FILE_INCOMPLETE}
147
function DISKQUOTA_FILE_REBUILDING(s: DWORD): BOOL;
148
{$EXTERNALSYM DISKQUOTA_FILE_REBUILDING}
151
// Definitions for bits in DWORD returned by
152
// IDiskQuotaControl::GetQuotaLogFlags.
156
DISKQUOTA_LOGFLAG_USER_THRESHOLD = $00000001;
157
{$EXTERNALSYM DISKQUOTA_LOGFLAG_USER_THRESHOLD}
158
DISKQUOTA_LOGFLAG_USER_LIMIT = $00000002;
159
{$EXTERNALSYM DISKQUOTA_LOGFLAG_USER_LIMIT}
162
// Helper macros to interrogate a log flags DWORD.
165
function DISKQUOTA_IS_LOGGED_USER_THRESHOLD(f: DWORD): BOOL;
166
{$EXTERNALSYM DISKQUOTA_IS_LOGGED_USER_THRESHOLD}
167
function DISKQUOTA_IS_LOGGED_USER_LIMIT(f: DWORD): BOOL;
168
{$EXTERNALSYM DISKQUOTA_IS_LOGGED_USER_LIMIT}
171
// Helper macros to set/clear bits in a log flags DWORD.
174
function DISKQUOTA_SET_LOG_USER_THRESHOLD(f: DWORD; yn: BOOL): DWORD;
175
{$EXTERNALSYM DISKQUOTA_SET_LOG_USER_THRESHOLD}
176
function DISKQUOTA_SET_LOG_USER_LIMIT(f: DWORD; yn: BOOL): DWORD;
177
{$EXTERNALSYM DISKQUOTA_SET_LOG_USER_LIMIT}
180
// Per-user quota information.
184
PDISKQUOTA_USER_INFORMATION = ^DISKQUOTA_USER_INFORMATION;
185
{$EXTERNALSYM PDISKQUOTA_USER_INFORMATION}
186
DiskQuotaUserInformation = record
188
QuotaThreshold: LONGLONG;
189
QuotaLimit: LONGLONG;
191
{$EXTERNALSYM DiskQuotaUserInformation}
192
DISKQUOTA_USER_INFORMATION = DiskQuotaUserInformation;
193
{$EXTERNALSYM DISKQUOTA_USER_INFORMATION}
194
TDiskQuotaUserInformation = DISKQUOTA_USER_INFORMATION;
195
PDiskQuotaUserInformation = PDISKQUOTA_USER_INFORMATION;
198
// Values for fNameResolution argument to:
200
// IDiskQuotaControl::AddUserSid
201
// IDiskQuotaControl::AddUserName
202
// IDiskQuotaControl::FindUserSid
203
// IDiskQuotaControl::CreateEnumUsers
207
DISKQUOTA_USERNAME_RESOLVE_NONE = 0;
208
{$EXTERNALSYM DISKQUOTA_USERNAME_RESOLVE_NONE}
209
DISKQUOTA_USERNAME_RESOLVE_SYNC = 1;
210
{$EXTERNALSYM DISKQUOTA_USERNAME_RESOLVE_SYNC}
211
DISKQUOTA_USERNAME_RESOLVE_ASYNC = 2;
212
{$EXTERNALSYM DISKQUOTA_USERNAME_RESOLVE_ASYNC}
215
// Values for status returned by IDiskQuotaUser::GetAccountStatus.
218
DISKQUOTA_USER_ACCOUNT_RESOLVED = 0;
219
{$EXTERNALSYM DISKQUOTA_USER_ACCOUNT_RESOLVED}
220
DISKQUOTA_USER_ACCOUNT_UNAVAILABLE = 1;
221
{$EXTERNALSYM DISKQUOTA_USER_ACCOUNT_UNAVAILABLE}
222
DISKQUOTA_USER_ACCOUNT_DELETED = 2;
223
{$EXTERNALSYM DISKQUOTA_USER_ACCOUNT_DELETED}
224
DISKQUOTA_USER_ACCOUNT_INVALID = 3;
225
{$EXTERNALSYM DISKQUOTA_USER_ACCOUNT_INVALID}
226
DISKQUOTA_USER_ACCOUNT_UNKNOWN = 4;
227
{$EXTERNALSYM DISKQUOTA_USER_ACCOUNT_UNKNOWN}
228
DISKQUOTA_USER_ACCOUNT_UNRESOLVED = 5;
229
{$EXTERNALSYM DISKQUOTA_USER_ACCOUNT_UNRESOLVED}
232
// IDiskQuotaUser represents a single user quota record on a particular
233
// NTFS volume. Objects using this interface are instantiated
234
// through several IDiskQuotaControl methods.
238
IDiskQuotaUser = interface (IUnknown)
239
['{7988B574-EC89-11cf-9C00-00AA00A14F56}']
240
function GetID(var pulID: ULONG): HRESULT; stdcall;
241
function GetName(pszAccountContainer: LPWSTR; cchAccountContainer: DWORD;
242
pszLogonName: LPWSTR; cchLogonName: DWORD; pszDisplayName: LPWSTR;
243
cchDisplayName: DWORD): HRESULT; stdcall;
244
function GetSidLength(var pdwLength: DWORD): HRESULT; stdcall;
245
function GetSid(pbSidBuffer: LPBYTE; cbSidBuffer: DWORD): HRESULT; stdcall;
246
function GetQuotaThreshold(var pllThreshold: LONGLONG): HRESULT; stdcall;
247
function GetQuotaThresholdText(pszText: LPWSTR; cchText: DWORD): HRESULT; stdcall;
248
function GetQuotaLimit(var pllLimit: LONGLONG): HRESULT; stdcall;
249
function GetQuotaLimitText(pszText: LPWSTR; cchText: DWORD): HRESULT; stdcall;
250
function GetQuotaUsed(var pllUsed: LONGLONG): HRESULT; stdcall;
251
function GetQuotaUsedText(pszText: LPWSTR; cchText: DWORD): HRESULT; stdcall;
252
function GetQuotaInformation(pbQuotaInfo: LPVOID; cbQuotaInfo: DWORD): HRESULT; stdcall;
253
function SetQuotaThreshold(llThreshold: LONGLONG; fWriteThrough: BOOL): HRESULT; stdcall;
254
function SetQuotaLimit(llLimit: LONGLONG; fWriteThrough: BOOL): HRESULT; stdcall;
255
function Invalidate: HRESULT; stdcall;
256
function GetAccountStatus(var pdwStatus: DWORD): HRESULT; stdcall;
258
{$EXTERNALSYM IDiskQuotaUser}
260
DISKQUOTA_USER = IDiskQuotaUser;
261
{$EXTERNALSYM DISKQUOTA_USER}
262
PDISKQUOTA_USER = ^DISKQUOTA_USER;
263
{$EXTERNALSYM PDISKQUOTA_USER}
266
// IEnumDiskQuotaUsers represents an enumerator created by
267
// IDiskQuotaControl for the purpose of enumerating individual user quota
268
// records on a particular volume. Each record is represented through
269
// the IDiskQuotaUser interface.
272
IEnumDiskQuotaUsers = interface (IUnknown)
273
['{7988B577-EC89-11cf-9C00-00AA00A14F56}']
274
function Next(cUsers: DWORD; var rgUsers: IDiskQuotaUser; pcUsersFetched: LPDWORD): HRESULT; stdcall;
275
function Skip(cUsers: DWORD): HRESULT; stdcall;
276
function Reset: HRESULT; stdcall;
277
function Clone(out ppEnum: IEnumDiskQuotaUsers): HRESULT; stdcall;
279
{$EXTERNALSYM IEnumDiskQuotaUsers}
281
ENUM_DISKQUOTA_USERS = IEnumDiskQuotaUsers;
282
{$EXTERNALSYM ENUM_DISKQUOTA_USERS}
283
PENUM_DISKQUOTA_USERS = ^ENUM_DISKQUOTA_USERS;
284
{$EXTERNALSYM PENUM_DISKQUOTA_USERS}
287
// IDiskQuotaUserBatch represents a collection of IDiskQuotaUser
288
// pointers for the purpose of grouping updates to quota information.
291
IDiskQuotaUserBatch = interface (IUnknown)
292
['{7988B576-EC89-11cf-9C00-00AA00A14F56}']
293
function Add(pUser: IDiskQuotaUser): HRESULT; stdcall;
294
function Remove(pUser: IDiskQuotaUser): HRESULT; stdcall;
295
function RemoveAll: HRESULT; stdcall;
296
function FlushToDisk: HRESULT; stdcall;
298
{$EXTERNALSYM IDiskQuotaUserBatch}
300
DISKQUOTA_USER_BATCH = IDiskQuotaUserBatch;
301
{$EXTERNALSYM DISKQUOTA_USER_BATCH}
302
PDISKQUOTA_USER_BATCH = ^DISKQUOTA_USER_BATCH;
303
{$EXTERNALSYM PDISKQUOTA_USER_BATCH}
306
// IDiskQuotaControl represents a disk volume, providing query and
307
// control of that volume's quota information.
310
IDiskQuotaControl = interface (IConnectionPointContainer)
311
['{7988B571-EC89-11cf-9C00-00AA00A14F56}']
312
function Initialize(pszPath: LPCWSTR; bReadWrite: BOOL): HRESULT; stdcall;
313
function SetQuotaState(dwState: DWORD): HRESULT; stdcall;
314
function GetQuotaState(var pdwState: DWORD): HRESULT; stdcall;
315
function SetQuotaLogFlags(dwFlags: DWORD): HRESULT; stdcall;
316
function GetQuotaLogFlags(var pdwFlags: DWORD): HRESULT; stdcall;
317
function SetDefaultQuotaThreshold(llThreshold: LONGLONG): HRESULT; stdcall;
318
function GetDefaultQuotaThreshold(var pllThreshold: LONGLONG): HRESULT; stdcall;
319
function GetDefaultQuotaThresholdText(pszText: LPWSTR; cchText: DWORD): HRESULT; stdcall;
320
function SetDefaultQuotaLimit(llLimit: LONGLONG): HRESULT; stdcall;
321
function GetDefaultQuotaLimit(var pllLimit: LONGLONG): HRESULT; stdcall;
322
function GetDefaultQuotaLimitText(pszText: LPWSTR; cchText: DWORD): HRESULT; stdcall;
323
function AddUserSid(pUserSid: PSID; fNameResolution: DWORD;
324
out ppUser: IDiskQuotaUser): HRESULT; stdcall;
325
function AddUserName(pszLogonName: LPCWSTR; fNameResolution: DWORD;
326
out ppUser: IDiskQuotaUser): HRESULT; stdcall;
327
function DeleteUser(pUser: IDiskQuotaUser): HRESULT; stdcall;
328
function FindUserSid(pUserSid: PSID; fNameResolution: DWORD;
329
out ppUser: IDiskQuotaUser): HRESULT; stdcall;
330
function FindUserName(pszLogonName: LPCWSTR; out ppUser: IDiskQuotaUser): HRESULT; stdcall;
331
function CreateEnumUsers(rgpUserSids: PSID; cpSids, fNameResolution: DWORD;
332
out ppEnum: IEnumDiskQuotaUsers): HRESULT; stdcall;
333
function CreateUserBatch(out ppBatch: IDiskQuotaUserBatch): HRESULT; stdcall;
334
function InvalidateSidNameCache: HRESULT; stdcall;
335
function GiveUserNameResolutionPriority(pUser: IDiskQuotaUser): HRESULT; stdcall;
336
function ShutdownNameResolution: HRESULT; stdcall;
338
{$EXTERNALSYM IDiskQuotaControl}
340
DISKQUOTA_CONTROL = IDiskQuotaControl;
341
{$EXTERNALSYM DISKQUOTA_CONTROL}
342
PDISKQUOTA_CONTROL = ^DISKQUOTA_CONTROL;
343
{$EXTERNALSYM PDISKQUOTA_CONTROL}
345
IDiskQuotaEvents = interface (IUnknown)
346
['{7988B579-EC89-11cf-9C00-00AA00A14F56}']
347
function OnUserNameChanged(pUser: IDiskQuotaUser): HRESULT; stdcall;
349
{$EXTERNALSYM IDiskQuotaEvents}
351
DISKQUOTA_EVENTS = IDiskQuotaEvents;
352
{$EXTERNALSYM DISKQUOTA_EVENTS;}
353
PDISKQUOTA_EVENTS = ^DISKQUOTA_EVENTS;
354
{$EXTERNALSYM PDISKQUOTA_EVENTS;}
358
function DISKQUOTA_SET_DISABLED(var s: DWORD): DWORD;
360
s := DISKQUOTA_STATE_DISABLED;
364
function DISKQUOTA_SET_TRACKED(var s: DWORD): DWORD;
366
s := DISKQUOTA_STATE_TRACK;
370
function DISKQUOTA_SET_ENFORCED(var s: DWORD): DWORD;
372
s := DISKQUOTA_STATE_ENFORCE;
376
function DISKQUOTA_IS_DISABLED(s: DWORD): BOOL;
378
Result := (DISKQUOTA_STATE_DISABLED = (s and DISKQUOTA_STATE_MASK));
381
function DISKQUOTA_IS_TRACKED(s: DWORD): BOOL;
383
Result := (DISKQUOTA_STATE_TRACK = (s and DISKQUOTA_STATE_MASK));
386
function DISKQUOTA_IS_ENFORCED(s: DWORD): BOOL;
388
Result := (DISKQUOTA_STATE_ENFORCE = (s and DISKQUOTA_STATE_MASK));
391
function DISKQUOTA_FILE_INCOMPLETE(s: DWORD): BOOL;
393
Result := (0 <> (s and DISKQUOTA_FILESTATE_INCOMPLETE));
396
function DISKQUOTA_FILE_REBUILDING(s: DWORD): BOOL;
398
Result := (0 <> (s and DISKQUOTA_FILESTATE_REBUILDING));
401
function DISKQUOTA_IS_LOGGED_USER_THRESHOLD(f: DWORD): BOOL;
403
Result := (0 <> (f and DISKQUOTA_LOGFLAG_USER_THRESHOLD));
406
function DISKQUOTA_IS_LOGGED_USER_LIMIT(f: DWORD): BOOL;
408
Result := (0 <> (f and DISKQUOTA_LOGFLAG_USER_LIMIT));
411
function DISKQUOTA_SET_LOG_USER_THRESHOLD(f: DWORD; yn: BOOL): DWORD;
413
Result := f and (not DISKQUOTA_LOGFLAG_USER_THRESHOLD);
415
Result := Result or DISKQUOTA_LOGFLAG_USER_THRESHOLD;
418
function DISKQUOTA_SET_LOG_USER_LIMIT(f: DWORD; yn: BOOL): DWORD;
420
Result := f and (not DISKQUOTA_LOGFLAG_USER_LIMIT);
422
Result := Result or DISKQUOTA_LOGFLAG_USER_LIMIT;