📄 system.pas
字号:
Size: Cardinal;
end;
THeapBlockArray = array of THeapBlock;
TObjectArray = array of TObject;
function GetHeapBlocks: THeapBlockArray;
function FindObjects(AClass: TClass; FindDerived: Boolean): TObjectArray;
{ Inspector Query }
{$ENDIF}
{
When an exception is thrown, the exception object that is thrown is destroyed
automatically when the except clause which handles the exception is exited.
There are some cases in which an application may wish to acquire the thrown
object and keep it alive after the except clause is exited. For this purpose,
we have added the AcquireExceptionObject and ReleaseExceptionObject functions.
These functions maintain a reference count on the most current exception object,
allowing applications to legitimately obtain references. If the reference count
for an exception that is being thrown is positive when the except clause is exited,
then the thrown object is not destroyed by the RTL, but assumed to be in control
of the application. It is then the application's responsibility to destroy the
thrown object. If the reference count is zero, then the RTL will destroy the
thrown object when the except clause is exited.
}
function AcquireExceptionObject: Pointer;
procedure ReleaseExceptionObject;
{$IFDEF PC_MAPPED_EXCEPTIONS}
procedure GetUnwinder(var Dest: TUnwinder);
procedure SetUnwinder(const NewUnwinder: TUnwinder);
function IsUnwinderSet: Boolean;
//function SysRegisterIPLookup(ModuleHandle, StartAddr, EndAddr: LongInt; Context: Pointer; GOT: LongInt): LongBool;
{
Do NOT call these functions. They are for internal use only:
SysRegisterIPLookup
SysUnregisterIPLookup
BlockOSExceptions
UnblockOSExceptions
AreOSExceptionsBlocked
}
function SysRegisterIPLookup(StartAddr, EndAddr: LongInt; Context: Pointer; GOT: LongInt): LongBool;
procedure SysUnregisterIPLookup(StartAddr: LongInt);
//function SysAddressIsInPCMap(Addr: LongInt): Boolean;
function SysClosestDelphiHandler(Context: Pointer): LongWord;
procedure BlockOSExceptions;
procedure UnblockOSExceptions;
function AreOSExceptionsBlocked: Boolean;
{$ELSE}
// These functions are not portable. Use AcquireExceptionObject above instead
function RaiseList: Pointer; deprecated; { Stack of current exception objects }
function SetRaiseList(NewPtr: Pointer): Pointer; deprecated; { returns previous value }
{$ENDIF}
function ExceptObject: TObject;
function ExceptAddr: Pointer;
{
Coverage support. These are internal use structures referenced by compiler
helper functions for QA coverage support.
}
type
TCVModInfo = packed record
ModName: PChar;
LibName: PChar;
UserData: PChar;
end;
PCVModInfo = ^TCVModInfo;
{$EXTERNALSYM _CVR_PROBE}
procedure _CVR_PROBE(mi: PCVModInfo; probeNum: Cardinal); cdecl;
{$EXTERNALSYM _CVR_STMTPROBE}
function _CVR_STMTPROBE(mi: PCVModInfo; probeNum: Cardinal; TrueFalse: Cardinal): Boolean; cdecl;
procedure SetInOutRes(NewValue: Integer);
type
TAssertErrorProc = procedure (const Message, Filename: string;
LineNumber: Integer; ErrorAddr: Pointer);
TSafeCallErrorProc = procedure (ErrorCode: HResult; ErrorAddr: Pointer);
{$IFDEF DEBUG}
{
This variable is just for debugging the exception handling system. See
_DbgExcNotify for the usage.
}
var
ExcNotificationProc : procedure ( NotificationKind: Integer;
ExceptionObject: Pointer;
ExceptionName: PShortString;
ExceptionLocation: Pointer;
HandlerAddr: Pointer) = nil;
{$ENDIF}
var
DispCallByIDProc: Pointer;
ExceptProc: Pointer; { Unhandled exception handler }
ErrorProc: procedure (ErrorCode: Byte; ErrorAddr: Pointer); { Error handler procedure }
{$IFDEF MSWINDOWS}
ExceptClsProc: Pointer; { Map an OS Exception to a Delphi class reference }
ExceptObjProc: Pointer; { Map an OS Exception to a Delphi class instance }
RaiseExceptionProc: Pointer;
RTLUnwindProc: Pointer;
{$ENDIF}
ExceptionClass: TClass; { Exception base class (must be Exception) }
SafeCallErrorProc: TSafeCallErrorProc; { Safecall error handler }
AssertErrorProc: TAssertErrorProc; { Assertion error handler }
ExitProcessProc: procedure; { Hook to be called just before the process actually exits }
AbstractErrorProc: procedure; { Abstract method error handler }
HPrevInst: LongWord deprecated; { Handle of previous instance - HPrevInst cannot be tested for multiple instances in Win32}
MainInstance: LongWord; { Handle of the main(.EXE) HInstance }
MainThreadID: LongWord; { ThreadID of thread that module was initialized in }
IsLibrary: Boolean; { True if module is a DLL }
CmdShow: Integer platform; { CmdShow parameter for CreateWindow }
CmdLine: PChar platform; { Command line pointer }
InitProc: Pointer; { Last installed initialization procedure }
ExitCode: Integer = 0; { Program result }
ExitProc: Pointer; { Last installed exit procedure }
ErrorAddr: Pointer = nil; { Address of run-time error }
RandSeed: Longint = 0; { Base for random number generator }
IsConsole: Boolean; { True if compiled as console app }
IsMultiThread: Boolean; { True if more than one thread }
FileMode: Byte = 2; { Standard mode for opening files }
{$IFDEF LINUX}
FileAccessRights: Integer platform; { Default access rights for opening files }
ArgCount: Integer platform;
ArgValues: PPChar platform;
{$ENDIF}
Test8086: Byte; { CPU family (minus one) See consts below }
Test8087: Byte = 3; { assume 80387 FPU or OS supplied FPU emulation }
TestFDIV: Shortint; { -1: Flawed Pentium, 0: Not determined, 1: Ok }
Input: Text; { Standard input }
Output: Text; { Standard output }
ErrOutput: Text; { Standard error output }
envp: PPChar platform;
{$HPPEMIT 'struct TVarData;'}
VarClearProc: procedure (var v: TVarData) = nil; // for internal use only
VarAddRefProc: procedure (var v: TVarData) = nil; // for internal use only
VarCopyProc: procedure (var Dest: TVarData; const Source: TVarData) = nil; // for internal use only
VarToLStrProc: procedure (var Dest: AnsiString; const Source: TVarData) = nil; // for internal use only
VarToWStrProc: procedure (var Dest: WideString; const Source: TVarData) = nil; // for internal use only
const
CPUi386 = 2;
CPUi486 = 3;
CPUPentium = 4;
var
Default8087CW: Word = $1332;{ Default 8087 control word. FPU control
register is set to this value.
CAUTION: Setting this to an invalid value
could cause unpredictable behavior. }
HeapAllocFlags: Word platform = 2; { Heap allocation flags, gmem_Moveable }
DebugHook: Byte platform = 0; { 1 to notify debugger of non-Delphi exceptions
>1 to notify debugger of exception unwinding }
JITEnable: Byte platform = 0; { 1 to call UnhandledExceptionFilter if the exception
is not a Pascal exception.
>1 to call UnhandledExceptionFilter for all exceptions }
NoErrMsg: Boolean platform = False; { True causes the base RTL to not display the message box
when a run-time error occurs }
{$IFDEF LINUX}
{ CoreDumpEnabled = True will cause unhandled
exceptions and runtime errors to raise a
SIGABRT signal, which will cause the OS to
coredump the process address space. This can
be useful for postmortem debugging. }
CoreDumpEnabled: Boolean platform = False;
{$ENDIF}
type
(*$NODEFINE TTextLineBreakStyle*)
TTextLineBreakStyle = (tlbsLF, tlbsCRLF);
var { Text output line break handling. Default value for all text files }
DefaultTextLineBreakStyle: TTextLineBreakStyle = {$IFDEF LINUX} tlbsLF {$ENDIF}
{$IFDEF MSWINDOWS} tlbsCRLF {$ENDIF};
const
sLineBreak = {$IFDEF LINUX} #10 {$ENDIF} {$IFDEF MSWINDOWS} #13#10 {$ENDIF};
type
HRSRC = THandle;
TResourceHandle = HRSRC; // make an opaque handle type
HINST = THandle;
HMODULE = HINST;
HGLOBAL = THandle;
{$IFDEF ELF}
{ ELF resources }
function FindResource(ModuleHandle: HMODULE; ResourceName, ResourceType: PChar): TResourceHandle;
function LoadResource(ModuleHandle: HMODULE; ResHandle: TResourceHandle): HGLOBAL;
function SizeofResource(ModuleHandle: HMODULE; ResHandle: TResourceHandle): Integer;
function LockResource(ResData: HGLOBAL): Pointer;
function UnlockResource(ResData: HGLOBAL): LongBool;
function FreeResource(ResData: HGLOBAL): LongBool;
{$ENDIF}
{ Memory manager support }
procedure GetMemoryManager(var MemMgr: TMemoryManager);
procedure SetMemoryManager(const MemMgr: TMemoryManager);
function IsMemoryManagerSet: Boolean;
function SysGetMem(Size: Integer): Pointer;
function SysFreeMem(P: Pointer): Integer;
function SysReallocMem(P: Pointer; Size: Integer): Pointer;
var
AllocMemCount: Integer; { Number of allocated memory blocks }
AllocMemSize: Integer; { Total size of allocated memory blocks }
{$IFDEF MSWINDOWS}
function GetHeapStatus: THeapStatus; platform;
{$ENDIF}
{ Thread support }
type
TThreadFunc = function(Parameter: Pointer): Integer;
{$IFDEF LINUX}
TSize_T = Cardinal;
TSchedParam = record
sched_priority: Integer;
end;
pthread_attr_t = record
__detachstate,
__schedpolicy: Integer;
__schedparam: TSchedParam;
__inheritsched,
__scope: Integer;
__guardsize: TSize_T;
__stackaddr_set: Integer;
__stackaddr: Pointer;
__stacksize: TSize_T;
end;
{$EXTERNALSYM pthread_attr_t}
TThreadAttr = pthread_attr_t;
PThreadAttr = ^TThreadAttr;
TBeginThreadProc = function (Attribute: PThreadAttr;
ThreadFunc: TThreadFunc; Parameter: Pointer;
var ThreadId: Cardinal): Integer;
TEndThreadProc = procedure(ExitCode: Integer);
var
BeginThreadProc: TBeginThreadProc = nil;
EndThreadProc: TEndThreadProc = nil;
{$ENDIF}
{$IFDEF MSWINDOWS}
function BeginThread(SecurityAttributes: Pointer; StackSize: LongWord;
ThreadFunc: TThreadFunc; Parameter: Pointer; CreationFlags: LongWord;
var ThreadId: LongWord): Integer;
{$ENDIF}
{$IFDEF LINUX}
function BeginThread(Attribute: PThreadAttr; ThreadFunc: TThreadFunc;
Parameter: Pointer; var ThreadId: Cardinal): Integer;
{$ENDIF}
procedure EndThread(ExitCode: Integer);
{ Standard procedures and functions }
const
{ File mode magic numbers }
fmClosed = $D7B0;
fmInput = $D7B1;
fmOutput = $D7B2;
fmInOut = $D7B3;
{ Text file flags }
tfCRLF = $1; // Dos compatibility flag, for CR+LF line breaks and EOF checks
type
{ Typed-file and untyped-file record }
TFileRec = packed record (* must match the size the compiler generates: 332 bytes *)
Handle: Integer;
Mode: Word;
Flags: Word;
case Byte of
0: (RecSize: Cardinal); // files of record
1: (BufSize: Cardinal; // text files
BufPos: Cardinal;
BufEnd: Cardinal;
BufPtr: PChar;
OpenFunc: Pointer;
InOutFunc: Pointer;
FlushFunc: Pointer;
CloseFunc: Pointer;
UserData: array[1..32] of Byte;
Name: array[0..259] of Char; );
end;
{ Text file record structure used for Text files }
PTextBuf = ^TTextBuf;
TTextBuf = array[0..127] of Char;
TTextRec = packed record (* must match the size the compiler generates: 460 bytes *)
Handle: Integer; (* must overlay with TFileRec *)
Mode: Word;
Flags: Word;
BufSize: Cardinal;
BufPos: Cardinal;
BufEnd: Cardinal;
BufPtr: PChar;
OpenFunc: Pointer;
InOutFunc: Pointer;
FlushFunc: Pointer;
CloseFunc: Pointer;
UserData: array[1..32] of Byte;
Name: array[0..259] of Char;
Buffer: TTextBuf;
end;
TTextIOFunc = function (var F: TTextRec): Integer;
TFileIOFunc = function (var F: TFileRec): Integer;
procedure SetLineBreakStyle(var T: Text; Style: TTextLineBreakStyle);
procedure ChDir(const S: string); overload;
procedure ChDir(P: PChar); overload;
function Flush(var t: Text): Integer;
procedure _LGetDir(D: Byte; var S: string);
procedure _SGetDir(D: Byte; var S: ShortString);
function IOResult: Integer;
procedure MkDir(const S: string); overload;
procedure MkDir(P: PChar); overload;
procedure Move(const Source; var Dest; Count: Integer);
function ParamCount: Integer;
function ParamStr(Index: Integer): string;
procedure Randomize;
procedure RmDir(const S: string); overload;
procedure RmDir(P: PChar); overload;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -