home *** CD-ROM | disk | FTP | other *** search
/ PC World Plus! (NZ) 2001 June / HDC50.iso / Runimage / Delphi50 / Source / Rtl / Win / PSAPI.PAS < prev    next >
Pascal/Delphi Source File  |  1999-08-11  |  17KB  |  429 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Borland Delphi Run-time Library                 }
  5. {       WinNT process API Interface Unit                }
  6. {                                                       }
  7. {       Copyright (c) 1985-1999, Microsoft Corporation  }
  8. {                                                       }
  9. {       Translator: Inprise Corporation                 }
  10. {                                                       }
  11. {*******************************************************}
  12.  
  13. unit Psapi;
  14.  
  15. interface
  16.  
  17. {$WEAKPACKAGEUNIT}
  18.  
  19. uses Windows;
  20.  
  21. {$HPPEMIT '#include <psapi.h>'}
  22.  
  23. type
  24.   PPointer = ^Pointer;
  25.  
  26.   TEnumProcesses = function (lpidProcess: LPDWORD; cb: DWORD; var cbNeeded: DWORD): BOOL stdcall;
  27.   TEnumProcessModules = function (hProcess: THandle; lphModule: LPDWORD; cb: DWORD;
  28.     var lpcbNeeded: DWORD): BOOL stdcall;
  29.   TGetModuleBaseNameA = function (hProcess: THandle; hModule: HMODULE;
  30.     lpBaseName: PAnsiChar; nSize: DWORD): DWORD stdcall;
  31.   TGetModuleBaseNameW = function (hProcess: THandle; hModule: HMODULE;
  32.     lpBaseName: PWideChar; nSize: DWORD): DWORD stdcall;
  33.   TGetModuleBaseName = TGetModuleBaseNameA;
  34.   TGetModuleFileNameExA = function (hProcess: THandle; hModule: HMODULE;
  35.     lpFilename: PAnsiChar; nSize: DWORD): DWORD stdcall;
  36.   TGetModuleFileNameExW = function (hProcess: THandle; hModule: HMODULE;
  37.     lpFilename: PWideChar; nSize: DWORD): DWORD stdcall;
  38.   TGetModuleFileNameEx = TGetModuleFileNameExA;
  39.  
  40.   {$EXTERNALSYM _MODULEINFO}
  41.   _MODULEINFO = packed record
  42.     lpBaseOfDll: Pointer;
  43.     SizeOfImage: DWORD;
  44.     EntryPoint: Pointer;
  45.   end;
  46.   {$EXTERNALSYM MODULEINFO}
  47.   MODULEINFO = _MODULEINFO;
  48.   {$EXTERNALSYM LPMODULEINFO}
  49.   LPMODULEINFO = ^_MODULEINFO;
  50.   TModuleInfo = _MODULEINFO;
  51.   PModuleInfo = LPMODULEINFO;
  52.  
  53.   TGetModuleInformation = function (hProcess: THandle; hModule: HMODULE;
  54.     lpmodinfo: LPMODULEINFO; cb: DWORD): BOOL stdcall;
  55.   TEmptyWorkingSet = function (hProcess: THandle): BOOL stdcall;
  56.   TQueryWorkingSet = function (hProcess: THandle; pv: Pointer; cb: DWORD): BOOL stdcall;
  57.   TInitializeProcessForWsWatch = function (hProcess: THandle): BOOL stdcall;
  58.  
  59.   {$EXTERNALSYM _PSAPI_WS_WATCH_INFORMATION}
  60.   _PSAPI_WS_WATCH_INFORMATION = packed record
  61.     FaultingPc: Pointer;
  62.     FaultingVa: Pointer;
  63.   end;
  64.   {$EXTERNALSYM PSAPI_WS_WATCH_INFORMATION}
  65.   PSAPI_WS_WATCH_INFORMATION = _PSAPI_WS_WATCH_INFORMATION;
  66.   {$EXTERNALSYM PPSAPI_WS_WATCH_INFORMATION}
  67.   PPSAPI_WS_WATCH_INFORMATION = ^_PSAPI_WS_WATCH_INFORMATION;
  68.   TPSAPIWsWatchInformation = _PSAPI_WS_WATCH_INFORMATION;
  69.   PPSAPIWsWatchInformation = PPSAPI_WS_WATCH_INFORMATION;
  70.  
  71.   TGetWsChanges = function (hProcess: THandle; lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION;
  72.     cb: DWORD): BOOL stdcall;
  73.  
  74.   TGetMappedFileNameA = function (hProcess: THandle; lpv: Pointer;
  75.     lpFilename: PAnsiChar; nSize: DWORD): DWORD stdcall;
  76.   TGetMappedFileNameW = function (hProcess: THandle; lpv: Pointer;
  77.     lpFilename: PWideChar; nSize: DWORD): DWORD stdcall;
  78.   TGetMappedFileName = TGetMappedFileNameA;
  79.   TGetDeviceDriverBaseNameA = function (ImageBase: Pointer; lpBaseName: PAnsiChar;
  80.     nSize: DWORD): DWORD stdcall;
  81.   TGetDeviceDriverBaseNameW = function (ImageBase: Pointer; lpBaseName: PWideChar;
  82.     nSize: DWORD): DWORD stdcall;
  83.   TGetDeviceDriverBaseName = TGetDeviceDriverBaseNameA;
  84.   TGetDeviceDriverFileNameA = function (ImageBase: Pointer; lpFileName: PAnsiChar;
  85.     nSize: DWORD): DWORD stdcall;
  86.   TGetDeviceDriverFileNameW = function (ImageBase: Pointer; lpFileName: PWideChar;
  87.     nSize: DWORD): DWORD stdcall;
  88.   TGetDeviceDriverFileName = TGetDeviceDriverFileNameA;
  89.  
  90.   TEnumDeviceDrivers = function (lpImageBase: PPointer; cb: DWORD;
  91.     var lpcbNeeded: DWORD): BOOL stdcall;
  92.  
  93.   {$EXTERNALSYM _PROCESS_MEMORY_COUNTERS}
  94.   _PROCESS_MEMORY_COUNTERS = packed record
  95.     cb: DWORD;
  96.     PageFaultCount: DWORD;
  97.     PeakWorkingSetSize: DWORD;
  98.     WorkingSetSize: DWORD;
  99.     QuotaPeakPagedPoolUsage: DWORD;
  100.     QuotaPagedPoolUsage: DWORD;
  101.     QuotaPeakNonPagedPoolUsage: DWORD;
  102.     QuotaNonPagedPoolUsage: DWORD;
  103.     PagefileUsage: DWORD;
  104.     PeakPagefileUsage: DWORD;
  105.   end;
  106.   {$EXTERNALSYM PROCESS_MEMORY_COUNTERS}
  107.   PROCESS_MEMORY_COUNTERS = _PROCESS_MEMORY_COUNTERS;
  108.   {$EXTERNALSYM PPROCESS_MEMORY_COUNTERS}
  109.   PPROCESS_MEMORY_COUNTERS = ^_PROCESS_MEMORY_COUNTERS;
  110.   TProcessMemoryCounters = _PROCESS_MEMORY_COUNTERS;
  111.   PProcessMemoryCounters = ^_PROCESS_MEMORY_COUNTERS;
  112.  
  113.   TGetProcessMemoryInfo = function (Process: THandle;
  114.     ppsmemCounters: PPROCESS_MEMORY_COUNTERS; cb: DWORD): BOOL stdcall;
  115.  
  116. {$EXTERNALSYM EnumProcesses}
  117. function EnumProcesses(lpidProcess: LPDWORD; cb: DWORD; var cbNeeded: DWORD): BOOL;
  118. {$EXTERNALSYM EnumProcessModules}
  119. function EnumProcessModules(hProcess: THandle; lphModule: LPDWORD; cb: DWORD;
  120.   var lpcbNeeded: DWORD): BOOL;
  121. {$EXTERNALSYM GetModuleBaseNameA}
  122. function GetModuleBaseNameA(hProcess: THandle; hModule: HMODULE;
  123.   lpBaseName: PAnsiChar; nSize: DWORD): DWORD;
  124. {$EXTERNALSYM GetModuleBaseNameW}
  125. function GetModuleBaseNameW(hProcess: THandle; hModule: HMODULE;
  126.   lpBaseName: PWideChar; nSize: DWORD): DWORD;
  127. {$EXTERNALSYM GetModuleBaseName}
  128. function GetModuleBaseName(hProcess: THandle; hModule: HMODULE;
  129.   lpBaseName: PChar; nSize: DWORD): DWORD;
  130. {$EXTERNALSYM GetModuleFileNameExA}
  131. function GetModuleFileNameExA(hProcess: THandle; hModule: HMODULE;
  132.   lpFilename: PAnsiChar; nSize: DWORD): DWORD;
  133. {$EXTERNALSYM GetModuleFileNameExW}
  134. function GetModuleFileNameExW(hProcess: THandle; hModule: HMODULE;
  135.   lpFilename: PWideChar; nSize: DWORD): DWORD;
  136. {$EXTERNALSYM GetModuleFileNameEx}
  137. function GetModuleFileNameEx(hProcess: THandle; hModule: HMODULE;
  138.   lpFilename: PChar; nSize: DWORD): DWORD;
  139. {$EXTERNALSYM GetModuleInformation}
  140. function GetModuleInformation(hProcess: THandle; hModule: HMODULE;
  141.   lpmodinfo: LPMODULEINFO; cb: DWORD): BOOL;
  142. {$EXTERNALSYM EmptyWorkingSet}
  143. function EmptyWorkingSet(hProcess: THandle): BOOL;
  144. {$EXTERNALSYM QueryWorkingSet}
  145. function QueryWorkingSet(hProcess: THandle; pv: Pointer; cb: DWORD): BOOL;
  146. {$EXTERNALSYM InitializeProcessForWsWatch}
  147. function InitializeProcessForWsWatch(hProcess: THandle): BOOL;
  148. {$EXTERNALSYM GetMappedFileNameA}
  149. function GetMappedFileNameA(hProcess: THandle; lpv: Pointer;
  150.   lpFilename: PAnsiChar; nSize: DWORD): DWORD;
  151. {$EXTERNALSYM GetMappedFileNameW}
  152. function GetMappedFileNameW(hProcess: THandle; lpv: Pointer;
  153.   lpFilename: PWideChar; nSize: DWORD): DWORD;
  154. {$EXTERNALSYM GetMappedFileName}
  155. function GetMappedFileName(hProcess: THandle; lpv: Pointer;
  156.   lpFilename: PChar; nSize: DWORD): DWORD;
  157. {$EXTERNALSYM GetDeviceDriverBaseNameA}
  158. function GetDeviceDriverBaseNameA(ImageBase: Pointer; lpBaseName: PAnsiChar;
  159.   nSize: DWORD): DWORD;
  160. {$EXTERNALSYM GetDeviceDriverBaseNameW}
  161. function GetDeviceDriverBaseNameW(ImageBase: Pointer; lpBaseName: PWideChar;
  162.   nSize: DWORD): DWORD;
  163. {$EXTERNALSYM GetDeviceDriverBaseName}
  164. function GetDeviceDriverBaseName(ImageBase: Pointer; lpBaseName: PChar;
  165.   nSize: DWORD): DWORD;
  166. {$EXTERNALSYM GetDeviceDriverFileNameA}
  167. function GetDeviceDriverFileNameA(ImageBase: Pointer; lpFileName: PAnsiChar;
  168.   nSize: DWORD): DWORD;
  169. {$EXTERNALSYM GetDeviceDriverFileNameW}
  170. function GetDeviceDriverFileNameW(ImageBase: Pointer; lpFileName: PWideChar;
  171.   nSize: DWORD): DWORD;
  172. {$EXTERNALSYM GetDeviceDriverFileName}
  173. function GetDeviceDriverFileName(ImageBase: Pointer; lpFileName: PChar;
  174.   nSize: DWORD): DWORD;
  175. {$EXTERNALSYM EnumDeviceDrivers}
  176. function EnumDeviceDrivers(lpImageBase: PPointer; cb: DWORD;
  177.   var lpcbNeeded: DWORD): BOOL;
  178. {$EXTERNALSYM GetProcessMemoryInfo}
  179. function GetProcessMemoryInfo(Process: THandle;
  180.   ppsmemCounters: PPROCESS_MEMORY_COUNTERS; cb: DWORD): BOOL;
  181.  
  182. implementation
  183.  
  184. var
  185.   hPSAPI: THandle;
  186.   _EnumProcesses: TEnumProcesses;
  187.   _EnumProcessModules: TEnumProcessModules;
  188.   {procedure}_GetModuleBaseNameA: TGetModuleBaseNameA;
  189.   {procedure}_GetModuleFileNameExA: TGetModuleFileNameExA;
  190.   {procedure}_GetModuleBaseNameW: TGetModuleBaseNameW;
  191.   {procedure}_GetModuleFileNameExW: TGetModuleFileNameExW;
  192.   {procedure}_GetModuleBaseName: TGetModuleBaseNameA;
  193.   {procedure}_GetModuleFileNameEx: TGetModuleFileNameExA;
  194.   _GetModuleInformation: TGetModuleInformation;
  195.   _EmptyWorkingSet: TEmptyWorkingSet;
  196.   _QueryWorkingSet: TQueryWorkingSet;
  197.   _InitializeProcessForWsWatch: TInitializeProcessForWsWatch;
  198.   {procedure}_GetMappedFileNameA: TGetMappedFileNameA;
  199.   {procedure}_GetDeviceDriverBaseNameA: TGetDeviceDriverBaseNameA;
  200.   {procedure}_GetDeviceDriverFileNameA: TGetDeviceDriverFileNameA;
  201.   {procedure}_GetMappedFileNameW: TGetMappedFileNameW;
  202.   {procedure}_GetDeviceDriverBaseNameW: TGetDeviceDriverBaseNameW;
  203.   {procedure}_GetDeviceDriverFileNameW: TGetDeviceDriverFileNameW;
  204.   {procedure}_GetMappedFileName: TGetMappedFileNameA;
  205.   {procedure}_GetDeviceDriverBaseName: TGetDeviceDriverBaseNameA;
  206.   {procedure}_GetDeviceDriverFileName: TGetDeviceDriverFileNameA;
  207.   _EnumDeviceDrivers: TEnumDeviceDrivers;
  208.   _GetProcessMemoryInfo: TGetProcessMemoryInfo;
  209.  
  210. function CheckPSAPILoaded: Boolean;
  211. begin
  212.   if hPSAPI = 0 then
  213.   begin
  214.     hPSAPI := LoadLibrary('PSAPI.dll');
  215.     if hPSAPI < 32 then
  216.     begin
  217.       hPSAPI := 0;
  218.       Result := False;
  219.       Exit;
  220.     end;
  221.     @_EnumProcesses := GetProcAddress(hPSAPI, 'EnumProcesses');
  222.     @_EnumProcessModules := GetProcAddress(hPSAPI, 'EnumProcessModules');
  223.     {procedure}@_GetModuleBaseNameA := GetProcAddress(hPSAPI, 'GetModuleBaseNameA');
  224.     {procedure}@_GetModuleFileNameExA := GetProcAddress(hPSAPI, 'GetModuleFileNameExA');
  225.     {procedure}@_GetModuleBaseNameW := GetProcAddress(hPSAPI, 'GetModuleBaseNameW');
  226.     {procedure}@_GetModuleFileNameExW := GetProcAddress(hPSAPI, 'GetModuleFileNameExW');
  227.     {procedure}@_GetModuleBaseName := GetProcAddress(hPSAPI, 'GetModuleBaseNameA');
  228.     {procedure}@_GetModuleFileNameEx := GetProcAddress(hPSAPI, 'GetModuleFileNameExA');
  229.     @_GetModuleInformation := GetProcAddress(hPSAPI, 'GetModuleInformation');
  230.     @_EmptyWorkingSet := GetProcAddress(hPSAPI, 'EmptyWorkingSet');
  231.     @_QueryWorkingSet := GetProcAddress(hPSAPI, 'QueryWorkingSet');
  232.     @_InitializeProcessForWsWatch := GetProcAddress(hPSAPI, 'InitializeProcessForWsWatch');
  233.     {procedure}@_GetMappedFileNameA := GetProcAddress(hPSAPI, 'GetMappedFileNameA');
  234.     {procedure}@_GetDeviceDriverBaseNameA := GetProcAddress(hPSAPI, 'GetDeviceDriverBaseNameA');
  235.     {procedure}@_GetDeviceDriverFileNameA := GetProcAddress(hPSAPI, 'GetDeviceDriverFileNameA');
  236.     {procedure}@_GetMappedFileNameW := GetProcAddress(hPSAPI, 'GetMappedFileNameW');
  237.     {procedure}@_GetDeviceDriverBaseNameW := GetProcAddress(hPSAPI, 'GetDeviceDriverBaseNameW');
  238.     {procedure}@_GetDeviceDriverFileNameW := GetProcAddress(hPSAPI, 'GetDeviceDriverFileNameW');
  239.     {procedure}@_GetMappedFileName := GetProcAddress(hPSAPI, 'GetMappedFileNameA');
  240.     {procedure}@_GetDeviceDriverBaseName := GetProcAddress(hPSAPI, 'GetDeviceDriverBaseNameA');
  241.     {procedure}@_GetDeviceDriverFileName := GetProcAddress(hPSAPI, 'GetDeviceDriverFileNameA');
  242.     @_EnumDeviceDrivers := GetProcAddress(hPSAPI, 'EnumDeviceDrivers');
  243.     @_GetProcessMemoryInfo := GetProcAddress(hPSAPI, 'GetProcessMemoryInfo');
  244.   end;
  245.   Result := True;
  246. end;
  247.  
  248. function EnumProcesses(lpidProcess: LPDWORD; cb: DWORD; var cbNeeded: DWORD): BOOL;
  249. begin
  250.   if CheckPSAPILoaded then
  251.     Result := _EnumProcesses(lpidProcess, cb, cbNeeded)
  252.   else Result := False;
  253. end;
  254.  
  255. function EnumProcessModules(hProcess: THandle; lphModule: LPDWORD; cb: DWORD;
  256.   var lpcbNeeded: DWORD): BOOL;
  257. begin
  258.   if CheckPSAPILoaded then
  259.     Result := _EnumProcessModules(hProcess, lphModule, cb, lpcbNeeded)
  260.   else Result := False;
  261. end;
  262.  
  263. function GetModuleBaseNameA(hProcess: THandle; hModule: HMODULE;
  264.   lpBaseName: PAnsiChar; nSize: DWORD): DWORD;
  265. begin
  266.   if CheckPSAPILoaded then
  267.     Result := _GetModuleBaseNameA(hProcess, hModule, lpBaseName, nSize)
  268.   else Result := 0;
  269. end;
  270.  
  271. function GetModuleBaseNameW(hProcess: THandle; hModule: HMODULE;
  272.   lpBaseName: PWideChar; nSize: DWORD): DWORD;
  273. begin
  274.   if CheckPSAPILoaded then
  275.     Result := _GetModuleBaseNameW(hProcess, hModule, lpBaseName, nSize)
  276.   else Result := 0;
  277. end;
  278.  
  279. function GetModuleBaseName(hProcess: THandle; hModule: HMODULE;
  280.   lpBaseName: PChar; nSize: DWORD): DWORD;
  281. begin
  282.   if CheckPSAPILoaded then
  283.     Result := _GetModuleBaseName(hProcess, hModule, lpBaseName, nSize)
  284.   else Result := 0;
  285. end;
  286.  
  287. function GetModuleFileNameExA(hProcess: THandle; hModule: HMODULE;
  288.   lpFilename: PAnsiChar; nSize: DWORD): DWORD;
  289. begin
  290.   if CheckPSAPILoaded then
  291.     Result := _GetModuleFileNameExA(hProcess, hModule, lpFileName, nSize)
  292.   else Result := 0;
  293. end;
  294.  
  295. function GetModuleFileNameExW(hProcess: THandle; hModule: HMODULE;
  296.   lpFilename: PWideChar; nSize: DWORD): DWORD;
  297. begin
  298.   if CheckPSAPILoaded then
  299.     Result := _GetModuleFileNameExW(hProcess, hModule, lpFileName, nSize)
  300.   else Result := 0;
  301. end;
  302.  
  303. function GetModuleFileNameEx(hProcess: THandle; hModule: HMODULE;
  304.   lpFilename: PChar; nSize: DWORD): DWORD;
  305. begin
  306.   if CheckPSAPILoaded then
  307.     Result := _GetModuleFileNameEx(hProcess, hModule, lpFileName, nSize)
  308.   else Result := 0;
  309. end;
  310.  
  311. function GetModuleInformation(hProcess: THandle; hModule: HMODULE;
  312.   lpmodinfo: LPMODULEINFO; cb: DWORD): BOOL;
  313. begin
  314.   if CheckPSAPILoaded then
  315.     Result := _GetModuleInformation(hProcess, hModule, lpmodinfo, cb)
  316.   else Result := False;
  317. end;
  318.  
  319. function EmptyWorkingSet(hProcess: THandle): BOOL;
  320. begin
  321.   if CheckPSAPILoaded then
  322.     Result := _EmptyWorkingSet(hProcess)
  323.   else Result := False;
  324. end;
  325.  
  326. function QueryWorkingSet(hProcess: THandle; pv: Pointer; cb: DWORD): BOOL;
  327. begin
  328.   if CheckPSAPILoaded then
  329.     Result := _QueryWorkingSet(hProcess, pv, cb)
  330.   else Result := False;
  331. end;
  332.  
  333. function InitializeProcessForWsWatch(hProcess: THandle): BOOL;
  334. begin
  335.   if CheckPSAPILoaded then
  336.     Result := _InitializeProcessForWsWatch(hProcess)
  337.   else Result := False;
  338. end;
  339.  
  340. function GetMappedFileNameA(hProcess: THandle; lpv: Pointer;
  341.   lpFilename: PAnsiChar; nSize: DWORD): DWORD;
  342. begin
  343.   if CheckPSAPILoaded then
  344.     Result := _GetMappedFileNameA(hProcess, lpv, lpFileName, nSize)
  345.   else Result := 0;
  346. end;
  347.  
  348. function GetMappedFileNameW(hProcess: THandle; lpv: Pointer;
  349.   lpFilename: PWideChar; nSize: DWORD): DWORD;
  350. begin
  351.   if CheckPSAPILoaded then
  352.     Result := _GetMappedFileNameW(hProcess, lpv, lpFileName, nSize)
  353.   else Result := 0;
  354. end;
  355.  
  356. function GetMappedFileName(hProcess: THandle; lpv: Pointer;
  357.   lpFilename: PChar; nSize: DWORD): DWORD;
  358. begin
  359.   if CheckPSAPILoaded then
  360.     Result := _GetMappedFileName(hProcess, lpv, lpFileName, nSize)
  361.   else Result := 0;
  362. end;
  363.  
  364. function GetDeviceDriverBaseNameA(ImageBase: Pointer; lpBaseName: PAnsiChar;
  365.   nSize: DWORD): DWORD;
  366. begin
  367.   if CheckPSAPILoaded then
  368.     Result := _GetDeviceDriverBasenameA(ImageBase, lpBaseName, nSize)
  369.   else Result := 0;
  370. end;
  371.  
  372. function GetDeviceDriverBaseNameW(ImageBase: Pointer; lpBaseName: PWideChar;
  373.   nSize: DWORD): DWORD;
  374. begin
  375.   if CheckPSAPILoaded then
  376.     Result := _GetDeviceDriverBasenameW(ImageBase, lpBaseName, nSize)
  377.   else Result := 0;
  378. end;
  379.  
  380. function GetDeviceDriverBaseName(ImageBase: Pointer; lpBaseName: PChar;
  381.   nSize: DWORD): DWORD;
  382. begin
  383.   if CheckPSAPILoaded then
  384.     Result := _GetDeviceDriverBasename(ImageBase, lpBaseName, nSize)
  385.   else Result := 0;
  386. end;
  387.  
  388. function GetDeviceDriverFileNameA(ImageBase: Pointer; lpFileName: PAnsiChar;
  389.   nSize: DWORD): DWORD;
  390. begin
  391.   if CheckPSAPILoaded then
  392.     Result := _GetDeviceDriverFileNameA(ImageBase, lpFileName, nSize)
  393.   else Result := 0;
  394. end;
  395.  
  396. function GetDeviceDriverFileNameW(ImageBase: Pointer; lpFileName: PWideChar;
  397.   nSize: DWORD): DWORD;
  398. begin
  399.   if CheckPSAPILoaded then
  400.     Result := _GetDeviceDriverFileNameW(ImageBase, lpFileName, nSize)
  401.   else Result := 0;
  402. end;
  403.  
  404. function GetDeviceDriverFileName(ImageBase: Pointer; lpFileName: PChar;
  405.   nSize: DWORD): DWORD;
  406. begin
  407.   if CheckPSAPILoaded then
  408.     Result := _GetDeviceDriverFileName(ImageBase, lpFileName, nSize)
  409.   else Result := 0;
  410. end;
  411.  
  412. function EnumDeviceDrivers(lpImageBase: PPointer; cb: DWORD;
  413.   var lpcbNeeded: DWORD): BOOL;
  414. begin
  415.   if CheckPSAPILoaded then
  416.     Result := _EnumDeviceDrivers(lpImageBase, cb, lpcbNeeded)
  417.   else Result := False;
  418. end;
  419.  
  420. function GetProcessMemoryInfo(Process: THandle;
  421.   ppsmemCounters: PPROCESS_MEMORY_COUNTERS; cb: DWORD): BOOL;
  422. begin
  423.   if CheckPSAPILoaded then
  424.     Result := _GetProcessMemoryInfo(Process, ppsmemCounters, cb)
  425.   else Result := False;
  426. end;
  427.  
  428. end.
  429.