home *** CD-ROM | disk | FTP | other *** search
- unit Win32Except;
-
- interface
-
- uses
- SysUtils, Windows, DB;
-
- type
- EWin32Error = class(Exception);
-
- procedure Win32Chk(Win32OK: Boolean);
-
- implementation
-
- const
- ERRORSIZE = 300; // Maximum error string size
-
- var
- Buffer: String;
-
- procedure Win32Chk(Win32OK: Boolean);
- begin
- if Win32OK = False then
- begin
- SetLength(Buffer, ERRORSIZE);
- if FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nil, GetLastError, 0, PChar(Buffer),
- ERRORSIZE, nil) = 0 then
- Buffer := 'Internal Error: Error creating Error String';
- SetLength(Buffer, StrLen(PChar(Buffer)));
- raise EWin32Error.Create(Buffer);
- end;
- end;
-
- end.
-