📄 jwawintype.pas
字号:
LPRECT = ^RECT;
{$EXTERNALSYM LPRECT}
tagRECT = record
left: LONG;
top: LONG;
right: LONG;
bottom: LONG;
end;
{$EXTERNALSYM tagRECT}
RECT = {$IFDEF USE_DELPHI_TYPES}Windows.TRect{$ELSE}tagRECT{$ENDIF};
{$EXTERNALSYM RECT}
NPRECT = ^RECT;
{$EXTERNALSYM NPRECT}
LPCRECT = ^RECT;
{$EXTERNALSYM LPCRECT}
TRect = {$IFDEF USE_DELPHI_TYPES}Windows.TRect{$ELSE}RECT{$ENDIF};
PRect = {$IFDEF USE_DELPHI_TYPES}Windows.PRect{$ELSE}LPRECT{$ENDIF};
LPRECTL = ^RECTL;
{$EXTERNALSYM LPRECTL}
_RECTL = record
left: LONG;
top: LONG;
right: LONG;
bottom: LONG;
end;
{$EXTERNALSYM _RECTL}
RECTL = _RECTL;
{$EXTERNALSYM RECTL}
LPCRECTL = ^_RECTL;
{$EXTERNALSYM LPCRECTL}
TRectl = RECTL;
PRectl = LPRECTL;
LPPOINT = ^POINT;
{$EXTERNALSYM LPPOINT}
tagPOINT = record
x: LONG;
y: LONG;
end;
{$EXTERNALSYM tagPOINT}
NPPOINT = ^tagPoint;
{$EXTERNALSYM NPPOINT}
POINT = tagPOINT;
{$EXTERNALSYM tagPOINT}
TPoint = {$IFDEF USE_DELPHI_TYPES}Windows.TPoint{$ELSE}POINT{$ENDIF};
PPoint = {$IFDEF USE_DELPHI_TYPES}Windows.PPoint{$ELSE}LPPOINT{$ENDIF};
PPointl = ^POINTL;
_POINTL = record
x: LONG;
y: LONG;
end;
{$EXTERNALSYM _POINTL}
POINTL = _POINTL;
{$EXTERNALSYM POINTL}
TPointl = POINTL;
LPSIZE = ^TSize;
{$EXTERNALSYM LPSIZE}
{$IFDEF USE_DELPHI_TYPES}
TSize = Windows.TSize;
PSize = Windows.PSize;
{$ELSE}
tagSIZE = record
cx: LONG;
cy: LONG;
end;
{$EXTERNALSYM tagSIZE}
TSize = tagSIZE;
PSize = LPSIZE;
{$ENDIF}
SIZE = TSize;
{$EXTERNALSYM SIZE}
SIZEL = TSize;
{$EXTERNALSYM SIZEL}
PSIZEL = PSize;
{$EXTERNALSYM PSIZEL}
LPSIZEL = PSize;
{$EXTERNALSYM LPSIZEL}
LPPOINTS = ^POINTS;
{$EXTERNALSYM LPPOINTS}
tagPOINTS = record
x: SHORT;
y: SHORT;
end;
{$EXTERNALSYM tagPOINTS}
POINTS = tagPOINTS;
{$EXTERNALSYM POINTS}
TPoints = POINTS;
PPoints = LPPOINTS;
//
// File System time stamps are represented with the following structure:
//
{$IFNDEF _FILETIME_}
{$DEFINE _FILETIME_}
_FILETIME = record
dwLowDateTime: DWORD;
dwHighDateTime: DWORD;
end;
{$EXTERNALSYM _FILETIME}
FILETIME = _FILETIME;
{$EXTERNALSYM FILETIME}
PFILETIME = ^FILETIME;
{$EXTERNALSYM PFILETIME}
LPFILETIME = PFILETIME;
{$EXTERNALSYM LPFILETIME}
TFileTime = FILETIME;
{$ENDIF}
// mode selections for the device mode function
const
DM_UPDATE = 1;
{$EXTERNALSYM DM_UPDATE}
DM_COPY = 2;
{$EXTERNALSYM DM_COPY}
DM_PROMPT = 4;
{$EXTERNALSYM DM_PROMPT}
DM_MODIFY = 8;
{$EXTERNALSYM DM_MODIFY}
DM_IN_BUFFER = DM_MODIFY;
{$EXTERNALSYM DM_IN_BUFFER}
DM_IN_PROMPT = DM_PROMPT;
{$EXTERNALSYM DM_IN_PROMPT}
DM_OUT_BUFFER = DM_COPY;
{$EXTERNALSYM DM_OUT_BUFFER}
DM_OUT_DEFAULT = DM_UPDATE;
{$EXTERNALSYM DM_OUT_DEFAULT}
// device capabilities indices
DC_FIELDS = 1;
{$EXTERNALSYM DC_FIELDS}
DC_PAPERS = 2;
{$EXTERNALSYM DC_PAPERS}
DC_PAPERSIZE = 3;
{$EXTERNALSYM DC_PAPERSIZE}
DC_MINEXTENT = 4;
{$EXTERNALSYM DC_MINEXTENT}
DC_MAXEXTENT = 5;
{$EXTERNALSYM DC_MAXEXTENT}
DC_BINS = 6;
{$EXTERNALSYM DC_BINS}
DC_DUPLEX = 7;
{$EXTERNALSYM DC_DUPLEX}
DC_SIZE = 8;
{$EXTERNALSYM DC_SIZE}
DC_EXTRA = 9;
{$EXTERNALSYM DC_EXTRA}
DC_VERSION = 10;
{$EXTERNALSYM DC_VERSION}
DC_DRIVER = 11;
{$EXTERNALSYM DC_DRIVER}
DC_BINNAMES = 12;
{$EXTERNALSYM DC_BINNAMES}
DC_ENUMRESOLUTIONS = 13;
{$EXTERNALSYM DC_ENUMRESOLUTIONS}
DC_FILEDEPENDENCIES = 14;
{$EXTERNALSYM DC_FILEDEPENDENCIES}
DC_TRUETYPE = 15;
{$EXTERNALSYM DC_TRUETYPE}
DC_PAPERNAMES = 16;
{$EXTERNALSYM DC_PAPERNAMES}
DC_ORIENTATION = 17;
{$EXTERNALSYM DC_ORIENTATION}
DC_COPIES = 18;
{$EXTERNALSYM DC_COPIES}
//
// HALF_PTR is half the size of a pointer it intended for use with
// within strcuture which contain a pointer and two small fields.
// UHALF_PTR is the unsigned variation.
//
const
ADDRESS_TAG_BIT = DWORD($80000000);
{$EXTERNALSYM ADDRESS_TAG_BIT}
type
UHALF_PTR = Byte;
{$EXTERNALSYM UHALF_PTR}
PUHALF_PTR = ^UHALF_PTR;
{$EXTERNALSYM PUHALF_PTR}
HALF_PTR = Shortint;
{$EXTERNALSYM HALF_PTR}
PHALF_PTR = ^HALF_PTR;
{$EXTERNALSYM PHALF_PTR}
SHANDLE_PTR = Longint;
{$EXTERNALSYM SHANDLE_PTR}
HANDLE_PTR = Longint;
{$EXTERNALSYM HANDLE_PTR}
//
// SIZE_T used for counts or ranges which need to span the range of
// of a pointer. SSIZE_T is the signed variation.
//
SIZE_T = ULONG_PTR;
{$EXTERNALSYM SIZE_T}
PSIZE_T = ^SIZE_T;
{$EXTERNALSYM PSIZE_T}
SSIZE_T = LONG_PTR;
{$EXTERNALSYM SSIZE_T}
PSSIZE_T = ^SSIZE_T;
{$EXTERNALSYM PSSIZE_T}
//
// Add Windows flavor DWORD_PTR types
//
DWORD_PTR = ULONG_PTR;
{$EXTERNALSYM DWORD_PTR}
PDWORD_PTR = ^DWORD_PTR;
{$EXTERNALSYM PDWORD_PTR}
//
// The following types are guaranteed to be signed and 64 bits wide.
//
LONG64 = Int64;
{$EXTERNALSYM LONG64}
PLONG64 = ^LONG64;
{$EXTERNALSYM PLONG64}
PINT64 = ^Int64;
{$EXTERNALSYM PINT64}
//
// The following types are guaranteed to be unsigned and 64 bits wide.
//
ULONG64 = Int64;
{$EXTERNALSYM ULONG64}
PULONG64 = ^ULONG64;
{$EXTERNALSYM PULONG64}
DWORD64 = Int64;
{$EXTERNALSYM DWORD64}
PDWORD64 = ^DWORD64;
{$EXTERNALSYM PDWORD64}
UINT64 = Int64;
{$EXTERNALSYM UINT64}
PUINT64 = ^UINT64;
{$EXTERNALSYM PUINT64}
const
MAXUINT_PTR = not UINT_PTR(0);
{$EXTERNALSYM MAXUINT_PTR}
MAXINT_PTR = INT_PTR((MAXUINT_PTR shr 1));
{$EXTERNALSYM MAXINT_PTR}
MININT_PTR = not MAXINT_PTR;
{$EXTERNALSYM MININT_PTR}
MAXULONG_PTR = not ULONG_PTR(0);
{$EXTERNALSYM MAXULONG_PTR}
MAXLONG_PTR = LONG_PTR(MAXULONG_PTR shr 1);
{$EXTERNALSYM MAXLONG_PTR}
MINLONG_PTR = not MAXLONG_PTR;
{$EXTERNALSYM MINLONG_PTR}
MAXUHALF_PTR = UHALF_PTR( not 0);
{$EXTERNALSYM MAXUHALF_PTR}
MAXHALF_PTR = HALF_PTR(MAXUHALF_PTR shr 1);
{$EXTERNALSYM MAXHALF_PTR}
MINHALF_PTR = not MAXHALF_PTR;
{$EXTERNALSYM MINHALF_PTR}
// basetsd
type
INT8 = Shortint;
{$EXTERNALSYM INT8}
PINT8 = ^INT8;
{$EXTERNALSYM PINT8}
INT16 = Smallint;
{$EXTERNALSYM INT16}
PINT16 = ^INT16;
{$EXTERNALSYM PINT16}
UINT8 = Byte;
{$EXTERNALSYM UINT8}
PUINT8 = ^UINT8;
{$EXTERNALSYM PUINT8}
UINT16 = Word;
{$EXTERNALSYM UINT16}
PUINT16 = ^UINT16;
{$EXTERNALSYM PUINT16}
//
// Thread affinity.
//
KAFFINITY = ULONG_PTR;
{$EXTERNALSYM KAFFINITY}
PKAFFINITY = ^KAFFINITY;
{$EXTERNALSYM PKAFFINITY}
implementation
uses
JwaWinNT;
function Int32x32To64(a, b: LONG): LONGLONG;
begin
Result := a * b;
end;
function UInt32x32To64(a, b: DWORD): ULONGLONG;
begin
Result := a * b;
end;
function Int64ShllMod32(Value: ULONGLONG; ShiftCount: DWORD): ULONGLONG;
asm
MOV ECX, ShiftCount
MOV EAX, DWORD PTR [Value]
MOV EDX, DWORD PTR [Value + 4]
SHLD EDX, EAX, CL
SHL EAX, CL
end;
function Int64ShraMod32(Value: LONGLONG; ShiftCount: DWORD): LONGLONG;
asm
MOV ECX, ShiftCount
MOV EAX, DWORD PTR [Value]
MOV EDX, DWORD PTR [Value + 4]
SHRD EAX, EDX, CL
SAR EDX, CL
end;
function Int64ShrlMod32(Value: ULONGLONG; ShiftCount: DWORD): ULONGLONG;
asm
MOV ECX, ShiftCount
MOV EAX, DWORD PTR [Value]
MOV EDX, DWORD PTR [Value + 4]
SHRD EAX, EDX, CL
SHR EDX, CL
end;
procedure ListEntry32To64(l32: PLIST_ENTRY32; l64: PLIST_ENTRY64);
begin
l64^.Flink := l32^.Flink;
l64^.Blink := l32^.Blink;
end;
procedure ListEntry64To32(l64: PLIST_ENTRY64; l32: PLIST_ENTRY32);
begin
l32^.Flink := ULONG(l64^.Flink);
l32^.Blink := ULONG(l64^.Blink);
end;
function NT_SUCCESS(Status: NTSTATUS): BOOL;
begin
Result := Status >= 0;
end;
function NT_INFORMATION(Status: NTSTATUS): BOOL;
begin
Result := (ULONG(Status) shr 30) = 1;
end;
function NT_WARNING(Status: NTSTATUS): BOOL;
begin
Result := (ULONG(Status) shr 30) = 2;
end;
function NT_ERROR(Status: NTSTATUS): BOOL;
begin
Result := (ULONG(Status) shr 30) = 3;
end;
procedure InitializeObjectAttributes(p: POBJECT_ATTRIBUTES; n: PUNICODE_STRING;
a: ULONG; r: HANDLE; s: PVOID{PSECURITY_DESCRIPTOR});
begin
p^.Length := sizeof(OBJECT_ATTRIBUTES);
p^.RootDirectory := r;
p^.Attributes := a;
p^.ObjectName := n;
p^.SecurityDescriptor := s;
p^.SecurityQualityOfService := nil;
end;
function ARGUMENT_PRESENT(ArgumentPointer: Pointer): BOOL;
begin
Result := ArgumentPointer <> nil;
end;
function MAKEWORD(a, b: BYTE): WORD;
begin
Result := (b shl 8) or a;
end;
function MAKELONG(a, b: WORD): DWORD;
begin
Result := (b shl 16) or a;
end;
function LOWORD(L: DWORD): WORD;
begin
Result := L and $0000FFFF;
end;
function HIWORD(L: DWORD): WORD;
begin
Result := L shr 16;
end;
function LOBYTE(W: WORD): BYTE;
begin
Result := W and $FF;
end;
function HIBYTE(W: WORD): BYTE;
begin
Result := W shr 8;
end;
function GetModuleHandle(lpModuleName: LPCSTR): HMODULE; stdcall; external kernel32 name 'GetModuleHandleA';
function LoadLibrary(lpLibFileName: LPCSTR): HMODULE; stdcall; external kernel32 name 'LoadLibraryA';
function GetProcAddress(hModule: HMODULE; lpProcName: LPCSTR): FARPROC; stdcall; external kernel32 name 'GetProcAddress';
procedure GetProcedureAddress(var P: Pointer; const ModuleName, ProcName: string);
var
ModuleHandle: HMODULE;
begin
if not Assigned(P) then
begin
ModuleHandle := GetModuleHandle(PChar(ModuleName));
if ModuleHandle = 0 then
begin
ModuleHandle := LoadLibrary(PChar(ModuleName));
if ModuleHandle = 0 then raise EJwaLoadLibraryError.Create('Library not found: ' + ModuleName);
end;
P := GetProcAddress(ModuleHandle, PChar(ProcName));
if not Assigned(P) then raise EJwaGetProcAddressError.Create('Function not found: ' + ModuleName + '.' + ProcName);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -