source: branches/2.20_branch/Library/ACLUtility.pas@ 461

Last change on this file since 461 was 152, checked in by RBRi, 18 years ago

typo fix

  • Property svn:eol-style set to native
File size: 22.1 KB
Line 
1Unit ACLUtility;
2
3Interface
4
5Uses
6 Classes, SysUtils,
7{$ifdef os2}
8 Os2Def, IniFiles;
9{$endif}
10{$ifdef win32}
11 Registry;
12{$endif}
13
14function GetACLLibraryVersion: string;
15
16Type
17 TPrintOutput = procedure( TheText: string ) of object;
18 TTerminateCheck = function: boolean of object;
19 TProgressCallback = procedure( n, outof: integer;
20 Message: string ) of object;
21
22const
23 _MAX_PATH = 260; // max. length of full pathname
24 _MAX_DRIVE = 3; // max. length of drive component
25 _MAX_DIR = 256; // max. length of path component
26 _MAX_FNAME = 256; // max. length of file name component
27 _MAX_EXT = 256; // max. length of extension component
28
29 mrFailed = $c000 + 1;
30
31{$ifdef win32}
32Function GetAPIErrorString( ErrorCode: integer ): string;
33Function GetLastAPIErrorString: string;
34{$endif}
35
36Type
37 TMyIniFile =
38{$ifdef os2}
39 class( TAsciiIniFile )
40{$else}
41 class( TRegIniFile )
42{$endif}
43 constructor CreateMe( const Path: string );
44 destructor Destroy; override;
45 end;
46
47{$ifdef os2}
48function AllocateMemory( const Size: longint ): pointer;
49procedure DeallocateMemory( Var P: pointer );
50procedure Sleep( const milliseconds: longint );
51{$endif}
52
53// allocate a new copy of the given source memory
54procedure AllocMemCopy( const Source: pointer;
55 var Dest: pointer;
56 const Size: longint );
57
58procedure MemCopy( const Source: pointer;
59 const Dest: pointer;
60 const Size: longint );
61
62procedure FillMem( Dest: pointer;
63 Size: longint;
64 Data: Byte );
65
66// Returns A - B
67function PtrDiff( A, B: pointer ): longword;
68
69function Min( const a: longint;
70 const b: longint ): longint;
71
72function Max( const a: longint;
73 const b: longint ): longint;
74
75function Between( const Value: longint;
76 const Limit1: longint;
77 const Limit2: longint ): boolean;
78
79function PtrBetween( const Value: pointer;
80 const Limit1: pointer;
81 const Limit2: pointer ): boolean;
82
83Procedure AddList( Source, Dest: TList );
84
85Procedure AssignList( Source, Dest: TList );
86
87// Destroy the objects stored in List
88// and clear the list.
89Procedure ClearListAndObjects( List: TList );
90
91// Destroy the objects stored in the list
92// and then destroy the list itself
93// And set the reference to nil
94Procedure DestroyListAndObjects( Var List: TList );
95
96// Destroy the objects stored in the list.
97// You probably want to use one of the two functions above.
98Procedure DestroyListObjects( List: TList );
99
100// Returns the filename of the running app
101// (including drive/directory)
102Function GetApplicationFilename: string;
103
104// Returns the starting directory of the app
105Function GetApplicationDir: string;
106
107{$ifdef win32}
108type
109 TDaylightSavingStatus =
110 (
111 dssDisabled,
112 dssDaylightSaving,
113 dssNormal
114 );
115
116function GetDaylightSavingStatus: TDaylightSavingStatus;
117{$endif}
118
119type
120 TDataList = TList; // to help distinguish from TObjectList below
121
122type
123 TObjectListSortCompare = function ( Item1, Item2: TObject ): Integer;
124
125 // TObjectList has exactly the same functionality as TList,
126 // except that rather than using untyped pointers it expects
127 // object references. This means that incorrect typecasts can
128 // be detected when using the list
129 TObjectList = class( TList )
130 protected
131 function Get( index: integer ): TObject;
132 procedure Put( index: integer; Item: TObject );
133 public
134 function Add( item: TObject ): integer;
135 function First: TObject;
136 function IndexOf( item: TObject ): integer;
137 procedure Insert( Index: Integer; Item: TObject );
138 function Last: TObject;
139 function Remove( Item: TObject ): Integer;
140 procedure Sort( Compare: TObjectListSortCompare );
141 property Items[ index: integer ]: TObject read Get write Put; default;
142
143 // Additional:
144 // Copy the given list to this one.
145 procedure Assign( Source: TObjectList );
146 // Add the objects in the given list to this one
147 procedure AddList( Source: TObjectList );
148
149 end;
150
151{$ifdef os2}
152function GetCrc32( pData: pointer; size: longint ): longword;
153{$endif}
154
155function Pascal_GetCrc32( pData: pointer; size: longint ): longword;
156
157// Raise an exception if the given Code is <> 0
158procedure CheckSystemError( Code: longword;
159 Message: string );
160
161{$ifdef os2}
162// get pointer to start, and length, of specified parameter
163procedure GetCommandLineParameter( item: byte;
164 var pParam: pchar;
165 var ParamLength: longint );
166
167function GetUserProfileString( const AppName: string;
168 const KeyName: string;
169 const Default: string ): string;
170
171Procedure SetUserProfileString( const AppName: string;
172 const KeyName: string;
173 const Value: string );
174
175Procedure LoadDLLFunction( const DLLName: string;
176 const FunctionName: string;
177 var hDLL: HMODULE;
178 var F: pointer );
179
180{$endif}
181
182Implementation
183
184// Implementation ------------------------------------------
185
186Uses
187{$ifdef os2}
188 Dos, BseDos, BseTib, PmWin, PmGpi, PmDev, PmShl;
189{$else}
190 Windows, FileCtrl;
191{$endif}
192
193constructor TMyIniFile.CreateMe( const Path: string );
194begin
195{$ifdef os2}
196 Inherited Create( Path );
197{$else}
198 Inherited Create( Path );
199{$endif}
200end;
201
202destructor TMyIniFile.Destroy;
203begin
204{$ifdef os2}
205 Refresh;
206{$endif}
207 inherited Destroy;
208end;
209
210{$ifdef os2}
211function AllocateMemory( const Size: longint ): pointer;
212begin
213 GetMem( Result, size + sizeof( Size ) );
214 pLong( Result )^ := Size;
215 inc( Result, sizeof( Size ) );
216end;
217
218procedure DeallocateMemory( Var P: pointer );
219var
220 Size: longint;
221begin
222 if P = nil then
223 exit;
224
225 dec( P, sizeof( Size ) );
226 Size := pLong( P )^;
227 FreeMem( P, Size + sizeof( Size ) );
228 P := nil;
229end;
230{$endif}
231
232{$ifdef win32}
233Function GetAPIErrorString( ErrorCode: integer ): string;
234var
235 buffer: array[ 0..1000 ] of char;
236begin
237 if FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM,
238 nil, // no special message source
239 ErrorCode,
240 0, // use default language
241 Buffer,
242 Sizeof( Buffer ),
243 nil ) > 0
244 then // no arguments
245 Result:= IntToStr( ErrorCode ) + ': ' + Buffer
246 else
247 Result:= '(Unknown error)';
248
249end;
250
251Function GetLastAPIErrorString: string;
252begin
253 Result := GetAPIErrorString( GetLastError );
254end;
255{$endif}
256
257procedure AllocMemCopy( const Source: pointer;
258 var Dest: pointer;
259 const Size: longint );
260begin
261 GetMem( Dest, Size );
262 MemCopy( Source, Dest, Size );
263end;
264
265procedure MemCopy( const Source: pointer;
266 const Dest: pointer;
267 const Size: longint );
268begin
269 Move( Source^, Dest^, Size );
270end;
271
272procedure FillMem( Dest: pointer;
273 Size: longint;
274 Data: Byte );
275begin
276 FillChar( Dest^, Size, Data );
277end;
278
279function PtrDiff( A, B: pointer ): longword;
280begin
281 result:= longword( A ) - longword( B );
282end;
283
284Procedure AddList( Source, Dest: TList );
285var
286 i: longint;
287begin
288 // expand the destination list
289 // to what's required
290 Dest.Capacity := Dest.Capacity
291 + Source.Capacity;
292 for i:= 0 to Source.Count - 1 do
293 Dest.Add( Source[ i ] );
294end;
295
296Procedure AssignList( Source, Dest: TList );
297begin
298 Dest.Clear;
299 AddList( Source, Dest );
300end;
301
302{$ifdef win32}
303function GetDaylightSavingStatus: TDaylightSavingStatus;
304var
305 TimeZoneInfo: TIME_ZONE_INFORMATION;
306 ZoneID: DWORD;
307Begin
308 ZoneID:= GetTimeZoneInformation( TimeZoneInfo );
309 if TimeZoneInfo.DaylightBias = 0 then
310 Result:= dssDisabled
311 else if ZoneID = TIME_ZONE_ID_DAYLIGHT then
312 Result:= dssDaylightSaving
313 else
314 Result:= dssNormal;
315end;
316{$endif}
317
318// Destroy the objects stored in List
319// and clear the list.
320Procedure ClearListAndObjects( List: TList );
321begin
322 DestroyListObjects( List );
323 List.Clear;
324end;
325
326// Destroy the objects stored in the list
327// and then destroy the list itself.
328Procedure DestroyListAndObjects( Var List: TList );
329begin
330 if not Assigned( List ) then
331 exit;
332
333 DestroyListObjects( List );
334 List.Destroy;
335 List := nil;
336end;
337
338Procedure DestroyListObjects( List: TList );
339var
340 Index: longint;
341begin
342 for Index := 0 to List.Count - 1 do
343 begin
344 if List[ Index ] <> nil then
345 begin
346 TObject( List[ Index ] ).Destroy;
347 List[ Index ] := nil;
348 end;
349 end;
350end;
351
352function Min( const a: longint;
353 const b: longint ): longint;
354begin
355 if a<b then
356 result:= a
357 else
358 result:= b;
359end;
360
361function Max( const a: longint;
362 const b: longint ): longint;
363begin
364 if a>b then
365 result:= a
366 else
367 result:= b;
368end;
369
370function Between( const Value: longint;
371 const Limit1: longint;
372 const Limit2: longint ): boolean;
373begin
374 if Limit1 < Limit2 then
375 Result:= ( Value >= Limit1 ) and ( Value <= Limit2 )
376 else
377 Result:= ( Value >= Limit2 ) and ( Value <= Limit1 )
378end;
379
380function PtrBetween( const Value: pointer;
381 const Limit1: pointer;
382 const Limit2: pointer ): boolean;
383var
384 v, p1, p2: pchar;
385begin
386 v := Value;
387 p1 := Limit1;
388 p2 := Limit2;
389 if p1 < p2 then
390 Result:= ( V >= p1 ) and ( V <= p2 )
391 else
392 Result:= ( V >= p2 ) and ( V <= p1 )
393end;
394
395{$ifdef os2}
396Function GetApplicationFilename: string;
397var
398 pThreadInfo: PTIB;
399 pProcessInfo: PPIB;
400 ProcessName: cstring[ _MAX_PATH ];
401begin
402 DosGetInfoBlocks( pThreadInfo,
403 pProcessInfo );
404 DosQueryModuleName( pProcessInfo^.pib_hmte,
405 sizeof( ProcessName ),
406 ProcessName );
407 Result := ProcessName;
408end;
409{$else}
410Function GetApplicationFilename: string;
411var
412 ProcessName: array[ 0.._MAX_PATH ] of char;
413begin
414 GetModuleFileName( 0, // our own process
415 ProcessName,
416 sizeof( ProcessName ) );
417
418 Result := ProcessName;
419end;
420{$endif}
421
422Function GetApplicationDir: string;
423begin
424 Result := ExtractFilePath( GetApplicationFilename );
425end;
426
427{ TObjectList }
428
429function TObjectList.Add( item: TObject ): integer;
430begin
431 result := inherited Add( item );
432end;
433
434function TObjectList.First: TObject;
435begin
436 result := inherited First;
437end;
438
439function TObjectList.Get( index: integer ): TObject;
440begin
441 result := Items[ Index ];
442end;
443
444function TObjectList.IndexOf( item: TObject ): integer;
445begin
446 result := inherited IndexOf( item );
447end;
448
449procedure TObjectList.Insert( Index: Integer; Item: TObject );
450begin
451 inherited Insert( Index, Item );
452end;
453
454function TObjectList.Last: TObject;
455begin
456 result := inherited Last;
457end;
458
459procedure TObjectList.Put( index: integer; Item: TObject );
460begin
461 Items[ Index ] := Item;
462end;
463
464function TObjectList.Remove( Item: TObject ): Integer;
465begin
466 result := inherited Remove( Item );
467end;
468
469procedure QuickSortObjectList( SortList: PPointerList;
470 L, R: Integer;
471 CompareFunction: TObjectListSortCompare );
472var
473 I, J: Integer;
474 P, T: Pointer;
475begin
476 repeat
477 I := L;
478 J := R;
479 P := SortList^[(L + R) shr 1];
480 repeat
481 while CompareFunction( TObject( SortList^[I] ), P ) < 0 do
482 Inc(I);
483 while CompareFunction( TObject( SortList^[J] ), P) > 0 do
484 Dec(J);
485 if I <= J then
486 begin
487 T := SortList^[I];
488 SortList^[I] := SortList^[J];
489 SortList^[J] := T;
490 Inc(I);
491 Dec(J);
492 end;
493 until I > J;
494 if L < J then
495 QuickSortObjectList( SortList, L, J, CompareFunction );
496 L := I;
497 until I >= R;
498end;
499
500procedure TObjectList.Sort( Compare: TObjectListSortCompare );
501begin
502 if ( List <> nil ) and ( Count > 0 ) then
503 QuickSortObjectList( List, 0, Count - 1, Compare );
504end;
505
506procedure TObjectList.Assign( Source: TObjectList );
507begin
508 Clear;
509 AddList( Source );
510end;
511
512procedure TObjectList.AddList( Source: TObjectList );
513var
514 i: integer;
515begin
516 for i := 0 to Source.Count - 1 do
517 Add( Source[ i ] );
518end;
519
520{$ifdef os2}
521procedure Sleep( const milliseconds: longint );
522begin
523 DosSleep( milliseconds );
524end;
525{$endif}
526
527const
528 Crc32Table: array[ 0..255 ] of longword =
529 (
530 $00000000, $77073096, $EE0E612C, $990951BA,
531 $076DC419, $706AF48F, $E963A535, $9E6495A3,
532 $0EDB8832, $79DCB8A4, $E0D5E91E, $97D2D988,
533 $09B64C2B, $7EB17CBD, $E7B82D07, $90BF1D91,
534 $1DB71064, $6AB020F2, $F3B97148, $84BE41DE,
535 $1ADAD47D, $6DDDE4EB, $F4D4B551, $83D385C7,
536 $136C9856, $646BA8C0, $FD62F97A, $8A65C9EC,
537 $14015C4F, $63066CD9, $FA0F3D63, $8D080DF5,
538 $3B6E20C8, $4C69105E, $D56041E4, $A2677172,
539 $3C03E4D1, $4B04D447, $D20D85FD, $A50AB56B,
540 $35B5A8FA, $42B2986C, $DBBBC9D6, $ACBCF940,
541 $32D86CE3, $45DF5C75, $DCD60DCF, $ABD13D59,
542 $26D930AC, $51DE003A, $C8D75180, $BFD06116,
543 $21B4F4B5, $56B3C423, $CFBA9599, $B8BDA50F,
544 $2802B89E, $5F058808, $C60CD9B2, $B10BE924,
545 $2F6F7C87, $58684C11, $C1611DAB, $B6662D3D,
546 $76DC4190, $01DB7106, $98D220BC, $EFD5102A,
547 $71B18589, $06B6B51F, $9FBFE4A5, $E8B8D433,
548 $7807C9A2, $0F00F934, $9609A88E, $E10E9818,
549 $7F6A0DBB, $086D3D2D, $91646C97, $E6635C01,
550 $6B6B51F4, $1C6C6162, $856530D8, $F262004E,
551 $6C0695ED, $1B01A57B, $8208F4C1, $F50FC457,
552 $65B0D9C6, $12B7E950, $8BBEB8EA, $FCB9887C,
553 $62DD1DDF, $15DA2D49, $8CD37CF3, $FBD44C65,
554 $4DB26158, $3AB551CE, $A3BC0074, $D4BB30E2,
555 $4ADFA541, $3DD895D7, $A4D1C46D, $D3D6F4FB,
556 $4369E96A, $346ED9FC, $AD678846, $DA60B8D0,
557 $44042D73, $33031DE5, $AA0A4C5F, $DD0D7CC9,
558 $5005713C, $270241AA, $BE0B1010, $C90C2086,
559 $5768B525, $206F85B3, $B966D409, $CE61E49F,
560 $5EDEF90E, $29D9C998, $B0D09822, $C7D7A8B4,
561 $59B33D17, $2EB40D81, $B7BD5C3B, $C0BA6CAD,
562 $EDB88320, $9ABFB3B6, $03B6E20C, $74B1D29A,
563 $EAD54739, $9DD277AF, $04DB2615, $73DC1683,
564 $E3630B12, $94643B84, $0D6D6A3E, $7A6A5AA8,
565 $E40ECF0B, $9309FF9D, $0A00AE27, $7D079EB1,
566 $F00F9344, $8708A3D2, $1E01F268, $6906C2FE,
567 $F762575D, $806567CB, $196C3671, $6E6B06E7,
568 $FED41B76, $89D32BE0, $10DA7A5A, $67DD4ACC,
569 $F9B9DF6F, $8EBEEFF9, $17B7BE43, $60B08ED5,
570 $D6D6A3E8, $A1D1937E, $38D8C2C4, $4FDFF252,
571 $D1BB67F1, $A6BC5767, $3FB506DD, $48B2364B,
572 $D80D2BDA, $AF0A1B4C, $36034AF6, $41047A60,
573 $DF60EFC3, $A867DF55, $316E8EEF, $4669BE79,
574 $CB61B38C, $BC66831A, $256FD2A0, $5268E236,
575 $CC0C7795, $BB0B4703, $220216B9, $5505262F,
576 $C5BA3BBE, $B2BD0B28, $2BB45A92, $5CB36A04,
577 $C2D7FFA7, $B5D0CF31, $2CD99E8B, $5BDEAE1D,
578 $9B64C2B0, $EC63F226, $756AA39C, $026D930A,
579 $9C0906A9, $EB0E363F, $72076785, $05005713,
580 $95BF4A82, $E2B87A14, $7BB12BAE, $0CB61B38,
581 $92D28E9B, $E5D5BE0D, $7CDCEFB7, $0BDBDF21,
582 $86D3D2D4, $F1D4E242, $68DDB3F8, $1FDA836E,
583 $81BE16CD, $F6B9265B, $6FB077E1, $18B74777,
584 $88085AE6, $FF0F6A70, $66063BCA, $11010B5C,
585 $8F659EFF, $F862AE69, $616BFFD3, $166CCF45,
586 $A00AE278, $D70DD2EE, $4E048354, $3903B3C2,
587 $A7672661, $D06016F7, $4969474D, $3E6E77DB,
588 $AED16A4A, $D9D65ADC, $40DF0B66, $37D83BF0,
589 $A9BCAE53, $DEBB9EC5, $47B2CF7F, $30B5FFE9,
590 $BDBDF21C, $CABAC28A, $53B39330, $24B4A3A6,
591 $BAD03605, $CDD70693, $54DE5729, $23D967BF,
592 $B3667A2E, $C4614AB8, $5D681B02, $2A6F2B94,
593 $B40BBE37, $C30C8EA1, $5A05DF1B, $2D02EF8D
594 );
595
596function Pascal_GetCrc32( pData: pointer; size: longint ): longword;
597var
598 i: longint;
599 p: pbyte;
600begin
601 Result := $ffffffff;
602 p := pData;
603 for i := 0 to size - 1 do
604 begin
605 Result := ( Result shr 8 )
606 xor Crc32Table[ ( Result xor p^ ) and $000000FF ];
607 inc( p );
608 end;
609end;
610
611{$ifdef os2}
612function GetCrc32( pData: pointer; size: longint ): longword;
613begin
614 asm
615 mov esi, pData {esi: Points to Buffer}
616 mov edx, $ffffffff {edx: Result}
617 mov ecx, Size
618 xor eax, eax {clear EAX: top bits must remain 0}
619 cld
620
621 @@Loop:
622 mov ebx, edx {Save Result in ebx}
623 shr edx, 8
624 lodsb {Load next Buffer entry}
625 xor ebx, eax
626 and ebx, $ff
627
628// should be able to use
629// xor edx, dword ptr [edi+4*ebx]
630// Sibyl Assembler doesn't support it!
631
632 mov edi, ebx {Get lookup index}
633 shl edi, 2 {x4 to get address for longword}
634 xor edx, Crc32Table[edi] {lookup in table, XOR with edx}
635
636 dec ecx {Dec Count}
637 jnz @@Loop {if Count<>0 goto @@Loop}
638
639 mov Result, edx {Save Result}
640 end;
641end;
642{$endif}
643
644// Raise an exception if the given Code is <> 0
645procedure CheckSystemError( Code: longword;
646 Message: string );
647begin
648 if Code <> 0 then
649 raise Exception.Create( Message
650 + ': ['
651 + IntToStr( Code )
652 + '] '
653 + SysErrorMessage( Code ) );
654end;
655
656{$ifdef os2}
657procedure GetCommandLineParameter( item: byte;
658 var pParam: pchar;
659 var ParamLength: longint );
660
661Begin
662 ParamLength := 0;
663 ASM
664 MOV CL, item // Load item to CL
665 MOV AL, 2
666 MOV ESI, SYSTEM.ArgStart // Get start of parameters
667 CALLN32 SYSTEM.!ParaInfo // Get start of this parameter
668
669 LEA EDI, pParam // Address of pParam
670 MOV EDI, [EDI] // Address of what pParam references
671 MOV [EDI], ESI // store start of param
672
673 CMP ESI, 0 // Parameter invalid ?
674 JE gclp_End // leave if invalid
675
676 CLD
677 MOV ECX, 0 // Len is 0
678 MOV DL, 0 // we are not in quote state
679
680gclp_Loop:
681 LODSB // load byte of parameter
682
683 CMP AL, '"' // Check for quote char
684 JNE gclp_NotQuote
685 NOT DL // toggle quote flag
686
687gclp_NotQuote:
688 CMP AL, ' ' // check for space - end of parameter
689 JNE gclp_NotEnd
690 // parameter has ended, unless in quote
691 CMP DL, 0 // check quote flag
692 JE gclp_Done // if off, then we're finished
693
694gclp_NotEnd:
695 CMP AL, 0 // check for zero terminator at end of last parameter
696 JE gclp_Done // if found, we're finished
697
698 INC ECX // OK we have one more byte
699 JMP gclp_Loop // next please
700
701gclp_Done:
702 // now to remove quotes at start/end
703 CMP ECX, 0
704 JE gclp_NoQuotes // length is zero, can't be quotes
705
706 LEA EDI, pParam // Address of pParam
707 MOV EDI, [EDI] // Address of what pParam references
708 MOV ESI, [EDI] // get start of param
709
710 MOV AL, [ESI+ECX-1] // get last char
711 CMP AL, '"' // check if quote
712 JNE gclp_EndQuoteDone
713 DEC ECX // decrease length
714 CMP ECX, 0
715 JE gclp_StartQuoteDone // length is zero, can't be another quote
716gclp_EndQuoteDone:
717
718 LODSB // load first byte, inc ESI
719 CMP AL, '"' // check if quote
720 JNE gclp_StartQuoteDone
721 DEC ECX // quote, so decrease length
722 MOV [EDI], ESI // store new start of param
723gclp_StartQuoteDone:
724
725gclp_NoQuotes:
726 LEA EDI,ParamLength // address of ParamLength
727 MOV EDI, [EDI] // dereference
728 MOV [EDI],ECX // store length
729gclp_End:
730 END;
731END;
732
733function GetUserProfileString( const AppName: string;
734 const KeyName: string;
735 const Default: string ): string;
736var
737 Buffer: array[ 0..255 ] of char;
738 Len: longint;
739 i: longint;
740 szDefault: cstring;
741begin
742 szDefault := Default;
743 Len := PrfQueryProfileString( HINI_USERPROFILE, // user profile
744 AppName, // application
745 KeyName, // key
746 szDefault,
747 Buffer,
748 sizeof( Buffer ) );
749
750 // remove null terminator, if present
751 if Len > 0 then
752 if Buffer[ Len - 1 ] = #0 then
753 dec( Len );
754 Result := '';
755 for i := 0 to Len - 1 do
756 Result := Result + Buffer[ i ];
757end;
758
759Procedure SetUserProfileString( const AppName: string;
760 const KeyName: string;
761 const Value: string );
762begin
763 if not PrfWriteProfileString( HINI_USERPROFILE, // user profile
764 AppName, // application
765 KeyName, // key
766 Value ) then
767 raise Exception.Create(
768 'Error writing INI ['
769 + AppName
770 + '/'
771 + KeyName
772 + '] rc = '
773 + IntToHex( WinGetLastError( AppHandle ), 8 ) );
774end;
775
776procedure LoadDLLFunction( const DLLName: string;
777 const FunctionName: string;
778 var hDLL: HMODULE;
779 var F: pointer );
780var
781 ActualDLLName: string;
782 csErrorObject: cstring;
783 csFunctionName: cstring;
784 rc: APIRET;
785begin
786 F := nil;
787
788 if hDLL = NullHandle then
789 begin
790 ActualDLLName := GetApplicationDir + DLLName;
791 if not FileExists( ActualDLLName ) then
792 ActualDLLName := DLLName;
793
794 rc := DosLoadModule( csErrorObject,
795 sizeof( csErrorObject ),
796 ActualDLLName,
797 hDLL );
798 if rc <> 0 then
799 raise Exception.Create( DLLName
800 + ' could not be loaded: '
801 + SysErrorMessage( rc ) );
802
803 end;
804
805 csFunctionName := FunctionName;
806 rc := DosQueryProcAddr( hDLL,
807 0, // using by name
808 csFunctionName,
809 F );
810 if rc <> 0 then
811 raise Exception.Create( FunctionName
812 + ' in '
813 + DLLName
814 + ': '
815 + SysErrorMessage( rc ) );
816end;
817
818{$endif}
819
820const
821 LibVersion = 'V1.5.14'; // $SS_REQUIRE_NEW_VERSION$
822
823function GetACLLibraryVersion: string;
824begin
825 Result := LibVersion;
826end;
827
828Initialization
829End.
830
Note: See TracBrowser for help on using the repository browser.