~ubuntu-branches/ubuntu/dapper/fpc/dapper

« back to all changes in this revision

Viewing changes to packages/extra/winunits/jwaadshlp.pas

  • Committer: Bazaar Package Importer
  • Author(s): Carlos Laviola
  • Date: 2005-05-30 11:59:10 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050530115910-x5pbzm4qqta4i94h
Tags: 2.0.0-2
debian/fp-compiler.postinst.in: forgot to reapply the patch that
correctly creates the slave link to pc(1).  (Closes: #310907)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{******************************************************************************}
 
2
{                                                                              }
 
3
{ Active Directory Helper Functions API interface Unit for Object Pascal       }
 
4
{                                                                              }
 
5
{ Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft          }
 
6
{ Corporation. All Rights Reserved.                                            }
 
7
{                                                                              }
 
8
{ The original file is: adshlp.h, released June 2000. The original Pascal      }
 
9
{ code is: AdsHlp.pas, released December 2000. The initial developer of the    }
 
10
{ Pascal code is Marcel van Brakel (brakelm att chello dott nl).               }
 
11
{                                                                              }
 
12
{ Portions created by Marcel van Brakel are Copyright (C) 1999-2001            }
 
13
{ Marcel van Brakel. All Rights Reserved.                                      }
 
14
{                                                                              }
 
15
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
 
16
{                                                                              }
 
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              }
 
19
{                                                                              }
 
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                                      }
 
24
{                                                                              }
 
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.    }
 
28
{                                                                              }
 
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.          }
 
38
{                                                                              }
 
39
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
 
40
{                                                                              }
 
41
{******************************************************************************}
 
42
 
 
43
// $Id: jwaadshlp.pas,v 1.1 2005/04/04 07:56:10 marco Exp $
 
44
 
 
45
unit JwaAdsHlp;
 
46
 
 
47
{$WEAKPACKAGEUNIT}
 
48
 
 
49
{$HPPEMIT ''}
 
50
{$HPPEMIT '#include "adshlp.h"'}
 
51
{$HPPEMIT ''}
 
52
 
 
53
{$I jediapilib.inc}
 
54
 
 
55
interface
 
56
 
 
57
uses
 
58
  ActiveX {TODO}, JwaAdsTLB, JwaWinType, JwaWinNT;
 
59
 
 
60
function ADsGetObject(lpszPathName: LPCWSTR; const riid: TGUID; out ppObject: Pointer): HRESULT; stdcall;
 
61
{$EXTERNALSYM ADsGetObject}
 
62
 
 
63
function ADsBuildEnumerator(pADsContainer: IADsContainer; out ppEnumVariant: IEnumVARIANT): HRESULT; stdcall;
 
64
{$EXTERNALSYM ADsBuildEnumerator}
 
65
 
 
66
function ADsFreeEnumerator(pEnumVariant: IEnumVARIANT): HRESULT; stdcall;
 
67
{$EXTERNALSYM ADsFreeEnumerator}
 
68
 
 
69
function ADsEnumerateNext(pEnumVariant: IEnumVARIANT; cElements: ULONG;
 
70
  var pvar: OleVariant; var pcElementsFetched: ULONG): HRESULT; stdcall;
 
71
{$EXTERNALSYM ADsEnumerateNext}
 
72
 
 
73
function ADsBuildVarArrayStr(lppPathNames: LPWSTR; dwPathNames: DWORD;
 
74
  var pVar: OleVariant): HRESULT; stdcall;
 
75
{$EXTERNALSYM ADsBuildVarArrayStr}
 
76
 
 
77
function ADsBuildVarArrayInt(lpdwObjectTypes: LPDWORD; dwObjectTypes: DWORD;
 
78
  var pVar: OleVariant): HRESULT; stdcall;
 
79
{$EXTERNALSYM ADsBuildVarArrayInt}
 
80
 
 
81
function ADsOpenObject(lpszPathName, lpszUserName, lpszPassword: LPCWSTR;
 
82
  dwReserved: DWORD; const riid: TGUID; out ppObject: Pointer): HRESULT; stdcall;
 
83
{$EXTERNALSYM ADsOpenObject}
 
84
 
 
85
//
 
86
// Helper functions for extended error support
 
87
//
 
88
 
 
89
function ADsGetLastError(var lpError: DWORD; lpErrorBuf: LPWSTR;
 
90
  dwErrorBufLen: DWORD; lpNameBuf: LPWSTR; dwNameBufLen: DWORD): HRESULT; stdcall;
 
91
{$EXTERNALSYM ADsGetLastError}
 
92
 
 
93
procedure ADsSetLastError(dwErr: DWORD; pszError, pszProvider: LPCWSTR); stdcall;
 
94
{$EXTERNALSYM ADsSetLastError}
 
95
 
 
96
//procedure ADsFreeAllErrorRecords; stdcall;
 
97
//{$EXTERNALSYM ADsFreeAllErrorRecords}
 
98
 
 
99
function AllocADsMem(cb: DWORD): LPVOID; stdcall;
 
100
{$EXTERNALSYM AllocADsMem}
 
101
 
 
102
function FreeADsMem(pMem: LPVOID): BOOL; stdcall;
 
103
{$EXTERNALSYM FreeADsMem}
 
104
 
 
105
function ReallocADsMem(pOldMem: LPVOID; cbOld, cbNew: DWORD): LPVOID; stdcall;
 
106
{$EXTERNALSYM ReallocADsMem}
 
107
 
 
108
function AllocADsStr(pStr: LPCWSTR): LPWSTR; stdcall;
 
109
{$EXTERNALSYM AllocADsStr}
 
110
 
 
111
function FreeADsStr(pStr: LPWSTR): BOOL; stdcall;
 
112
{$EXTERNALSYM FreeADsStr}
 
113
 
 
114
function ReallocADsStr(var ppStr: LPWSTR; pStr: LPWSTR): BOOL; stdcall;
 
115
{$EXTERNALSYM ReallocADsStr}
 
116
 
 
117
function ADsEncodeBinaryData(pbSrcData: PBYTE; dwSrcLen: DWORD;
 
118
  var ppszDestData: LPWSTR): HRESULT; stdcall;
 
119
{$EXTERNALSYM ADsEncodeBinaryData}
 
120
 
 
121
function ADsDecodeBinaryData(szSrcData: LPCWSTR; var ppbDestData: PBYTE;
 
122
  var pdwDestLen: ULONG): HRESULT; stdcall;
 
123
{$EXTERNALSYM ADsDecodeBinaryData}
 
124
 
 
125
type
 
126
  // imports of a type library sometimes are missing a few decls, these are just
 
127
  // a few of them to make this file compile at all. I really should do all of
 
128
  // them one day.
 
129
 
 
130
  PADSVALUE = ^_adsvalue;
 
131
  {$EXTERNALSYM PADSVALUE}
 
132
  PADS_ATTR_INFO = ^_ads_attr_info;
 
133
  {$EXTERNALSYM PADS_ATTR_INFO}
 
134
 
 
135
function PropVariantToAdsType(var pVariant: OleVariant; dwNumVariant: DWORD;
 
136
  var ppAdsValues: PADSVALUE; pdwNumValues: PDWORD): HRESULT; stdcall;
 
137
{$EXTERNALSYM PropVariantToAdsType}
 
138
 
 
139
function AdsTypeToPropVariant(pAdsValues: PADSVALUE; dwNumValues: DWORD;
 
140
  var pVariant: OleVariant): HRESULT; stdcall;
 
141
{$EXTERNALSYM AdsTypeToPropVariant}
 
142
 
 
143
procedure AdsFreeAdsValues(pAdsValues: PADSVALUE; dwNumValues: DWORD); stdcall;
 
144
{$EXTERNALSYM AdsFreeAdsValues}
 
145
 
 
146
//
 
147
// Helper routines to convert IADsSecurityDescriptor to a binary
 
148
// security descriptor and also to convert a binary SD to 
 
149
// IADsSecurityDescriptor.
 
150
//
 
151
 
 
152
// TODO VARIANT!
 
153
 
 
154
function BinarySDToSecurityDescriptor(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
 
155
  var pVarsec: VARIANT; pszServerName, userName, passWord: LPCWSTR; dwFlags: DWORD): HRESULT; stdcall;
 
156
{$EXTERNALSYM BinarySDToSecurityDescriptor}
 
157
 
 
158
function SecurityDescriptorToBinarySD(vVarSecDes: VARIANT;
 
159
  var ppSecurityDescriptor: PSECURITY_DESCRIPTOR; pdwSDLength: PDWORD;
 
160
  pszServerName, userName, passWord: LPCWSTR; dwFlags: DWORD): HRESULT; stdcall;
 
161
{$EXTERNALSYM SecurityDescriptorToBinarySD}
 
162
 
 
163
implementation
 
164
 
 
165
const
 
166
  adslib = 'activeds.dll';
 
167
 
 
168
//procedure ADsFreeAllErrorRecords
 
169
 
 
170
{$IFDEF DYNAMIC_LINK}
 
171
 
 
172
var
 
173
  _ADsGetObject: Pointer;
 
174
 
 
175
function ADsGetObject;
 
176
begin
 
177
  GetProcedureAddress(_ADsGetObject, adslib, 'ADsGetObject');
 
178
  asm
 
179
        MOV     ESP, EBP
 
180
        POP     EBP
 
181
        JMP     [_ADsGetObject]
 
182
  end;
 
183
end;
 
184
 
 
185
var
 
186
  _ADsBuildEnumerator: Pointer;
 
187
 
 
188
function ADsBuildEnumerator;
 
189
begin
 
190
  GetProcedureAddress(_ADsBuildEnumerator, adslib, 'ADsBuildEnumerator');
 
191
  asm
 
192
        MOV     ESP, EBP
 
193
        POP     EBP
 
194
        JMP     [_ADsBuildEnumerator]
 
195
  end;
 
196
end;
 
197
 
 
198
var
 
199
  _ADsFreeEnumerator: Pointer;
 
200
 
 
201
function ADsFreeEnumerator;
 
202
begin
 
203
  GetProcedureAddress(_ADsFreeEnumerator, adslib, 'ADsFreeEnumerator');
 
204
  asm
 
205
        MOV     ESP, EBP
 
206
        POP     EBP
 
207
        JMP     [_ADsFreeEnumerator]
 
208
  end;
 
209
end;
 
210
 
 
211
var
 
212
  _ADsEnumerateNext: Pointer;
 
213
 
 
214
function ADsEnumerateNext;
 
215
begin
 
216
  GetProcedureAddress(_ADsEnumerateNext, adslib, 'ADsEnumerateNext');
 
217
  asm
 
218
        MOV     ESP, EBP
 
219
        POP     EBP
 
220
        JMP     [_ADsEnumerateNext]
 
221
  end;
 
222
end;
 
223
 
 
224
var
 
225
  _ADsBuildVarArrayStr: Pointer;
 
226
 
 
227
function ADsBuildVarArrayStr;
 
228
begin
 
229
  GetProcedureAddress(_ADsBuildVarArrayStr, adslib, 'ADsBuildVarArrayStr');
 
230
  asm
 
231
        MOV     ESP, EBP
 
232
        POP     EBP
 
233
        JMP     [_ADsBuildVarArrayStr]
 
234
  end;
 
235
end;
 
236
 
 
237
var
 
238
  _ADsBuildVarArrayInt: Pointer;
 
239
 
 
240
function ADsBuildVarArrayInt;
 
241
begin
 
242
  GetProcedureAddress(_ADsBuildVarArrayInt, adslib, 'ADsBuildVarArrayInt');
 
243
  asm
 
244
        MOV     ESP, EBP
 
245
        POP     EBP
 
246
        JMP     [_ADsBuildVarArrayInt]
 
247
  end;
 
248
end;
 
249
 
 
250
var
 
251
  _ADsOpenObject: Pointer;
 
252
 
 
253
function ADsOpenObject;
 
254
begin
 
255
  GetProcedureAddress(_ADsOpenObject, adslib, 'ADsOpenObject');
 
256
  asm
 
257
        MOV     ESP, EBP
 
258
        POP     EBP
 
259
        JMP     [_ADsOpenObject]
 
260
  end;
 
261
end;
 
262
 
 
263
var
 
264
  _ADsGetLastError: Pointer;
 
265
 
 
266
function ADsGetLastError;
 
267
begin
 
268
  GetProcedureAddress(_ADsGetLastError, adslib, 'ADsGetLastError');
 
269
  asm
 
270
        MOV     ESP, EBP
 
271
        POP     EBP
 
272
        JMP     [_ADsGetLastError]
 
273
  end;
 
274
end;
 
275
 
 
276
var
 
