home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk14 / doc.pak / WINAPI.INT < prev    next >
Encoding:
Text File  |  1995-08-24  |  8.4 KB  |  252 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Runtime Library                          }
  5. {       DOS Protected-mode Interface Unit               }
  6. {                                                       }
  7. {       Copyright (c) 1991,94 Borland International     }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit WinAPI;
  12.  
  13. {$S-}
  14.  
  15. interface
  16.  
  17. { Generic types }
  18.  
  19. type
  20.   PStr     = PChar;
  21.   Bool     = WordBool;          { Windows compatible boolean }
  22.   THandle  = Word;              { Global memory handle }
  23.   TFarProc = Pointer;           { Procedure address }
  24.  
  25. type
  26.   PPoint = ^TPoint;
  27.   TPoint = record
  28.     X: Integer;
  29.     Y: Integer;
  30.   end;
  31.   MakePoint = TPoint;
  32.  
  33. type
  34.   PRect = ^TRect;
  35.   TRect = record
  36.     case Integer of
  37.       0: (Left, Top, Right, Bottom: Integer);
  38.       1: (TopLeft, BottomRight: TPoint);
  39.   end;
  40.  
  41. { Flags returned by GetWinFlags }
  42.  
  43. const
  44.   wf_PMode      = $00000001;    { Running in protected mode }
  45.   wf_CPU286     = $00000002;    { System CPU is an 80286 }
  46.   wf_CPU386     = $00000004;    { System CPU is an 80386 }
  47.   wf_CPU486     = $00000008;    { System CPU is an 80486 }
  48.   wf_Standard   = $00000010;    { Running in standard mode }
  49.   wf_Enhanced   = $00000020;    { Running in enhanced mode }
  50.   wf_CPU086     = $00000040;    { System CPU is an 8086 }
  51.   wf_CPU186     = $00000080;    { System CPU is an 80186 }
  52.   wf_LargeFrame = $00000100;    { Windows EMS large-frame configuration }
  53.   wf_SmallFrame = $00000200;    { Windows EMS small-frame configuration }
  54.   wf_80x87      = $00000400;    { System contains a math coprocessor }
  55.   wf_DPMI       = $80000000;    { Running in DOS protected mode }
  56.  
  57. { GlobalAlloc and GlobalReAlloc flags }
  58.  
  59. const
  60.   gmem_Fixed       = $0000;     { Allocate fixed memory }
  61.   gmem_Moveable    = $0002;     { Allocate moveable memory }
  62.   gmem_NoCompact   = $0010;     { Don't compact when allocating }
  63.   gmem_NoDiscard   = $0020;     { Don't discard when allocating }
  64.   gmem_ZeroInit    = $0040;     { Initialize memory contents to zero }
  65.   gmem_Modify      = $0080;     { Modify memory flags }
  66.   gmem_Discardable = $0100;     { Allocate discardable memory }
  67.   gmem_Not_Banked  = $1000;     { Allocate non-banked memory }
  68.   gmem_DDEShare    = $2000;     { Allocate sharable memory }
  69.   gmem_Notify      = $4000;     { Notify upon discarding }
  70.  
  71. { Flags returned by GlobalFlags (in addition to gmem_Discardable) }
  72.  
  73. const
  74.   gmem_Discarded = $4000;
  75.   gmem_LockCount = $00FF;
  76.  
  77. { MessageBox Flags }
  78.  
  79. const
  80.   mb_Ok               = $0000;
  81.   mb_OkCancel         = $0001;
  82.   mb_AbortRetryIgnore = $0002;
  83.   mb_YesNoCancel      = $0003;
  84.   mb_YesNo            = $0004;
  85.   mb_RetryCancel      = $0005;
  86.  
  87.   mb_IconHand         = $0010;
  88.   mb_IconStop         = $0010;
  89.   mb_IconQuestion     = $0020;
  90.   mb_IconExclamation  = $0030;
  91.   mb_IconAsterisk     = $0040;
  92.   mb_IconInformation  = $0040;
  93.  
  94.   mb_DefButton1       = $0000;
  95.   mb_DefButton2       = $0100;
  96.   mb_DefButton3       = $0200;
  97.  
  98.   mb_ApplModal        = $0000;
  99.   mb_SystemModal      = $1000;
  100.   mb_TaskModal        = $2000;
  101.  
  102.   mb_NoFocus          = $8000;
  103.  
  104.   mb_TypeMask         = $000F;
  105.   mb_IconMask         = $00F0;
  106.   mb_DefMask          = $0F00;
  107.   mb_ModeMask         = $3000;
  108.   mb_MiscMask         = $C000;
  109.  
  110. { MessageBox return values }
  111.  
  112. const
  113.   id_Ok     = 1;
  114.   id_Cancel = 2;
  115.   id_Abort  = 3;
  116.   id_Retry  = 4;
  117.   id_Ignore = 5;
  118.   id_Yes    = 6;
  119.   id_No     = 7;
  120.  
  121. type
  122.   MakeIntResource = PStr;
  123.  
  124. const
  125.   Difference = 11;
  126.  
  127. { Predefined Resource Types }
  128.  
  129. const
  130.   rt_Cursor      = MakeIntResource(1);
  131.   rt_Bitmap      = MakeIntResource(2);
  132.   rt_Icon        = MakeIntResource(3);
  133.   rt_Menu        = MakeIntResource(4);
  134.   rt_Dialog      = MakeIntResource(5);
  135.   rt_String      = MakeIntResource(6);
  136.   rt_FontDir     = MakeIntResource(7);
  137.   rt_Font        = MakeIntResource(8);
  138.   rt_Accelerator = MakeIntResource(9);
  139.   rt_RCData      = MakeIntResource(10);
  140.  
  141. { NOTE: if any new resource types are introduced above this point, }
  142. { then the value of Difference must be changed. }
  143. { (rt_Group_Cursor - rt_Cursor) must always be equal to Difference }
  144. { (rt_Group_Icon - rt_Icon) must always be equal to Difference }
  145.  
  146.   rt_Group_Cursor     = rt_Cursor + Difference;
  147.  
  148. { The value 13 is intentionally unused }
  149.  
  150.   rt_Group_Icon       = rt_Icon + Difference;
  151.  
  152. { Windows API routines }
  153.  
  154. function AccessResource(Instance, ResInfo: THandle): Integer;
  155. function AllocDStoCSAlias(Selector: Word): Word;
  156. function AllocSelector(Selector: Word): Word;
  157. function AnsiLower(Str: PChar): PChar;
  158. function AnsiLowerBuff(Str: PChar; Length: Word): Word;
  159. procedure AnsiToOem(AnsiStr, OemStr: PChar);
  160. procedure AnsiToOemBuff(AnsiStr, OemStr: PChar; Length: Word);
  161. function AnsiUpper(Str: PChar): PChar;
  162. function AnsiUpperBuff(Str: PChar; Length: Word): Word;
  163. function ChangeSelector(SourceSelector, DestSelector: Word): Word;
  164. procedure DOS3Call;
  165. procedure FatalExit(Code: Integer);
  166. function FindResource(Instance: THandle; Name, ResType: PChar): THandle;
  167. procedure FreeLibrary(LibModule: THandle);
  168. function FreeResource(ResData: THandle): Bool;
  169. function FreeSelector(Selector: Word): Word;
  170. function GetDOSEnvironment: PChar;
  171. function GetFreeSpace(Flag: Word): Longint;
  172. function GetModuleFileName(Module: THandle; Filename: PChar; Size: Integer): Integer;
  173. function GetModuleHandle(ModuleName: PChar): THandle;
  174. function GetModuleUsage(Module: THandle): Integer;
  175. function GetProcAddress(Module: THandle; ProcName: PChar): TFarProc;
  176. function GetSelectorBase(Selector: Word): Longint;
  177. function GetSelectorLimit(Selector: Word): Longint;
  178. function GetVersion: Longint;
  179. function GetWinFlags: Longint;
  180. function GlobalAlloc(Flags: Word; Bytes: Longint): THandle;
  181. function GlobalAllocPtr(Flags: Word; Bytes: Longint): Pointer; 
  182. function GlobalCompact(MinFree: Longint): Longint;
  183. function GlobalDiscard(Mem: THandle): THandle;
  184. function GlobalDosAlloc(Bytes: Longint): Longint;
  185. function GlobalDosFree(Selector: Word): Word;
  186. procedure GlobalFix(Mem: THandle);
  187. function GlobalFlags(Mem: THandle): Word;
  188. function GlobalFree(Mem: THandle): THandle;
  189. function GlobalFreePtr(P: Pointer): THandle;
  190. function GlobalHandle(Mem: Word): Longint;
  191. function GlobalLock(Mem: THandle): Pointer;
  192. function GlobalLRUNewest(Mem: THandle): THandle;
  193. function GlobalLRUOldest(Mem: THandle): THandle;
  194. procedure GlobalNotify(NotifyProc: TFarProc);
  195. function GlobalPageLock(Selector: THandle): Word;
  196. function GlobalPageUnlock(Selector: THandle): Word;
  197. function GlobalPtrHandle(P: Pointer): THandle;
  198. function GlobalReAlloc(Mem: THandle; Bytes: Longint; Flags: Word): THandle;
  199. function GlobalReAllocPtr(P: Pointer; Bytes: Longint; Flags: Word): Pointer;
  200. function GlobalSize(Mem: THandle): Longint;
  201. function GlobalUnfix(Mem: THandle): Bool;
  202. function GlobalUnlock(Mem: THandle): Bool;
  203. procedure hmemcpy(P1, P2: Pointer; L: Longint);
  204. function LoadLibrary(LibFileName: PChar): THandle;
  205. function LoadResource(Instance: THandle; ResInfo: THandle): THandle;
  206. function LoadString(Instance: THandle; ID: Word; Buffer: PChar;
  207.   BufferMax: Integer): Integer;
  208. function LockResource(ResData: THandle): Pointer;
  209. function LockSegment(Segment: Word): THandle;
  210. function lstrcmp(Str1, Str2: PChar): Integer;
  211. function lstrcmpi(Str1, Str2: PChar): Integer;
  212. function MessageBox(WndParent: THandle; Text, Caption: PChar;
  213.   TextType: Word): Integer;
  214. procedure OemToAnsi(OemStr, AnsiStr: PChar);
  215. procedure OemToAnsiBuff(OemStr, AnsiStr: PChar; Length: Word);
  216. function PrestoChangoSelector(SourceSelector, DestSelector: Word): Word;
  217. function SetSelectorBase(Selector: Word; Base: Longint): Word;
  218. function SetSelectorLimit(Selector: Word; Limit: Longint): Word;
  219. function SizeOfResource(Instance, ResInfo: THandle): Longint;
  220. function UnlockResource(ResData: THandle): Bool;
  221. function UnlockSegment(Segment: Word): THandle;
  222.  
  223. { Inline routines }
  224.  
  225. function MakeLong(A, B: Word): Longint;
  226. inline(
  227.   $5A/    { POP DX }
  228.   $58);   { POP AX }
  229.  
  230. function LoWord(A: Longint): Word;
  231. inline(
  232.   $58/    { POP AX }
  233.   $5A);   { POP DX }
  234.  
  235. function HiWord(A: Longint): Word;
  236. inline(
  237.   $5A/    { POP DX }
  238.   $58);   { POP AX }
  239.  
  240. function LoByte(A: Word): Byte;
  241. inline(
  242.   $58/       { POP AX    }
  243.   $32/$E4);  { XOR AH,AH }
  244.  
  245. function HiByte(A: Word): Byte;
  246. inline(
  247.   $58/       { POP AX    }
  248.   $8A/$C4/   { MOV AL,AH }
  249.   $32/$E4);  { XOR AH,AH }
  250.  
  251. implementation
  252.