Browse Source

+ started porting the win16 api units

git-svn-id: trunk@31533 -
nickysn 10 years ago
parent
commit
8610065db4
4 changed files with 195 additions and 0 deletions
  1. 3 0
      .gitattributes
  2. 17 0
      rtl/win16/win31.pp
  3. 94 0
      rtl/win16/winprocs.pp
  4. 81 0
      rtl/win16/wintypes.pp

+ 3 - 0
.gitattributes

@@ -9710,6 +9710,9 @@ rtl/win16/sysheap.inc svneol=native#text/plain
 rtl/win16/sysos.inc svneol=native#text/plain
 rtl/win16/sysosh.inc svneol=native#text/plain
 rtl/win16/system.pp svneol=native#text/plain
+rtl/win16/win31.pp svneol=native#text/plain
+rtl/win16/winprocs.pp svneol=native#text/plain
+rtl/win16/wintypes.pp svneol=native#text/plain
 rtl/win32/Makefile svneol=native#text/plain
 rtl/win32/Makefile.fpc svneol=native#text/plain
 rtl/win32/buildrtl.lpi svneol=native#text/plain

+ 17 - 0
rtl/win16/win31.pp

@@ -0,0 +1,17 @@
+unit win31;
+
+interface
+
+uses
+  wintypes;
+
+const
+  GFSR_SYSTEMRESOURCES = $0000;
+  GFSR_GDIRESOURCES    = $0001;
+  GFSR_USERRESOURCES   = $0002;
+
+function GetFreeSystemResources(SysResource: UINT): UINT; external 'USER';
+
+implementation
+
+end.

+ 94 - 0
rtl/win16/winprocs.pp

@@ -0,0 +1,94 @@
+unit winprocs;
+
+interface
+
+uses
+  wintypes;
+
+function LOBYTE(w: Word): Byte; inline;
+function HIBYTE(w: Word): Byte; inline;
+
+function LOWORD(l: LongInt): Word; inline;
+function HIWORD(l: LongInt): Word; inline;
+
+function MAKELONG(low, high: Word): LONG; inline;
+
+function MAKELPARAM(low, high: Word): LPARAM; inline;
+function MAKELRESULT(low, high: Word): LRESULT; inline;
+
+function MAKELP(sel, off: Word): FarPointer; inline;
+function SELECTOROF(lp: FarPointer): Word; inline;
+function OFFSETOF(lp: FarPointer): Word; inline;
+
+// FIELDOFFSET
+
+{ System Information }
+function GetVersion: DWORD; external 'KERNEL';
+
+function GetFreeSpace(Flag: UINT): DWORD; external 'KERNEL';
+function GetCurrentPDB: UINT; external 'KERNEL';
+
+function GetWindowsDirectory(Buffer: LPSTR; Size: UINT): UINT; external 'KERNEL';
+function GetSystemDirectory(Buffer: LPSTR; Size: UINT): UINT; external 'KERNEL';
+
+function GetWinFlags: DWORD; external 'KERNEL';
+
+function GetDOSEnvironment: LPSTR; external 'KERNEL';
+
+function GetCurrentTime: DWORD; external 'USER';
+function GetTickCount: DWORD; external 'USER';
+function GetTimerResolution: DWORD; external 'USER';
+
+implementation
+
+function LOBYTE(w: Word): Byte;
+begin
+  LOBYTE := Byte(w);
+end;
+
+function HIBYTE(w: Word): Byte;
+begin
+  HIBYTE := Byte(w shr 8);
+end;
+
+function LOWORD(l: LongInt): Word;
+begin
+  LOWORD := Word(l);
+end;
+
+function HIWORD(l: LongInt): Word;
+begin
+  HIWORD := Word(l shr 16);
+end;
+
+function MAKELONG(low, high: Word): LONG;
+begin
+  MAKELONG := low or (LongInt(high) shl 16);
+end;
+
+function MAKELPARAM(low, high: Word): LPARAM;
+begin
+  MAKELPARAM := MAKELONG(low, high);
+end;
+
+function MAKELRESULT(low, high: Word): LRESULT;
+begin
+  MAKELRESULT := MAKELONG(low, high);
+end;
+
+function MAKELP(sel, off: Word): FarPointer;
+begin
+  MAKELP := Ptr(sel, off);
+end;
+
+function SELECTOROF(lp: FarPointer): Word;
+begin
+  SELECTOROF:=HIWORD(LongInt(lp));
+end;
+
+function OFFSETOF(lp: FarPointer): Word;
+begin
+  OFFSETOF:=LOWORD(LongInt(lp));
+end;
+
+end.

+ 81 - 0
rtl/win16/wintypes.pp

@@ -0,0 +1,81 @@
+unit wintypes;
+
+interface
+
+type
+  Bool = WordBool;
+  
+  UINT = Word;
+  LONG = LongInt;
+  
+  WPARAM = UINT;
+  LPARAM = LONG;
+  LRESULT = LONG;
+  
+  { The Win16 C headers define the P-prefixed types - PSTR, etc. as near pointers.
+    Borland Pascal 7 defines them as far pointers (in other words, the same as the
+    LP-prefixed type - LPSTR)  We define them as the default pointer type for the
+    current memory model. This means we'll be BP7 compatible in the large memory
+    model (which is the only memory model supported by BP7).
+
+    Also, using memory models other than 'large' under win16 is somewhat nasty and
+    is better to be avoided. }
+  PSTR = ^Char;
+  NPSTR = ^Char; near;
+  LPSTR = ^Char; far;
+  LPCSTR = ^Char; far;
+  
+  { PBYTE is already defined in system }
+  LPBYTE = ^Byte; far;
+  
+  PINT = ^SmallInt;
+  LPINT = ^SmallInt; far;
+  
+  { PWORD is already defined in system }
+  LPWORD = ^Word; far;
+  
+  PLONG = ^LONG;
+  LPLONG = ^LONG; far;
+  
+  { PDWORD is already defined in system }
+  LPDWORD = ^DWORD; far;
+  
+  LPVOID = FarPointer;
+  
+  PHANDLE = ^THandle;
+  SPHANDLE = ^THandle; near;
+  LPHANDLE = ^THandle; far;
+  
+  HGLOBAL = THandle;
+  HLOCAL = THandle;
+  
+  TGlobalHandle = THandle;
+  TLocalHandle = THandle;
+  
+  ATOM = UINT;
+  TAtom = ATOM;
+  
+  HINST = THandle; { instead of HINSTANCE, to avoid conflict with var hInstance }
+  HMODULE = HINST;
+  
+const
+  { GetWinFlags result mask values }
+  WF_PMODE      = $0001;
+  WF_CPU286     = $0002;
+  WF_CPU386     = $0004;
+  WF_CPU486     = $0008;
+  WF_STANDARD   = $0010;
+  WF_WIN286     = $0010;
+  WF_ENHANCED   = $0020;
+  WF_WIN386     = $0020;
+  WF_CPU086     = $0040;
+  WF_CPU186     = $0080;
+  WF_LARGEFRAME = $0100;
+  WF_SMALLFRAME = $0200;
+  WF_80x87      = $0400;
+  WF_PAGING     = $0800;
+  WF_WLO        = $8000;
+
+implementation
+
+end.