277
  _ADsSetLastError: Pointer;
 
278
 
 
279
procedure ADsSetLastError;
 
280
begin
 
281
  GetProcedureAddress(_ADsSetLastError, adslib, 'ADsSetLastError');
 
282
  asm
 
283
        MOV     ESP, EBP
 
284
        POP     EBP
 
285
        JMP     [_ADsSetLastError]
 
286
  end;
 
287
end;
 
288
 
 
289
var
 
290
  _AllocADsMem: Pointer;
 
291
 
 
292
function AllocADsMem;
 
293
begin
 
294
  GetProcedureAddress(_AllocADsMem, adslib, 'AllocADsMem');
 
295
  asm
 
296
        MOV     ESP, EBP
 
297
        POP     EBP
 
298
        JMP     [_AllocADsMem]
 
299
  end;
 
300
end;
 
301
 
 
302
var
 
303
  _FreeADsMem: Pointer;
 
304
 
 
305
function FreeADsMem;
 
306
begin
 
307
  GetProcedureAddress(_FreeADsMem, adslib, 'FreeADsMem');
 
308
  asm
 
309
        MOV     ESP, EBP
 
310
        POP     EBP
 
311
        JMP     [_FreeADsMem]
 
312
  end;
 
313
end;
 
314
 
 
315
var
 
316
  _ReallocADsMem: Pointer;
 
317
 
 
318
function ReallocADsMem;
 
319
begin
 
320
  GetProcedureAddress(_ReallocADsMem, adslib, 'ReallocADsMem');
 
321
  asm
 
322
        MOV     ESP, EBP
 
323
        POP     EBP
 
324
        JMP     [_ReallocADsMem]
 
325
  end;
 
326
end;
 
327
 
 
328
var
 
329
  _AllocADsStr: Pointer;
 
330
 
 
331
function AllocADsStr;
 
332
begin
 
333
  GetProcedureAddress(_AllocADsStr, adslib, 'AllocADsStr');
 
334
  asm
 
335
        MOV     ESP, EBP
 
336
        POP     EBP
 
337
        JMP     [_AllocADsStr]
 
338
  end;
 
339
end;
 
340
 
 
341
var
 
342
  _FreeADsStr: Pointer;
 
343
 
 
344
function FreeADsStr;
 
345
begin
 
346
  GetProcedureAddress(_FreeADsStr, adslib, 'FreeADsStr');
 
347
  asm
 
348
        MOV     ESP, EBP
 
349
        POP     EBP
 
350
        JMP     [_FreeADsStr]
 
351
  end;
 
352
end;
 
353
 
 
354
var
 
355
  _ReallocADsStr: Pointer;
 
356
 
 
357
function ReallocADsStr;
 
358
begin
 
359
  GetProcedureAddress(_ReallocADsStr, adslib, 'ReallocADsStr');
 
360
  asm
 
361
        MOV     ESP, EBP
 
362
        POP     EBP
 
363
        JMP     [_ReallocADsStr]
 
364
  end;
 
365
end;
 
366
 
 
367
var
 
368
  _ADsEncodeBinaryData: Pointer;
 
369
 
 
370
function ADsEncodeBinaryData;
 
371
begin
 
372
  GetProcedureAddress(_ADsEncodeBinaryData, adslib, 'ADsEncodeBinaryData');
 
373
  asm
 
374
        MOV     ESP, EBP
 
375
        POP     EBP
 
376
        JMP     [_ADsEncodeBinaryData]
 
377
  end;
 
378
end;
 
379
 
 
380
var
 
381
  _ADsDecodeBinaryData: Pointer;
 
382
 
 
383
function ADsDecodeBinaryData;
 
384
begin
 
385
  GetProcedureAddress(_ADsDecodeBinaryData, adslib, 'ADsDecodeBinaryData');
 
386
  asm
 
387
        MOV     ESP, EBP
 
388
        POP     EBP
 
389
        JMP     [_ADsDecodeBinaryData]
 
390
  end;
 
391
end;
 
392
 
 
393
var
 
394
  _PropVariantToAdsType: Pointer;
 
395
 
 
396
function PropVariantToAdsType;
 
397
begin
 
398
  GetProcedureAddress(_PropVariantToAdsType, adslib, 'PropVariantToAdsType');
 
399
  asm
 
