home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / memory.swg / 0060_RTM Functions.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-08-24  |  12.9 KB  |  239 lines

  1. Unit RtmApi;
  2. { Import unit for all new functions in RTM 1.5
  3.   written 06/20/94 by Peter Sawatzki }
  4. Interface
  5. Uses
  6.   WinTypes;
  7.  
  8. procedure FatalExit(Code: Integer);
  9. function GetVersion: LongInt;
  10. function LocalInit(Segment, Start, EndPos: Word): Bool;
  11. function LocalAlloc(Flags, Bytes: Word): THandle;
  12. function LocalReAlloc(Mem: THandle; Bytes, Flags: Word): THandle;
  13. function LocalFree(Mem: THandle): THandle;
  14. function LocalLock(Mem: THandle): Pointer;
  15. function LocalUnlock(Mem: THandle): Bool;
  16. function LocalSize(Mem: THandle): Word;
  17. function LocalHandle(Mem: Word): THandle;
  18. function LocalFlags(Mem: THandle): Word;
  19. function LocalCompact(MinFree: Word): Word;
  20. function LocalDiscard(Mem: THandle): THandle;
  21. {function LocalNotify(NotifyProc: TFarProc): TFarProc;}
  22. function GlobalAlloc(Flags: Word; Bytes: LongInt): THandle;
  23. function GlobalReAlloc(Mem: THandle; Bytes: LongInt; Flags: Word): THandle;
  24. function GlobalFree(Mem: THandle): THandle;
  25. function GlobalLock(Mem: THandle): Pointer;
  26. function GlobalUnlock(Mem: THandle): Bool;
  27. function UnlockResource(ResData: THandle): Bool;
  28. function GlobalSize(Mem: THandle): LongInt;
  29. function GlobalHandle(Mem: Word): LongInt;
  30. function GlobalFlags(Mem: THandle): Word;
  31. function LockSegment(Segment: Word): THandle;
  32. function UnlockSegment(Segment: Word): THandle;
  33. function GlobalCompact(MinFree: LongInt): LongInt;
  34. function GetCurrentTask: THandle;
  35. function GetModuleUsage(Module: THandle): Integer;
  36. function GetModuleFileName(Module: THandle; Filename: PChar; Size: Integer): Integer;
  37. function GetModuleHandle(ModuleName: PChar): THandle;
  38. function GetProcAddress(Module: THandle; ProcName: PChar): TFarProc;
  39. function Catch(var CatchBuf: TCatchBuf): Integer;
  40. procedure Throw(var CatchBuf: TCatchBuf; ThrowBack: Integer);
  41. function GetProfileInt(AppName, KeyName: PChar; Default: Integer): Word;
  42. function GetProfileString(AppName, KeyName, Default, ReturnedString: PChar; Size: Integer): Integer;
  43. function WriteProfileString(ApplicationName, KeyName, Str: PChar): Bool;
  44. function FindResource(Instance: THandle; Name, ResType: PChar): THandle;
  45. function LoadResource(Instance: THandle; ResInfo: THandle): THandle;
  46. function LockResource(ResData: THandle): Pointer;
  47. function FreeResource(ResData: THandle): Bool;
  48. function AccessResource(Instance, ResInfo: THandle): Integer;
  49. function SizeofResource(Instance, ResInfo: THandle): LongInt;
  50. function OpenFile(FileName: PChar; var ReOpenBuff: TOfStruct; Style: Word): Integer;
  51. function _lclose(FileHandle: Integer): Integer;
  52. function _lread(FileHandle: Integer; Buffer: PChar; Bytes: Integer): Word;
  53. function _lcreat(PathName: PChar; Atribute: Integer): Integer;
  54. function _llseek(FileHandle: Integer; Offset: LongInt; Origin: Integer): LongInt;
  55. function _lopen(PathName: PChar; ReadWrite: Integer): Integer;
  56. function _lwrite(FileHandle: Integer; Buffer: PChar; Bytes: Integer): Word;
  57. function LoadLibrary(LibFileName: PChar): THandle;
  58. procedure FreeLibrary(LibModule: THandle);
  59. procedure DOS3Call;
  60. procedure OutputDebugString(OutputString: PChar);
  61. function LocalShrink(Seg: THandle; Size: Word): Word;
  62. function GetPrivateProfileInt(ApplicationName, KeyName: PChar;
  63.                               Default: Integer; FileName: PChar): Word;
  64. function GetPrivateProfileString(ApplicationName, KeyName: PChar;
  65.                                  Default: PChar; ReturnedString: PChar;
  66.                                  Size: Integer; FileName: PChar): Integer;
  67. function WritePrivateProfileString(ApplicationName, KeyName, Str, FileName: PChar): Bool;
  68. function GetDOSEnvironment: PChar;
  69. function GetWinFlags: LongInt;
  70. Function GetExePtr (aHandle: tHandle): tHandle;
  71. function GetWindowsDirectory(Buffer: PChar; Size: Word): Word;
  72. function GetSystemDirectory(Buffer: PChar; Size: Word): Word;
  73. procedure GlobalNotify(NotifyProc: TFarProc);
  74. function GlobalLRUOldest(Mem: THandle): THandle;
  75. function GlobalLRUNewest(Mem: THandle): THandle;
  76. function GetFreeSpace(Flag: Word): LongInt;
  77. function AllocDStoCSAlias(Selector: Word): Word;
  78. function AllocSelector(Selector: Word): Word;
  79. function FreeSelector(Selector: Word): Word;
  80. function ChangeSelector(DestSelector, SourceSelector: Word): Word;
  81. function GlobalDosAlloc(Bytes: LongInt): LongInt;
  82. function GlobalDosFree(Selector: Word): Word;
  83. function GlobalPageLock(Selector: THandle): Word;
  84. function GlobalPageUnlock(Selector: THandle): Word;
  85. procedure GlobalFix(Mem: THandle);
  86. function GlobalUnfix(Mem: THandle): Bool;
  87. function AnsiUpper(Str: PChar): PChar;
  88. function AnsiLower(Str: PChar): PChar;
  89. function PrestoChangoSelector(SourceSel, DestSel: Word): Word;
  90. function GetSelectorBase(Selector: Word): Longint;
  91. function SetSelectorBase(Selector: Word; Base: Longint): Word;
  92. function GetSelectorLimit(Selector: Word): Longint;
  93. function SetSelectorLimit(Selector: Word; Base: Longint): Word;
  94. function LockData(Dummy: Integer): THandle;
  95. function UnlockData(Dummy: Integer): THandle;
  96. function GlobalDiscard(Mem: THandle): THandle;
  97.  
  98. {USER}
  99. function MessageBox(WndParent: HWnd; Txt, Caption: PChar; TextType: Word): Integer;
  100. function GetTickCount: LongInt;
  101. function GetCurrentTime: LongInt;
  102. function LoadString(Instance: THandle; ID: Word; Buffer: PChar; BufferMax: Integer): Integer;
  103. function _wsprintf(DestStr, Format: PChar; var ArgList): Integer; CDecl;
  104.  
  105. {KEYBOARD}
  106. function AnsiToOem(AnsiStr, OemStr: PChar): Integer;
  107. procedure AnsiToOemBuff(AnsiStr, OemStr: PChar; Length: Integer);
  108. function OemToAnsi(OemStr, AnsiStr: PChar): Bool;
  109. procedure OemToAnsiBuff(OemStr, AnsiStr: PChar; Length: Integer);
  110.  
  111. Implementation
  112.  
  113. function _LocalLock(Mem: THandle): Word; far; forward;
  114.  
  115. procedure FatalExit;                    external 'KERNEL'        Index 1;
  116. function GetVersion;                    external 'KERNEL'        Index 3;
  117. function LocalInit;                     external 'KERNEL'        Index 4;
  118. function LocalAlloc;                    external 'KERNEL'        Index 5;
  119. function LocalReAlloc;                  external 'KERNEL'        Index 6;
  120. function LocalFree;                     external 'KERNEL'        Index 7;
  121. function _LocalLock;                    external 'KERNEL'        Index 8;
  122. function LocalUnlock;                   external 'KERNEL'        Index 9;
  123. function LocalSize;                     external 'KERNEL'        Index 10;
  124. function LocalHandle;                   external 'KERNEL'        Index 11;
  125. function LocalFlags;                    external 'KERNEL'        Index 12;
  126. function LocalCompact;                  external 'KERNEL'        Index 13;
  127. {function LocalNotify;                   external 'KERNEL'       Index 14;}
  128. function GlobalAlloc;                   external 'KERNEL'        Index 15;
  129. function GlobalReAlloc;                 external 'KERNEL'        Index 16;
  130. function GlobalFree;                    external 'KERNEL'        Index 17;
  131. function GlobalLock;                    external 'KERNEL'        Index 18;
  132. function GlobalUnlock;                  external 'KERNEL'        Index 19;
  133. function UnlockResource;                external 'KERNEL'        Index 19;
  134. function GlobalSize;                    external 'KERNEL'        Index 20;
  135. function GlobalHandle;                  external 'KERNEL'        Index 21;
  136. function GlobalFlags;                   external 'KERNEL'        Index 22;
  137. function LockSegment;                   external 'KERNEL'        Index 23;
  138. function UnlockSegment;                 external 'KERNEL'        Index 24;
  139. function GlobalCompact;                 external 'KERNEL'        Index 25;
  140. function GetCurrentTask;                external 'KERNEL'        Index 36;
  141. function GetModuleHandle;               external 'KERNEL'        Index 47;
  142. function GetModuleUsage;                external 'KERNEL'        Index 48;
  143. function GetModuleFileName;             external 'KERNEL'        Index 49;
  144. function GetProcAddress;                external 'KERNEL'        Index 50;
  145. function Catch;                         external 'KERNEL'        Index 55;
  146. procedure Throw;                        external 'KERNEL'        Index 56;
  147. function GetProfileInt;                 external 'KERNEL'        Index 57;
  148. function GetProfileString;              external 'KERNEL'        Index 58;
  149. function WriteProfileString;            external 'KERNEL'        Index 59;
  150. function FindResource;                  external 'KERNEL'        Index 60;
  151. function LoadResource;                  external 'KERNEL'        Index 61;
  152. function LockResource;                  external 'KERNEL'        Index 62;
  153. function FreeResource;                  external 'KERNEL'        Index 63;
  154. function AccessResource;                external 'KERNEL'        Index 64;
  155. function SizeofResource;                external 'KERNEL'        Index 65;
  156. function OpenFile;                      external 'KERNEL'        Index 74;
  157. function _lclose;                       external 'KERNEL'        Index 81;
  158. function _lread;                        external 'KERNEL'        Index 82;
  159. function _lcreat;                       external 'KERNEL'        Index 83;
  160. function _llseek;                       external 'KERNEL'        Index 84;
  161. function _lopen;                        external 'KERNEL'        Index 85;
  162. function _lwrite;                       external 'KERNEL'        Index 86;
  163. function LoadLibrary;                   external 'KERNEL'        Index 95;
  164. procedure FreeLibrary;                  external 'KERNEL'        Index 96;
  165. procedure DOS3Call;                     external 'KERNEL'        Index 102;
  166. procedure OutputDebugString;            external 'KERNEL'        Index 115;
  167. function LocalShrink;                   external 'KERNEL'        Index 121;
  168. function GetPrivateProfileInt;          external 'KERNEL'        Index 127;
  169. function GetPrivateProfileString;       external 'KERNEL'        Index 128;
  170. function WritePrivateProfileString;     external 'KERNEL'        Index 129;
  171. function GetDOSEnvironment;             external 'KERNEL'        Index 131;
  172. function GetWinFlags;                   external 'KERNEL'        Index 132;
  173. function GetExePtr;                     external 'KERNEL'        Index 133;
  174. function GetWindowsDirectory;           external 'KERNEL'        Index 134;
  175. function GetSystemDirectory;            external 'KERNEL'        Index 135;
  176. procedure GlobalNotify;                 external 'KERNEL'        Index 154;
  177. function GlobalLRUOldest;               external 'KERNEL'        Index 163;
  178. function GlobalLRUNewest;               external 'KERNEL'        Index 164;
  179. function GetFreeSpace;                  external 'KERNEL'        Index 169;
  180. function AllocDStoCSAlias;              external 'KERNEL'        Index 171;
  181. function AllocSelector;                 external 'KERNEL'        Index 175;
  182. function FreeSelector;                  external 'KERNEL'        Index 176;
  183. function ChangeSelector;                external 'KERNEL'        Index 177;
  184. function GlobalDosAlloc;                external 'KERNEL'        Index 184;
  185. function GlobalDosFree;                 external 'KERNEL'        Index 185;
  186. function GlobalPageLock;                external 'KERNEL'        Index 191;
  187. function GlobalPageUnlock;              external 'KERNEL'        Index 192;
  188. procedure GlobalFix;                    external 'KERNEL'        Index 197;
  189. function GlobalUnfix;                   external 'KERNEL'        Index 198;
  190. function AnsiUpper;                     external 'KERNEL'        Index 431;
  191. function AnsiLower;                     external 'KERNEL'        Index 432;
  192. function PrestoChangoSelector;          external 'KERNEL'        Index 177;
  193. function GetSelectorBase;               external 'KERNEL'        Index 186;
  194. function SetSelectorBase;               external 'KERNEL'        Index 187;
  195. function GetSelectorLimit;              external 'KERNEL'        Index 188;
  196. function SetSelectorLimit;              external 'KERNEL'        Index 189;
  197.  
  198. function MessageBox;                    external 'USER'          Index 1;
  199. function GetTickCount;                  external 'USER'          Index 13;
  200. function GetCurrentTime;                external 'USER'          Index 15;
  201. function LoadString;                    external 'USER'          Index 176;
  202. function _wsprintf;                     external 'USER'          Index 420;
  203.  
  204. function AnsiToOem;                     external 'KEYBOARD'      Index 5;
  205. function OemToAnsi;                     external 'KEYBOARD'      Index 6;
  206. procedure AnsiToOemBuff;                external 'KEYBOARD'      Index 134;
  207. procedure OemToAnsiBuff;                external 'KEYBOARD'      Index 135;
  208.  
  209. { Various wrapper routines }
  210.  
  211. function LockData(Dummy: Integer): THandle;
  212. begin
  213.   LockData := LockSegment($FFFF);
  214. end;
  215.  
  216. function UnlockData(Dummy: Integer): THandle;
  217. begin
  218.   UnlockData := UnlockSegment($FFFF);
  219. end;
  220.  
  221. function GlobalDiscard(Mem: THandle): THandle;
  222. begin
  223.   GlobalDiscard := GlobalReAlloc(Mem, 0, gmem_Moveable);
  224. end;
  225.  
  226. function LocalDiscard(Mem: THandle): THandle;
  227. begin
  228.   LocalDiscard := LocalReAlloc(Mem, 0, lmem_Moveable);
  229. end;
  230.  
  231. function LocalLock(Mem: THandle): Pointer; assembler;
  232. asm
  233.         PUSH    Mem
  234.         CALL    _LocalLock
  235.         MOV     DX,DS
  236. end;
  237.  
  238. End.
  239.