400
        MOV     ESP, EBP
 
401
        POP     EBP
 
402
        JMP     [_PropVariantToAdsType]
 
403
  end;
 
404
end;
 
405
 
 
406
var
 
407
  _AdsTypeToPropVariant: Pointer;
 
408
 
 
409
function AdsTypeToPropVariant;
 
410
begin
 
411
  GetProcedureAddress(_AdsTypeToPropVariant, adslib, 'AdsTypeToPropVariant');
 
412
  asm
 
413
        MOV     ESP, EBP
 
414
        POP     EBP
 
415
        JMP     [_AdsTypeToPropVariant]
 
416
  end;
 
417
end;
 
418
 
 
419
var
 
420
  _AdsFreeAdsValues: Pointer;
 
421
 
 
422
procedure AdsFreeAdsValues;
 
423
begin
 
424
  GetProcedureAddress(_AdsFreeAdsValues, adslib, 'AdsFreeAdsValues');
 
425
  asm
 
426
        MOV     ESP, EBP
 
427
        POP     EBP
 
428
        JMP     [_AdsFreeAdsValues]
 
429
  end;
 
430
end;
 
431
 
 
432
var
 
433
  _BinarySDToSecurityDescriptor: Pointer;
 
434
 
 
435
function BinarySDToSecurityDescriptor;
 
436
begin
 
437
  GetProcedureAddress(_BinarySDToSecurityDescriptor, adslib, 'BinarySDToSecurityDescriptor');
 
438
  asm
 
439
        MOV     ESP, EBP
 
440
        POP     EBP
 
441
        JMP     [_BinarySDToSecurityDescriptor]
 
442
  end;
 
443
end;
 
444
 
 
445
var
 
446
  _SecurityDescriptorToBinarySD: Pointer;
 
447
 
 
448
function SecurityDescriptorToBinarySD;
 
449
begin
 
450
  GetProcedureAddress(_SecurityDescriptorToBinarySD, adslib, 'SecurityDescriptorToBinarySD');
 
451
  asm
 
452
        MOV     ESP, EBP
 
453
        POP     EBP
 
454
        JMP     [_SecurityDescriptorToBinarySD]
 
455
  end;
 
456
end;
 
457
 
 
458
{$ELSE}
 
459
 
 
460
function ADsGetObject; external adslib name 'ADsGetObject';
 
461
function ADsBuildEnumerator; external adslib name 'ADsBuildEnumerator';
 
462
function ADsFreeEnumerator; external adslib name 'ADsFreeEnumerator';
 
463
function ADsEnumerateNext; external adslib name 'ADsEnumerateNext';
 
464
function ADsBuildVarArrayStr; external adslib name 'ADsBuildVarArrayStr';
 
465
function ADsBuildVarArrayInt; external adslib name 'ADsBuildVarArrayInt';
 
466
function ADsOpenObject; external adslib name 'ADsOpenObject';
 
467
function ADsGetLastError; external adslib name 'ADsGetLastError';
 
468
procedure ADsSetLastError; external adslib name 'ADsSetLastError';
 
469
function AllocADsMem; external adslib name 'AllocADsMem';
 
470
function FreeADsMem; external adslib name 'FreeADsMem';
 
471
function ReallocADsMem; external adslib name 'ReallocADsMem';
 
472
function AllocADsStr; external adslib name 'AllocADsStr';
 
473
function FreeADsStr; external adslib name 'FreeADsStr';
 
474
function ReallocADsStr; external adslib name 'ReallocADsStr';
 
475
function ADsEncodeBinaryData; external adslib name 'ADsEncodeBinaryData';
 
476
function ADsDecodeBinaryData; external adslib name 'ADsDecodeBinaryData';
 
477
function PropVariantToAdsType; external adslib name 'PropVariantToAdsType';
 
478
function AdsTypeToPropVariant; external adslib name 'AdsTypeToPropVariant';
 
479
procedure AdsFreeAdsValues; external adslib name 'AdsFreeAdsValues';
 
480
function BinarySDToSecurityDescriptor; external adslib name 'BinarySDToSecurityDescriptor';
 
481
function SecurityDescriptorToBinarySD; external adslib name 'SecurityDescriptorToBinarySD';
 
482
 
 
483
{$ENDIF DYNAMIC_LINK}
 
484
 
 
485
end.