home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 November / Chip_2002-11_cd1.bin / zkuste / delphi / unity / d56 / DW / DW10242.ZIP / SystemWorks.pas < prev   
Pascal/Delphi Source File  |  2002-07-07  |  58KB  |  1,793 lines

  1. (*------------------------------SystemWorks.pas--------------------------
  2.  V1.0.98 - 08.07.2002 current release
  3. *------------------------------------------------------------------------*)
  4. unit SystemWorks;
  5.  
  6. interface
  7.  
  8. uses Windows, Graphics;
  9.  
  10. type
  11.    TDWBootOption = (dwboNormal,        //Normaler Systemstart
  12.                     dwboFailSafe,      //Abgesicherter Modus
  13.                     dwboFailSaveNet);  //Abgesicherter Modus mit Netzwerk
  14.    TDWComPort  =   (dwcptCOM1,
  15.                     dwcptCOM2,
  16.                     dwcptCOM3,
  17.                     dwcptCOM4,
  18.                     dwcptCOM5,
  19.                     dwcptCOM6,
  20.                     dwcptCOM7,
  21.                     dwcptUnknown);
  22.    TDWDimension  = packed record
  23.                     Height,
  24.                     Width:              Integer;
  25.    end;
  26.    TDWFileFlags  = (dwffDebug,
  27.                     dwffInfoInferred,
  28.                     dwffPatched,
  29.                     dwffPrerelease,
  30.                     dwffPrivateBuild,
  31.                     dwffSpecialBuild);
  32.    TDWFileInfo = packed record
  33.                     dwSignature:        DWORD;
  34.                     dwStrucVersion:     DWORD;
  35.                     dwFileVersionMS:    DWORD;
  36.                     dwFileVersionLS:    DWORD;
  37.                     dwProductVersionMS: DWORD;
  38.                     dwProductVersionLS: DWORD;
  39.                     dwFileFlagsMask:    DWORD;
  40.                     dwFileFlags:        DWORD;
  41.                     dwFileOS:           DWORD;
  42.                     dwFileType:         DWORD;
  43.                     dwFileSubtype:      DWORD;
  44.                     dwFileDateMS:       DWORD;
  45.                     dwFileDateLS:       DWORD;
  46.                     dwFileLanguage:     Word;
  47.                     dwFileCharSet:      Word;
  48.                     dwComments,
  49.                     dwCompanyName,
  50.                     dwFileDescription,
  51.                     dwFileVersion,
  52.                     dwInternalName,
  53.                     dwLegalCopyright,
  54.                     dwLegalTrademarks,
  55.                     dwOriginalFilename,
  56.                     dwPrivateBuild,
  57.                     dwProductName,
  58.                     dwProductVersion,
  59.                     dwSpecialBuild:     String;
  60.    end;
  61.    TDWFileOS     = (dwfosDOS,
  62.                     dwfosDOS_Windows16,
  63.                     dwfosDOS_Windows32,
  64.                     dwfosNT,
  65.                     dwfosNT_Windows32,
  66.                     dwfosWindows16,
  67.                     dwfosWindows32,
  68.                     dwfosOS2_16,
  69.                     dwfosOS2_16_PM16,
  70.                     dwfosOS2_32,
  71.                     dwfosOS2_32_PM32,
  72.                     dwfosPM16,
  73.                     dwfosPM32,
  74.                     dwfosUnknown);
  75.    TDWFileOSSet   = Set of TDWFileOS;
  76.    TDWFileSubType= (dwfstCOMM,
  77.                     dwfstDisplay,
  78.                     dwfstFontRaster,
  79.                     dwfstFontTruetype,
  80.                     dwfstFontVector,
  81.                     dwfstInstallable,
  82.                     dwfstKeyboard,
  83.                     dwfstLanguage,
  84.                     dwfstMouse,
  85.                     dwfstNetwork,
  86.                     dwfstPrinter,
  87.                     dwfstSound,
  88.                     dwfstSystem,
  89.                     dwfstUnknown,
  90.                     dwfstVersionedPrinter);
  91.    TDWFileType   = (dwftApp,
  92.                     dwftDLL,
  93.                     dwftDRV,
  94.                     dwftFont,
  95.                     dwftStaticLib,
  96.                     dwftUnknown,
  97.                     dwftVXD);
  98.    TDWFixedFileInfo = packed record
  99.                     dwSignature:        DWORD;
  100.                     dwStrucVersion:     DWORD;
  101.                     dwFileVersionMS:    DWORD;
  102.                     dwFileVersionLS:    DWORD;
  103.                     dwProductVersionMS: DWORD;
  104.                     dwProductVersionLS: DWORD;
  105.                     dwFileFlagsMask:    DWORD;
  106.                     dwFileFlags:        DWORD;
  107.                     dwFileOS:           DWORD;
  108.                     dwFileType:         DWORD;
  109.                     dwFileSubtype:      DWORD;
  110.                     dwFileDateMS:       DWORD;
  111.                     dwFileDateLS:       DWORD;
  112.    end;
  113.    TDWLangCharSet = packed record
  114.                     dwLang,
  115.                     dwCharSet:          Word;
  116.    end;
  117.    TDWMenuAlignment =
  118.                    (dwmaLeft,          //Menⁿ links unter MenuItem
  119.                     dwmaRight);        //Menⁿ rechts unter MenuItem
  120.    TDWMinimizedWindowArrangement =
  121.                    (dwmwaBottomLeft,   //Unten links
  122.                     dwmwaBottomRight,  //Unten rechts
  123.                     dwmwaHide,         //Verborgen ( au▀erhalb sichtbarer Bereich )
  124.                     dwmwaTopLeft,      //Open links
  125.                     dwmwaTopRight);    //Oben rechts
  126.    TDWScreenType = (dwscrtAll,           //Jeder Bildschirm
  127.                     dwscrtDesktop,       //Alle, die ein Teil des Desktops sind
  128.                     dwscrtMirror,        //Alle, die einen Bildschirm spiegeln
  129.                     dwscrtModeSpruned,   //Grafikkarte kann mehr als der Monitor
  130.                     dwscrtPrimary,       //PrimΣre Grafikkarte
  131.                     dwscrtRemovable,     //Auswechselbare
  132.                     dwscrtVGA);          //VGA-kompatible
  133.    TDWScreenTypes = set of TDWScreenType;
  134.    TDWSpecialFolder =
  135.                    (dwspfAdminTools,
  136.                     dwspfAppData,
  137.                     dwspfRecycleBin,
  138.                     dwspfCommonAdminTools,
  139.                     dwspfCommonAppData,
  140.                     dwspfCommonDesktop,
  141.                     dwspfCommonDocuments,
  142.                     dwspfCommonFavorites,
  143.                     dwspfCommonMusic,
  144.                     dwspfCommonPictures,
  145.                     dwspfCommonProgramFiles,
  146.                     dwspfCommonPrograms,
  147.                     dwspfCommonStartmenu,
  148.                     dwspfCommonStartup,
  149.                     dwspfCommonTemplates,
  150.                     dwspfCommonVideo,
  151.                     dwspfControls,
  152.                     dwspfCookies,
  153.                     dwspfDesktop,
  154.                     dwspfDrives,
  155.                     dwspfFavorites,
  156.                     dwspfFonts,
  157.                     dwspfHistory,
  158.                     dwspfInternetCache,
  159.                     dwspfLocalAppData,
  160.                     dwspfMyMusic,
  161.                     dwspfMyPictures,
  162.                     dwspfMyVideo,
  163.                     dwspfNetHood,
  164.                     dwspfNetwork,
  165.                     dwspfPersonal,
  166.                     dwspfPrinters,
  167.                     dwspfPrintHood,
  168.                     dwspfProfile,
  169.                     dwspfProgramFiles,
  170.                     dwspfProgramFilesX86,
  171.                     dwspfPrograms,
  172.                     dwspfRecent,
  173.                     dwspfSendTo,
  174.                     dwspfStartMenu,
  175.                     dwspfStartUp,
  176.                     dwspfSystem,
  177.                     dwspfSystemX86,
  178.                     dwspfTemplates,
  179.                     dwspfWindows);
  180.    TDWACLineStatus =
  181.                    (dwalsOffline,
  182.                     dwalsOnline,
  183.                     dwalsUnknownState);
  184.    TDWBatteryState =
  185.                    (dwbtsHigh,
  186.                     dwbtsLow,
  187.                     dwbtsCritical,
  188.                     dwbtsCharging,
  189.                     dwbtsNoSystemBattery,
  190.                     dwbtsUnknownState);
  191.    TDWBatteryStates = set of TDWBatteryState;
  192.    TDWVersionBlock = packed record
  193.                     dwVersionMajor,
  194.                     dwVersionMinor:     Integer;
  195.    end;
  196.    TDWWindowsDialog =
  197.                    (dwwdAccessibilityProperties,
  198.                     dwwdBDEProperties,
  199.                     dwwdControlPanel,
  200.                     dwwdCopyFloppy,
  201.                     dwwdDialProperties,
  202.                     dwwdDisplayProperties,
  203.                     dwwdExecute,
  204.                     dwwdFindFiles,
  205.                     dwwdFontsProperties,
  206.                     dwwdGamecontrollerProperties,
  207.                     dwwdHardwareDetect,
  208.                     dwwdInternetProperties,
  209.                     dwwdKeyboardProperties,
  210.                     dwwdLocaleProperties,
  211.                     dwwdMailProperties,
  212.                     dwwdModemProperties,
  213.                     dwwdMouseProperties,
  214.                     dwwdMultimediaProperties,
  215.                     dwwdNetworkProperties,
  216.                     dwwdODBCProperties,
  217.                     dwwdPasswordsProperties,
  218.                     dwwdPowerManagementProperties,
  219.                     dwwdPrinterProperties,
  220.                     dwwdRASWizard,
  221.                     dwwdScanCamProperties,
  222.                     dwwdSoftwareProperties,
  223.                     dwwdSystemProperties,
  224.                     dwwdThemesProperties,
  225.                     dwwdTime,
  226.                     dwwdTweakUIProperties,
  227.                     dwwdWindowsShutdownDialog);
  228.    _devicemodeA_0500 = packed record
  229.       dmDeviceName: array [0..CCHDEVICENAME - 1] of AnsiChar;
  230.       dmSpecVersion: Word;
  231.       dmDriverVersion: Word;
  232.       dmSize: Word;
  233.       dmDriverExtra: Word;
  234.       dmFields: DWORD;
  235.       case Integer of // sequence rearranged (to have the biggest as last)
  236.         1: (dmPosition: TPointL; );
  237.         2: (dmDisplayOrientation: DWORD; );
  238.         3: (dmDisplayFixedOutput: DWORD; );
  239.         0: (
  240.           dmOrientation: SHORT;
  241.           dmPaperSize: SHORT;
  242.           dmPaperLength: SHORT;
  243.           dmPaperWidth: SHORT;
  244.           dmScale: SHORT;
  245.           dmCopies: SHORT;
  246.           dmDefaultSource: SHORT;
  247.           dmPrintQuality: SHORT; // );
  248.     { end; }
  249.       dmColor: SHORT;
  250.       dmDuplex: SHORT;
  251.       dmYResolution: SHORT;
  252.       dmTTOption: SHORT;
  253.       dmCollate: SHORT;
  254.       dmFormName: array [0..CCHFORMNAME - 1] of AnsiChar;
  255.       dmLogPixels: Word;
  256.       dmBitsPerPel: DWORD;
  257.       dmPelsWidth: DWORD;
  258.       dmPelsHeight: DWORD;
  259.       case Integer of
  260.         0: (dmDisplayFlags: DWORD; );
  261.         1: (dmNup: DWORD; // );
  262.     { end; }
  263.       dmDisplayFrequency: DWORD;
  264.       dmICMMethod: DWORD;
  265.       dmICMIntent: DWORD;
  266.       dmMediaType: DWORD;
  267.       dmDitherType: DWORD;
  268.       dmReserved1: DWORD;
  269.       dmReserved2: DWORD;
  270.       dmPanningWidth: DWORD;
  271.       dmPanningHeight: DWORD; ); ); // end of 'union's above
  272.     end;
  273.  
  274. (*V1.0.98*)
  275. function ActiveDesktopEnabled: Boolean;
  276. function AppExec(const CmdLine, CmdParams: String; const CmdShow: Integer): Boolean;
  277. function AppIsResponding(const ClassName: String; const TimeOut: Cardinal): Boolean;
  278. procedure AppRestart;
  279. function ComPortAvailable(const COMPort: TDWComPort): Boolean;
  280. procedure EmptyKeyboardQueue;
  281. procedure EmptyMouseQueue;
  282. procedure ExecAndWait(const FileName, Params: String; const CmdShow: Integer);
  283. procedure FileOpenWithDialog(const Filename: String);
  284. procedure FilePropertiesDialog(const Filename: String);
  285. function FontAdd(const FontFilename: String): Boolean;
  286. function FontRemove(const FontFilename: String): Boolean;
  287. function GetACLineStatus: TDWACLineStatus;
  288. function GetAssociatedProgram(const Ext: String): String;
  289. function GetBatteryFullLifeTime: Integer;
  290. function GetBatteryLifePercent: Byte;
  291. function GetBatteryLifeTime: Integer;
  292. function GetBatteryState: TDWBatteryStates;
  293. function GetIconDimension(const Filename: String; const Index: Integer): TDWDimension;
  294. function GetNumberOfIcons(const Filename: String): Integer;
  295. function GetSpecialFolder(const SpecialFolder: TDWSpecialFolder): String;
  296. function GetWindowsLanguageStr: String;
  297. procedure MinimizeAllWindows;
  298. procedure ProcessMessages;
  299. function ScreenColorDepth(const Index: Byte): Byte;
  300. function ScreenDeviceName(const Index: Byte): String;
  301. function ScreenDeviceString(const Index: Byte): String;
  302. function ScreenDeviceType(const Index: Byte): TDWScreenTypes;
  303. function ScreenFrequency(const Index: Byte): Integer;
  304. function ScreenMonitorName(const Index: Byte): String;
  305. function ScreenMonitorPosition(const Index: Byte; var Point: TPoint): Boolean;
  306. function ScreenMonitorString(const Index: Byte): String;
  307. function ScreenResolution(const Index: Byte): TDWDimension;
  308. procedure ShowDesktop;
  309. procedure ShowSpecialDialog(const SpecialDialog: TDWWindowsDialog);
  310. procedure ShowFormatDriveDialog(const Drive: Char);
  311. procedure StartNewBrowserWindow(const URL: string);
  312.  
  313. (*V1.0.97*)
  314. function GetFileCharSetName(const FileInfo: TDWFileInfo): String;
  315. function GetFileFlags(const FileInfo: TDWFileInfo): TDWFileFlags;
  316. function GetFileInfo(const Filename: String): TDWFileInfo;
  317. function GetFileLanguageName(const FileInfo: TDWFileInfo): String;
  318. function GetFileOS(const FileInfo: TDWFileInfo): TDWFileOSSet;
  319. function GetFileProductVersionMS(const FileInfo: TDWFileInfo): TDWVersionBlock;
  320. function GetFileProductVersionLS(const FileInfo: TDWFileInfo): TDWVersionBlock;
  321. function GetFileStrucVersion(const FileInfo: TDWFileInfo): TDWVersionBlock;
  322. function GetFileSubType(const FileInfo: TDWFileInfo): TDWFileSubType;
  323. function GetFileType(const FileInfo: TDWFileInfo): TDWFileType;
  324. function GetFileVersionLS(const FileInfo: TDWFileInfo): TDWVersionBlock;
  325. function GetFileVersionMS(const FileInfo: TDWFileInfo): TDWVersionBlock;
  326.  
  327. (*V1.0.96*)
  328. function ActiveCaptionGradientColor: TColor;
  329. function AvailablePageMemory: Int64;
  330. function AvailablePhysicalMemory: Int64;
  331. function AvailableVirtualMemory: Int64;
  332. function GetBootOption: TDWBootOption;
  333. procedure BuzzerSound(const Frequency: Word; const Delay: Cardinal);
  334. procedure DisableCaptionCloseButton(const FormHandle: THandle);
  335. function EmptyRecycleBin(const Confirmation, GUI, Sound: Boolean): Boolean;
  336. procedure EnableCaptionCloseButton(const FormHandle: THandle);
  337. function FilesInRecycleBin(var FileCount: Int64): Boolean;
  338. function GetCapsLock: Boolean;
  339. function GetMenuAlignment: TDWMenuAlignment;
  340. function GetMinimizedWindowArrangement: TDWMinimizedWindowArrangement;
  341. function GetMouseButtons: Integer;
  342. function GetNumLock: Boolean;
  343. function GetScrollLock: Boolean;
  344. //procedure GetVideoModes(var ModeList: TStringList);
  345. function HotLightColor: TColor;
  346. function InactiveCaptionGradientColor: TColor;
  347. function MemoryUsedPercentage: Integer;
  348. function MenuBarColor: TColor;
  349. function MenuHilightColor: TColor;
  350. function MouseButtonsSwaped: Boolean;
  351. function MouseIsPresent: Boolean;
  352. function MouseHasWheel: Boolean;
  353. function NetworkIsPresent: Boolean;
  354. function ScreenCount(const ScreenType: TDWScreenType): Integer;
  355. procedure SetCapsLock(const CapsLockOn: Boolean);
  356. procedure SetNumLock(const NumLockOn: Boolean);
  357. procedure SetScrollLock(const ScrollLockOn: Boolean);
  358. function SoundCardInstalled: Boolean;
  359. function TotalPageMemory: Int64;
  360. function TotalPhysicalMemory: Int64;
  361. function TotalVirtualMemory: Int64;
  362.  
  363. (*V1.0.95*)
  364. function CPUClock: Double;
  365. procedure MonitorOff;
  366. procedure MonitorOn;
  367. procedure SetSystemClock(Year, Month, Day, Hour, Minute, Second, MSecond: Integer);
  368.  
  369. implementation
  370.  
  371. uses SysUtils, Registry, MMSystem, OSWorks, Dialogs, Messages, DDEMan, ShellApi,
  372.      FileCtrl, StringWorks, MultiMon, ShlObj, ConvertWorks;
  373. const
  374.    DISPLAY_DEVICE_ACTIVE =              $00000001;
  375.    DISPLAY_DEVICE_ATTACHED_TO_DESKTOP = $00000001;
  376.    DISPLAY_DEVICE_MULTI_DRIVER =        $00000002;
  377.    DISPLAY_DEVICE_PRIMARY_DEVICE =      $00000004;
  378.    DISPLAY_DEVICE_MIRRORING_DRIVER =    $00000008;
  379.    DISPLAY_DEVICE_VGA_COMPATIBLE =      $00000010;
  380.    DISPLAY_DEVICE_REMOVABLE =           $00000020;
  381.    DISPLAY_DEVICE_MODESPRUNED =         $08000000;
  382.    DISPLAY_DEVICE_REMOTE =              $04000000;
  383.    DISPLAY_DEVICE_DISCONNECT =          $02000000;
  384.    ENUM_CURRENT_SETTINGS =              $FFFFFFFF;
  385.  
  386. function _FormatDriveDlg(h:hwnd;lw,df,op:word):
  387.           longint stdcall; external 'Shell32.dll' name 'SHFormatDrive';
  388.  
  389. procedure ShowFormatDriveDialog(const Drive: Char);
  390. begin
  391.    _FormatDriveDlg(0,Ord(UpCase(Drive))-65,$FFFF,0);
  392. end;
  393.  
  394. procedure ShowSpecialDialog(const SpecialDialog: TDWWindowsDialog);
  395.    procedure opencpl(const cpl: string);
  396.    begin
  397.       shellexecute(GetCurrentProcess,'open','rundll32.exe',
  398.          pchar('shell32.dll,Control_RunDLL'+#32+cpl),nil,sw_shownormal);
  399.    end;
  400. begin
  401.    case SpecialDialog of
  402.    dwwdCopyFloppy:
  403.       begin
  404.          ShellExecute(GetCurrentProcess,'open', 'rundll32.exe',
  405.                       PChar('diskcopy,DiskCopyRunDll'), nil, SW_SHOWNORMAL);
  406.       end;
  407.    dwwdHardwareDetect:
  408.       begin
  409.          ShellExecute(GetCurrentProcess, 'open','rundll32.exe',
  410.                          'sysdm.cpl,installdevice_rundll', nil, SW_SHOWNORMAL);
  411.       end;
  412.    dwwdControlPanel:
  413.       begin
  414.          ShellExecute(GetCurrentProcess, 'open','rundll32.exe',
  415.                          'shell32,Control_RunDLL', nil, SW_SHOWNORMAL);
  416.       end;
  417.    dwwdRASWizard:
  418.       begin
  419.          ShellExecute(GetCurrentProcess, 'open','rundll32.exe',
  420.                          'rnaui.dll,RnaWizard /1', nil, SW_SHOWNORMAL);
  421.       end;
  422.    dwwdWindowsShutdownDialog:
  423.       begin
  424.          PostMessage(FindWindow('Progman',nil), WM_CLOSE, 0, 0);
  425.       end;
  426.    dwwdExecute:
  427.       begin
  428.          keybd_event(VK_LWIN, MapVirtualKey(VK_LWIN, 0), 0, 0);
  429.          keybd_event(Ord('R'), MapVirtualKey(Ord('R'), 0), 0, 0);
  430.          keybd_event(Ord('R'), MapVirtualKey(Ord('R'), 0), KEYEVENTF_KEYUP, 0);
  431.          keybd_event(VK_LWIN, MapVirtualKey(VK_LWIN, 0), KEYEVENTF_KEYUP, 0);
  432.       end;
  433.    dwwdFindFiles:
  434.       begin
  435.          keybd_event(VK_LWIN, MapVirtualKey(VK_LWIN, 0), 0, 0);
  436.          keybd_event(Ord('F'), MapVirtualKey(Ord('F'), 0), 0, 0);
  437.          keybd_event(Ord('F'), MapVirtualKey(Ord('F'), 0), KEYEVENTF_KEYUP, 0);
  438.          keybd_event(VK_LWIN, MapVirtualKey(VK_LWIN, 0), KEYEVENTF_KEYUP, 0);
  439.       end;
  440.    dwwdTime:
  441.       begin
  442.          ShellExecute(GetCurrentProcess, 'open', 'control',
  443.                         'date/time', nil, SW_SHOW)
  444.       end;
  445.    dwwdMouseProperties:
  446.       begin
  447.          OpenCpl('MAIN.CPL @0');
  448.       end;
  449.    dwwdKeyboardProperties:
  450.       begin
  451.          OpenCpl('MAIN.CPL @1');
  452.       end;
  453.    dwwdPrinterProperties:
  454.       begin
  455.          OpenCpl('MAIN.CPL @2');
  456.       end;
  457.    dwwdFontsProperties:
  458.       begin
  459.          OpenCpl('MAIN.CPL @3');
  460.       end;
  461.    dwwdSoftwareProperties:
  462.       begin
  463.          OpenCpl('APPWIZ.CPL');
  464.       end;
  465.    dwwdDisplayProperties:
  466.       begin
  467.          OpenCpl('DESK.CPL');
  468.       end;
  469.    dwwdInternetProperties:
  470.       begin
  471.          OpenCpl('INETCPL.CPL');
  472.       end;
  473.    dwwdLocaleProperties:
  474.       begin
  475.          OpenCpl('INTL.CPL');
  476.       end;
  477.    dwwdMultimediaProperties:
  478.       begin
  479.          OpenCpl('MMSYS.CPL');
  480.       end;
  481.    dwwdModemProperties:
  482.       begin
  483.          OpenCpl('MODEM.CPL');
  484.       end;
  485.    dwwdNetworkProperties:
  486.       begin
  487.          OpenCpl('NETCPL.CPL');
  488.       end;
  489.    dwwdPasswordsProperties:
  490.       begin
  491.          OpenCpl('PASSWORD.CPL');
  492.       end;
  493.    dwwdScanCamProperties:
  494.       begin
  495.          OpenCpl('STICPL.CPL');
  496.       end;
  497.    dwwdSystemProperties:
  498.       begin
  499.          OpenCpl('SYSDM.CPL');
  500.       end;
  501.    dwwdDialProperties:
  502.       begin
  503.          OpenCpl('TELEPHON.CPL');
  504.       end;
  505.    dwwdGamecontrollerProperties:
  506.       begin
  507.          OpenCpl('JOY.CPL');
  508.       end;
  509.    dwwdAccessibilityProperties:
  510.       begin
  511.          OpenCpl('ACCESS.CPL');
  512.       end;
  513.    dwwdTweakUIProperties:
  514.       begin
  515.          OpenCpl('TWEAKUI.CPL');
  516.       end;
  517.    dwwdODBCProperties:
  518.       begin
  519.          OpenCpl('ODBCCP32.CPL');
  520.       end;
  521.    dwwdPowerManagementProperties:
  522.       begin
  523.          OpenCpl('POWERCFG.CPL');
  524.       end;
  525.    dwwdThemesProperties:
  526.       begin
  527.          OpenCpl('THEMES.CPL');
  528.       end;
  529.    dwwdBDEProperties:
  530.       begin
  531.          OpenCpl('BDEADMIN.CPL');
  532.       end;
  533.    dwwdMailProperties:
  534.       begin
  535.          OpenCpl('MLCFG32.CPL');
  536.       end;
  537.    end;
  538. end;
  539.  
  540. function GetSpecialFolder(const SpecialFolder: TDWSpecialFolder): String;
  541. var
  542.    pPath: PChar;
  543. begin
  544.    GetMem(pPath, MAX_PATH);
  545.    case SpecialFolder of
  546.    dwspfSystem:   GetSystemDirectory(pPath, MAX_PATH);
  547.    dwspfWindows:  GetWindowsDirectory(pPath, MAX_PATH);
  548.    else           SHGetSpecialFolderPath(GetCurrentProcess,
  549.                                          pPath,
  550.                                          SpecialFolderToCSIDL(SpecialFolder),
  551.                                          FALSE);
  552.    end;
  553.  
  554.    result:= IncludeTrailingBackslash(pPath);
  555.    FreeMem(pPath, MAX_PATH);
  556. end;
  557.  
  558. function ActiveDesktopEnabled: Boolean;
  559. var
  560.   h: HWND;
  561. begin
  562.   h := FindWindow('Progman', nil);
  563.   h := FindWindowEx(h, 0, 'SHELLDLL_DefView', nil);
  564.   h := FindWindowEx(h, 0, 'Internet Explorer_Server', nil);
  565.   Result := h <> 0;
  566. end;
  567.  
  568. function AppExec(const CmdLine, CmdParams: String; const CmdShow: Integer): Boolean;
  569. begin
  570.    result:= (ShellExecute(GetCurrentProcess,
  571.                          'open',
  572.                          PChar(CmdLine),
  573.                          PChar(CmdParams),
  574.                          '',
  575.                          CmdShow)>32);
  576. end;
  577.  
  578. function AppIsResponding(const ClassName: String; const TimeOut: Cardinal): Boolean;
  579. var
  580.   Res: DWORD;
  581.   h: HWND;
  582.   bClassFound,
  583.   bSendMessage: Boolean;
  584. begin
  585.   bSendMessage:= FALSE;
  586.   h:= FindWindow(PChar(ClassName), nil);
  587.   bClassFound:= (h <> 0);
  588.   if bClassFound then
  589.     bSendMessage:= (SendMessageTimeout(H,
  590.       WM_NULL,
  591.       0,
  592.       0,
  593.       SMTO_NORMAL or SMTO_ABORTIFHUNG,
  594.       TIMEOUT,
  595.       Res) <> 0);
  596.    result:= (bClassFound and bSendMessage);
  597. end;
  598.  
  599. procedure AppRestart;
  600. begin
  601.   AppExec(ParamStr(0), '', SW_SHOW);
  602.   TerminateProcess(GetCurrentProcess, 0);
  603. end;
  604.  
  605. function ComPortAvailable(const COMPort: TDWComPort): Boolean;
  606. var
  607.   DeviceName: array[0..80] of Char;
  608.   ComFile: THandle;
  609. begin
  610.   StrPCopy(DeviceName, ComPortToStr(COMPort));
  611.   ComFile := CreateFile(DeviceName, GENERIC_READ or GENERIC_WRITE, 0, nil,
  612.     OPEN_EXISTING,
  613.     FILE_ATTRIBUTE_NORMAL, 0);
  614.   Result := ComFile <> INVALID_HANDLE_VALUE;
  615.   CloseHandle(ComFile);
  616. end;
  617.  
  618. procedure EmptyKeyboardQueue;
  619. var
  620.   Msg: TMsg;
  621. begin
  622.   while PeekMessage(Msg, 0, WM_KEYFIRST, WM_KEYLAST,
  623.     PM_REMOVE or PM_NOYIELD) do;
  624. end;
  625.  
  626. procedure EmptyMouseQueue;
  627. var
  628.   Msg: TMsg;
  629. begin
  630.   while PeekMessage(Msg, 0, WM_MOUSEFIRST, WM_MOUSELAST,
  631.     PM_REMOVE or PM_NOYIELD) do;
  632. end;
  633.  
  634. procedure ExecAndWait(const FileName, Params: String; const CmdShow: Integer);
  635. var
  636.   exInfo: TShellExecuteInfo;
  637.   Ph: DWORD;
  638. begin
  639.   FillChar(exInfo, SizeOf(exInfo), 0);
  640.   with exInfo do
  641.   begin
  642.     cbSize := SizeOf(exInfo);
  643.     fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT;
  644.     Wnd := GetActiveWindow();
  645.     ExInfo.lpVerb := 'open';
  646.     ExInfo.lpParameters := PChar(Params);
  647.     lpFile := PChar(FileName);
  648.     nShow := CmdShow;
  649.   end;
  650.   if ShellExecuteEx(@exInfo) then
  651.     Ph := exInfo.HProcess
  652.   else
  653.   begin
  654.     ShowMessage(SysErrorMessage(GetLastError));
  655.     Exit;
  656.   end;
  657.   while WaitForSingleObject(ExInfo.hProcess, 50) <> WAIT_OBJECT_0 do
  658.     ProcessMessages;
  659.   CloseHandle(Ph);
  660. end;
  661.  
  662. function GetBatteryLifePercent: Byte;
  663. var
  664.    Sps: TSystemPowerStatus;
  665. begin
  666.    GetSystemPowerStatus(Sps);
  667.    result:= Sps.BatteryLifePercent;
  668. end;
  669.  
  670. function GetBatteryLifeTime: Integer;
  671. var
  672.    Sps: TSystemPowerStatus;
  673. begin
  674.    GetSystemPowerStatus(Sps);
  675.    result:= Sps.BatteryLifeTime;
  676. end;
  677.  
  678. function GetBatteryFullLifeTime: Integer;
  679. var
  680.    Sps: TSystemPowerStatus;
  681. begin
  682.    GetSystemPowerStatus(Sps);
  683.    result:= Sps.BatteryFullLifeTime;
  684. end;
  685.  
  686. function GetBatteryState: TDWBatteryStates;
  687. var
  688.    Sps: TSystemPowerStatus;
  689. begin
  690.    GetSystemPowerStatus(Sps);
  691.    with Sps do begin
  692.       if ((BatteryFlag and 1) = 1) then Include(result, dwbtsHigh);
  693.       if ((BatteryFlag and 2) = 2) then Include(result, dwbtsLow);
  694.       if ((BatteryFlag and 4) = 4) then Include(result, dwbtsCritical);
  695.       if ((BatteryFlag and 8) = 8) then Include(result, dwbtsCharging);
  696.       if ((BatteryFlag and 128) = 128) then Include(result, dwbtsNoSystemBattery);
  697.       if ((BatteryFlag and 255) = 255) then Include(result, dwbtsUnknownState);
  698.    end;
  699. end;
  700.  
  701. function GetIconDimension(const Filename: String; const Index: Integer): TDWDimension;
  702. var
  703.    iIcon: TIcon;
  704. begin
  705.    iIcon:= TIcon.Create;
  706.    iIcon.Handle:= ExtractIcon(GetCurrentProcess, PChar(Filename), Index);
  707.    with result do begin
  708.       Height:= iIcon.Height;
  709.       Width:=  iIcon.Width;
  710.    end;
  711.    iIcon.free;
  712. end;
  713.  
  714. function GetNumberOfIcons(const Filename: String): Integer;
  715. begin
  716.    result:= ExtractIcon(GetCurrentProcess, PChar(Filename), UINT(-1));
  717. end;
  718.  
  719. function GetWindowsLanguageStr: String;
  720. var
  721.   WinLanguage: array [0..50] of char;
  722. begin
  723.   VerLanguageName(GetSystemDefaultLangID, WinLanguage, 50);
  724.   Result := StrPas(WinLanguage);
  725. end;
  726.  
  727. procedure ProcessMessages;
  728. var
  729.   Msg: TMsg;
  730. begin
  731.   while PeekMessage(Msg, GetCurrentProcess, 0, 0, PM_REMOVE) do
  732.     //if not IsDialogMessage(Dlg, Msg) then
  733.     begin
  734.       TranslateMessage(Msg);
  735.       DispatchMessage(Msg);
  736.     end;
  737. end;
  738.  
  739. procedure FileOpenWithDialog(const Filename: String);
  740. begin
  741.   ShellExecute(GetCurrentProcess, 'open', PChar('rundll32.exe'),
  742.     PChar('shell32.dll,OpenAs_RunDLL ' + FileName), nil, SW_SHOWNORMAL);
  743. end;
  744.  
  745. procedure FilePropertiesDialog(const Filename: String);
  746. var
  747.   sei: TShellExecuteInfo;
  748. begin
  749.   FillChar(sei, SizeOf(sei), 0);
  750.   sei.cbSize := SizeOf(sei);
  751.   sei.lpFile := PChar(FileName);
  752.   sei.lpVerb := 'properties';
  753.   sei.fMask  := SEE_MASK_INVOKEIDLIST;
  754.   ShellExecuteEx(@sei);
  755. end;
  756.  
  757. function FontAdd(const FontFilename: String): Boolean;
  758. begin
  759.   result:= (AddFontResource(PChar(ExtractFilePath(ParamStr(0) + FontFilename)))<>0);
  760.   SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
  761. end;
  762.  
  763. function FontRemove(const FontFilename: String): Boolean;
  764. begin
  765.   result:= RemoveFontResource(PChar(ExtractFilePath(ParamStr(0) + FontFilename)));
  766.   SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
  767. end;
  768.  
  769. procedure StartNewBrowserWindow(const URL: string);
  770. var
  771.   DDEConv: TDDEClientConv;
  772.   URLFired: bool;
  773.   App: string;
  774.   UpApp: string;
  775.   p: array[0..MAX_PATH] of Char;
  776. begin
  777.   UrlFired := False;
  778.   App := GetAssociatedProgram('HTM');
  779.   UpApp := Uppercase(App);
  780.   Delete(App, Pos('.EXE', UpAPP), Length(App));
  781.   if Pos('NETSCAPE.EXE',
  782.     UpApp) > 0 then
  783.   begin
  784.     DDEConv := TDDEClientConv.Create(nil);
  785.     DDEConv.ServiceApplication := App;
  786.     if DDEConv.SetLink('NETSCAPE', 'WWW_OpenURL') then
  787.       if DDEConv.RequestData(URL + ',,0x0,0x0') <> nil then
  788.         if DDEConv.SetLink('NETSCAPE', 'WWW_Activate') then
  789.           URLFired := DDEConv.RequestData('0xFFFFFFFF,0x0') <> nil;
  790.     DDEConv.Free;
  791.   end
  792.   else if Pos('IEXPLORE.EXE',
  793.     UpApp) > 0 then 
  794.   begin
  795.     DDEConv := TDDEClientConv.Create(nil);
  796.     DDEConv.ServiceApplication := App;
  797.     if DDEConv.SetLink('iexplore', 'WWW_OpenURL') then
  798.       if DDEConv.RequestData(URL + ',,0') <> nil then
  799.         if DDEConv.SetLink('iexplore', 'WWW_Activate') then
  800.           URLFired := DDEConv.RequestData('0,0') <> nil;
  801.     DDEConv.Free;
  802.   end;
  803.   if UrlFired = False then
  804.     WinExec(StrPCopy(@p, URL), SW_SHOWNORMAL);
  805. end;
  806.  
  807. procedure MinimizeAllWindows;
  808. begin
  809.    keybd_event(VK_LWIN, MapVirtualKey(VK_LWIN, 0), 0, 0);
  810.    keybd_event(Ord('M'), MapVirtualKey(Ord('M'), 0), 0, 0);
  811.    keybd_event(Ord('M'), MapVirtualKey(Ord('M'), 0), KEYEVENTF_KEYUP, 0);
  812.    keybd_event(VK_LWIN, MapVirtualKey(VK_LWIN, 0), KEYEVENTF_KEYUP, 0);
  813. end;
  814.  
  815. procedure ShowDesktop;
  816. begin
  817.    keybd_event(VK_LWIN, MapVirtualKey(VK_LWIN, 0), 0, 0);
  818.    keybd_event(Ord('D'), MapVirtualKey(Ord('D'), 0), 0, 0);
  819.    keybd_event(Ord('D'), MapVirtualKey(Ord('D'), 0), KEYEVENTF_KEYUP, 0);
  820.    keybd_event(VK_LWIN, MapVirtualKey(VK_LWIN, 0), KEYEVENTF_KEYUP, 0);
  821. end;
  822.  
  823. function GetACLineStatus: TDWACLineStatus;
  824. var
  825.    Sps: TSystemPowerStatus;
  826. begin
  827.    GetSystemPowerStatus(Sps);
  828.    case Sps.ACLineStatus of
  829.    0:   result:= dwalsOffline;
  830.    1:   result:= dwalsOnline;
  831.    else result:= dwalsUnknownState;
  832.    end;
  833. end;
  834.  
  835. function GetAssociatedProgram(const Ext: String): String;
  836. var
  837.   {$IFDEF WIN32}
  838.   reg: TRegistry;
  839.   s: string;
  840.   {$ELSE}
  841.   WinIni: TIniFile;
  842.   WinIniFileName: array[0..MAX_PATH] of Char;
  843.   s: string;
  844.   {$ENDIF}
  845. begin
  846.   {$IFDEF WIN32}
  847.   s := '';
  848.   reg := TRegistry.Create;
  849.   reg.RootKey := HKEY_CLASSES_ROOT;
  850.   if reg.OpenKey('.' + ext + '\shell\open\command',
  851.     False) <> False then 
  852.   begin
  853.     {The open command has been found}
  854.     s := reg.ReadString('');
  855.     reg.CloseKey;
  856.   end 
  857.   else
  858.   begin
  859.     {perhaps thier is a system file pointer}
  860.     if reg.OpenKey('.' + ext,
  861.       False) <> False then 
  862.     begin
  863.       s := reg.ReadString('');
  864.       reg.CloseKey;
  865.       if s <> '' then
  866.       begin
  867.         {A system file pointer was found}
  868.         if reg.OpenKey(s + '\shell\open\command',
  869.           False) <> False then
  870.           {The open command has been found}
  871.           s := reg.ReadString('');
  872.         reg.CloseKey;
  873.       end;
  874.     end;
  875.   end;
  876.   {Delete any command line, quotes and spaces}
  877.   if Pos('%', s) > 0 then
  878.     Delete(s, Pos('%', s), Length(s));
  879.   if ((Length(s) > 0) and
  880.     (s[1] = '"')) then
  881.     Delete(s, 1, 1);
  882.   if ((Length(s) > 0) and
  883.     (Pos('"', s) > 0)) then
  884.     Delete(s, Pos('"', s), Length(s));
  885.   while ((Length(s) > 0) and
  886.     (s[Length(s)] = #32)) do
  887.     Delete(s, Length(s), 1);
  888.   {$ELSE}
  889.   GetWindowsDirectory(WinIniFileName, SizeOf(WinIniFileName));
  890.   StrCat(WinIniFileName, '\win.ini');
  891.   WinIni := TIniFile.Create(WinIniFileName);
  892.   s  := WinIni.ReadString('Extensions',ext,'');
  893.   WinIni.Free;
  894.   {Delete any command line}
  895.   if Pos(' ^', s) > 0 then
  896.     Delete(s, Pos(' ^', s), Length(s));
  897.   {$ENDIF}
  898.   Result := s;
  899. end;
  900.  
  901. function GetFileCharSetName(const FileInfo: TDWFileInfo): String;
  902. var
  903.    LngName: Array[0..255] of Char;
  904. begin
  905.    LngName:= '';
  906.    VerLanguageName(FileInfo.dwFileCharSet, LngName, Length(LngName));
  907.    result:= LngName;
  908. end;
  909.  
  910. function GetFileFlags(const FileInfo: TDWFileInfo): TDWFileFlags;
  911. begin
  912.    case FileInfo.dwFileFlags of
  913.    VS_FF_DEBUG:         result:= dwffDebug;
  914.    VS_FF_INFOINFERRED:  result:= dwffInfoInferred;
  915.    VS_FF_PATCHED:       result:= dwffPatched;
  916.    VS_FF_PRERELEASE:    result:= dwffPrerelease;
  917.    VS_FF_PRIVATEBUILD:  result:= dwffPrivateBuild;
  918.    VS_FF_SPECIALBUILD:  result:= dwffSpecialBuild;
  919.    else                 result:= dwffPrivateBuild;
  920.    end;
  921. end;
  922.  
  923. function GetFileInfo(const Filename: String): TDWFileInfo;
  924. type
  925.    pFixedFileInfo = ^TDWFixedFileInfo;
  926.    pLangCharSet = ^TDWLangCharSet;
  927. var
  928.    Size, TmpSize: DWord;
  929.    cFilename,
  930.    Buffer: PChar;
  931.    Ptr: Pointer;
  932.    FixedInfo: TDWFixedFileInfo;
  933.    PLCSet: pLangCharSet;
  934.    Translation: String;
  935.  
  936.    function QueryCopyrightString(const EntryName, Translation: String; pInfoBuffer: Pointer): String;
  937.    var
  938.       Buffer: Array[0..255] of Char;
  939.       FuncSize: UINT;
  940.       Ptr: Pointer;
  941.    begin
  942.        result:= '';
  943.        StrPCopy(Buffer, '\StringFileInfo\' + Translation + '\' + EntryName);
  944.        if VerQueryValue(pInfoBuffer, Buffer, Ptr, FuncSize) then
  945.          Result := StrPas(PChar(Ptr));
  946.    end;
  947. begin
  948.    cFilename := StrAlloc(Length(FileName) + 1);
  949.    StrPCopy(cFilename, FileName);
  950.    Size:= GetFileVersionInfoSize(cFilename, TmpSize);
  951.    if Size > 0 then
  952.    begin
  953.       Buffer := StrAlloc(Size);
  954.       if GetFileVersionInfo(cFilename, TmpSize, Size, Buffer) then
  955.       begin
  956.          VerQueryValue(Buffer, '\', Ptr, Size);
  957.          FixedInfo := pFixedFileInfo(Ptr)^;
  958.          VerQueryValue(Buffer, '\VarFileInfo\Translation', Ptr, Size);
  959.          PLCSet := pLangCharSet(Ptr);
  960.          Translation := Format('%4.4x%4.4x',[PLCSet^.dwLang, PLCSet^.dwCharSet]);
  961.          with result do begin
  962.             dwComments:=         QueryCopyrightString('Comments',
  963.                                                       Translation,
  964.                                                       Buffer);
  965.             dwCompanyName:=      QueryCopyrightString('CompanyName',
  966.                                                       Translation,
  967.                                                       Buffer);
  968.             dwFileDescription:=  QueryCopyrightString('FileDescription',
  969.                                                       Translation,
  970.                                                       Buffer);
  971.             dwFileVersion:=      QueryCopyrightString('FileVersion',
  972.                                                       Translation,
  973.                                                       Buffer);
  974.             dwInternalName:=     QueryCopyrightString('InternalName',
  975.                                                       Translation,
  976.                                                       Buffer);
  977.             dwLegalCopyright:=   QueryCopyrightString('LegalCopyright',
  978.                                                       Translation,
  979.                                                       Buffer);
  980.             dwLegalTrademarks:=  QueryCopyrightString('LegalTrademarks',
  981.                                                       Translation,
  982.                                                       Buffer);
  983.             dwOriginalFilename:= QueryCopyrightString('OriginalFilename',
  984.                                                       Translation,
  985.                                                       Buffer);
  986.             dwPrivateBuild:=     QueryCopyrightString('PrivateBuild',
  987.                                                       Translation,
  988.                                                       Buffer);
  989.             dwProductName:=      QueryCopyrightString('ProductName',
  990.                                                       Translation,
  991.                                                       Buffer);
  992.             dwProductVersion:=   QueryCopyrightString('ProductVersion',
  993.                                                       Translation,
  994.                                                       Buffer);
  995.             dwSpecialBuild:=     QueryCopyrightString('SpecialBuild',
  996.                                                       Translation,
  997.                                                       Buffer);
  998.          end;
  999.       end;
  1000.    end;
  1001.    StrDispose(cFilename);
  1002.    with result do begin
  1003.       dwSignature:=        FixedInfo.dwSignature;
  1004.       dwStrucVersion:=     FixedInfo.dwStrucVersion;
  1005.       dwFileVersionMS:=    FixedInfo.dwFileVersionMS;
  1006.       dwFileVersionLS:=    FixedInfo.dwFileVersionLS;
  1007.       dwProductVersionMS:= FixedInfo.dwProductVersionMS;
  1008.       dwProductVersionLS:= FixedInfo.dwProductVersionLS;
  1009.       dwFileFlagsMask:=    FixedInfo.dwFileFlagsMask;
  1010.       dwFileFlags:=        FixedInfo.dwFileFlags;
  1011.       dwFileOS:=           FixedInfo.dwFileOS;
  1012.       dwFileType:=         FixedInfo.dwFileType;
  1013.       dwFileSubtype:=      FixedInfo.dwFileSubtype;
  1014.       dwFileDateMS:=       FixedInfo.dwFileDateMS;
  1015.       dwFileDateLS:=       FixedInfo.dwFileDateLS;
  1016.       dwFileLanguage:=     PLCSet^.dwLang;
  1017.       dwFileCharSet:=      PLCSet^.dwCharSet;
  1018.    end;
  1019. end;
  1020.  
  1021. function GetFileLanguageName(const FileInfo: TDWFileInfo): String;
  1022. var
  1023.    LngName: Array[0..255] of Char;
  1024. begin
  1025.    LngName:= '';
  1026.    VerLanguageName(FileInfo.dwFileLanguage, LngName, Length(LngName));
  1027.    result:= LngName;
  1028. end;
  1029.  
  1030. function GetFileOS(const FileInfo: TDWFileInfo): TDWFileOSSet;
  1031. begin
  1032.    if (FileInfo.dwFileOS and VOS_DOS)>0
  1033.       then Include(result, dwfosDOS);
  1034.    if (FileInfo.dwFileOS and VOS_DOS_WINDOWS16)>0
  1035.       then Include(result, dwfosDOS_Windows16);
  1036.    if (FileInfo.dwFileOS and VOS_DOS_WINDOWS32)>0
  1037.       then Include(result, dwfosDOS_Windows32);
  1038.    if (FileInfo.dwFileOS and VOS_NT)>0
  1039.       then Include(result, dwfosNT);
  1040.    if (FileInfo.dwFileOS and VOS_NT_WINDOWS32)>0
  1041.       then Include(result, dwfosNT_Windows32);
  1042.    if (FileInfo.dwFileOS and VOS_OS216)>0
  1043.       then Include(result, dwfosOS2_16);
  1044.    if (FileInfo.dwFileOS and VOS_OS216_PM16)>0
  1045.       then Include(result, dwfosOS2_16_PM16);
  1046.    if (FileInfo.dwFileOS and VOS_OS232)>0
  1047.       then Include(result, dwfosOS2_32);
  1048.    if (FileInfo.dwFileOS and VOS_OS232_PM32)>0
  1049.       then Include(result, dwfosOS2_32_PM32);
  1050.    if (FileInfo.dwFileOS and VOS__WINDOWS16)>0
  1051.       then Include(result, dwfosWindows16);
  1052.    if (FileInfo.dwFileOS and VOS__WINDOWS32)>0
  1053.       then Include(result, dwfosWindows32);
  1054.    if (FileInfo.dwFileOS and VOS__PM16)>0
  1055.       then Include(result, dwfosPM16);
  1056.    if (FileInfo.dwFileOS and VOS__PM32)>0
  1057.       then Include(result, dwfosPM32);
  1058.    if result = [] then result:= [dwfosUnknown];
  1059. end;
  1060.  
  1061. function GetFileProductVersionMS(const FileInfo: TDWFileInfo): TDWVersionBlock;
  1062. begin
  1063.    result.dwVersionMajor:= (FileInfo.dwProductVersionMS and $FFFF0000) shr $10;
  1064.    result.dwVersionMinor:=  FileInfo.dwProductVersionMS and $FFFF;
  1065. end;
  1066.  
  1067. function GetFileProductVersionLS(const FileInfo: TDWFileInfo): TDWVersionBlock;
  1068. begin
  1069.    result.dwVersionMajor:= (FileInfo.dwProductVersionLS and $FFFF0000) shr $10;
  1070.    result.dwVersionMinor:=  FileInfo.dwProductVersionLS and $FFFF;
  1071. end;
  1072.  
  1073. function GetFileSubType(const FileInfo: TDWFileInfo): TDWFileSubType;
  1074. begin
  1075.    if (FileInfo.dwFileType = VFT_FONT) then begin
  1076.       case FileInfo.dwFileSubtype of
  1077.       VFT2_FONT_RASTER:   result:= dwfstFontRaster;
  1078.       VFT2_FONT_TRUETYPE: result:= dwfstFontTruetype;
  1079.       VFT2_FONT_VECTOR:   result:= dwfstFontVector;
  1080.       else                result:= dwfstUnknown;
  1081.       end;
  1082.       exit;
  1083.    end;
  1084.    case FileInfo.dwFileSubtype of
  1085.    VFT2_DRV_COMM:        result:= dwfstCOMM;
  1086.    VFT2_DRV_DISPLAY:     result:= dwfstDisplay;
  1087.    VFT2_DRV_INSTALLABLE: result:= dwfstInstallable;
  1088.    VFT2_DRV_KEYBOARD:    result:= dwfstKeyboard;
  1089.    VFT2_DRV_LANGUAGE:    result:= dwfstLanguage;
  1090.    VFT2_DRV_MOUSE:       result:= dwfstMouse;
  1091.    VFT2_DRV_NETWORK:     result:= dwfstNetwork;
  1092.    VFT2_DRV_PRINTER:     result:= dwfstPrinter;
  1093.    VFT2_DRV_SOUND:       result:= dwfstSound;
  1094.    VFT2_DRV_SYSTEM:      result:= dwfstSystem;
  1095.    VFT2_UNKNOWN:         result:= dwfstUnknown;
  1096.    else                  result:= dwfstUnknown;
  1097.    end;
  1098. end;
  1099.  
  1100. function GetFileType(const FileInfo: TDWFileInfo): TDWFileType;
  1101. begin
  1102.    case FileInfo.dwFileType of
  1103.    VFT_UNKNOWN:    result:= dwftUnknown;
  1104.    VFT_APP:        result:= dwftApp;
  1105.    VFT_DLL:        result:= dwftDLL;
  1106.    VFT_DRV:        result:= dwftDRV;
  1107.    VFT_FONT:       result:= dwftFont;
  1108.    VFT_VXD:        result:= dwftVXD;
  1109.    VFT_STATIC_LIB: result:= dwftStaticLib
  1110.    else            result:= dwftUnknown;
  1111.    end;
  1112. end;
  1113.  
  1114. function GetFileStrucVersion(const FileInfo: TDWFileInfo): TDWVersionBlock;
  1115. begin
  1116.    result.dwVersionMajor:= (FileInfo.dwStrucVersion and $FFFF0000) shr $10;
  1117.    result.dwVersionMinor:=  FileInfo.dwStrucVersion and $FFFF;
  1118. end;
  1119.  
  1120. function GetFileVersionLS(const FileInfo: TDWFileInfo): TDWVersionBlock;
  1121. begin
  1122.    result.dwVersionMajor:= (FileInfo.dwFileVersionLS and $FFFF0000) shr $10;
  1123.    result.dwVersionMinor:=  FileInfo.dwFileVersionLS and $FFFF;
  1124. end;
  1125.  
  1126. function GetFileVersionMS(const FileInfo: TDWFileInfo): TDWVersionBlock;
  1127. begin
  1128.    result.dwVersionMajor:= (FileInfo.dwFileVersionMS and $FFFF0000) shr $10;
  1129.    result.dwVersionMinor:=  FileInfo.dwFileVersionMS and $FFFF;
  1130. end;
  1131.  
  1132. {procedure GetVideoModes(var ModeList: TStringList);
  1133. var
  1134.   ModeNumber, j: Integer;
  1135.   MyMode: TDeviceModeA;
  1136.   Check, Need: Boolean;
  1137.   Str: string;
  1138. begin
  1139.   ModeNumber:=0;
  1140.   Check:=True;
  1141.   while(Check) do
  1142.   begin
  1143.     Check:=EnumDisplaySettings(nil, ModeNumber, MyMode);
  1144.     Str:=IntToStr(MyMode.dmPelsWidth)+'-'+IntToStr(MyMode.dmPelsHeight);
  1145.     Need:=False;
  1146.     for j:=0 to ModeList.Count-1 do
  1147.       if ModeList[j]=Str then
  1148.         Need:=True;
  1149.     if Need=False then ModeList.Add(Str);
  1150.     Inc(ModeNumber);
  1151.   end;
  1152. end;  }
  1153.  
  1154. procedure DisableCaptionCloseButton(const FormHandle: THandle);
  1155. var
  1156.    hMnu: THandle;
  1157. begin
  1158.    hMnu:= GetSystemMenu(FormHandle, FALSE);
  1159.    EnableMenuItem(hMnu, SC_MINIMIZE, SC_CLOSE or MF_GRAYED);
  1160. end;
  1161.  
  1162. procedure EnableCaptionCloseButton(const FormHandle: THandle);
  1163. var
  1164.    hMnu: THandle;
  1165. begin
  1166.    hMnu:= GetSystemMenu(FormHandle, FALSE);
  1167.    EnableMenuItem(hMnu, SC_MINIMIZE, SC_CLOSE or MF_ENABLED);
  1168. end;
  1169.  
  1170. function ScreenColorDepth(const Index: Byte): Byte;
  1171. var
  1172.    DevMode: TDeviceMode;
  1173. begin
  1174.    result:= 0;
  1175.    if EnumDisplaySettings(PChar(ScreenDeviceName(Index)), ENUM_CURRENT_SETTINGS,
  1176.                           DevMode) then begin
  1177.       result:= DevMode.dmBitsPerPel;
  1178.    end;
  1179. end;
  1180.  
  1181. function ScreenCount(const ScreenType: TDWScreenType): Integer;
  1182. var
  1183.    DeviceCount: Integer;
  1184.    DisplayDevice: TDisplayDevice;
  1185.    DeviceNum: DWord;
  1186. begin
  1187.    result:= 0;
  1188.    if (IsNT4 or IsWin95) then exit; //These OS does not support multimon
  1189.    DisplayDevice.cb:= SizeOf(DisplayDevice);
  1190.    DeviceNum:= 0;
  1191.    DeviceCount:= 1;
  1192.    while EnumDisplayDevices(NIL, DeviceNum, DisplayDevice, 0) do begin
  1193.       case ScreenType of
  1194.       dwscrtAll:
  1195.          begin
  1196.             if (DisplayDevice.StateFlags and DISPLAY_DEVICE_PRIMARY_DEVICE)>0 then
  1197.                Dec(DeviceCount);
  1198.             Inc(DeviceCount);
  1199.          end;
  1200.       dwscrtDesktop:
  1201.          begin
  1202.             if (DisplayDevice.StateFlags and DISPLAY_DEVICE_PRIMARY_DEVICE)>0 then
  1203.                Dec(DeviceCount);
  1204.             if (DisplayDevice.StateFlags and DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)>0 then
  1205.                Inc(DeviceCount);
  1206.          end;
  1207.       dwscrtMirror:
  1208.          begin
  1209.             if (DisplayDevice.StateFlags and DISPLAY_DEVICE_PRIMARY_DEVICE)>0 then
  1210.                Dec(DeviceCount);
  1211.             if (DisplayDevice.StateFlags and DISPLAY_DEVICE_MIRRORING_DRIVER)>0 then
  1212.                Inc(DeviceCount);
  1213.          end;
  1214.       dwscrtRemovable:
  1215.          begin
  1216.             if (DisplayDevice.StateFlags and DISPLAY_DEVICE_PRIMARY_DEVICE)>0 then
  1217.                Dec(DeviceCount);
  1218.             if (DisplayDevice.StateFlags and DISPLAY_DEVICE_REMOVABLE)>0 then
  1219.                Inc(DeviceCount);
  1220.          end;
  1221.       dwscrtVGA:
  1222.          begin
  1223.             if (DisplayDevice.StateFlags and DISPLAY_DEVICE_PRIMARY_DEVICE)>0 then
  1224.                Dec(DeviceCount);
  1225.             if (DisplayDevice.StateFlags and DISPLAY_DEVICE_VGA_COMPATIBLE)>0 then
  1226.                Inc(DeviceCount);
  1227.          end;
  1228.       end;
  1229.       Inc(DeviceNum);
  1230.    end;
  1231.    result:= DeviceCount;
  1232. end;
  1233.  
  1234. function ScreenDeviceName(const Index: Byte): String;
  1235. var
  1236.    DisplayDevice: TDisplayDevice;
  1237. begin
  1238.    result:= '';
  1239.    DisplayDevice.cb:= SizeOf(DisplayDevice);
  1240.    if EnumDisplayDevices(NIL, Index, DisplayDevice, 0) then begin
  1241.       result:= DisplayDevice.DeviceName;
  1242.    end;
  1243. end;
  1244.  
  1245. function ScreenDeviceString(const Index: Byte): String;
  1246. var
  1247.    DisplayDevice: TDisplayDevice;
  1248. begin
  1249.    result:= '';
  1250.    DisplayDevice.cb:= SizeOf(DisplayDevice);
  1251.    if EnumDisplayDevices(NIL, Index, DisplayDevice, 0) then begin
  1252.       result:= DisplayDevice.DeviceString;
  1253.    end;
  1254. end;
  1255.  
  1256. function ScreenDeviceType(const Index: Byte): TDWScreenTypes;
  1257. var
  1258.    DisplayDevice: TDisplayDevice;
  1259. begin
  1260.    result:= [];
  1261.    DisplayDevice.cb:= SizeOf(DisplayDevice);
  1262.    if EnumDisplayDevices(NIL, Index, DisplayDevice, 0) then begin
  1263.       with DisplayDevice do begin
  1264.          if ((StateFlags and DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) =
  1265.             DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) then Include(result, dwscrtDesktop);
  1266.  
  1267.          if ((StateFlags and DISPLAY_DEVICE_MIRRORING_DRIVER) =
  1268.             DISPLAY_DEVICE_MIRRORING_DRIVER) then Include(result, dwscrtMirror);
  1269.  
  1270.          if ((StateFlags and DISPLAY_DEVICE_MODESPRUNED) =
  1271.             DISPLAY_DEVICE_MODESPRUNED) then Include(result, dwscrtModeSpruned);
  1272.  
  1273.          if ((StateFlags and DISPLAY_DEVICE_PRIMARY_DEVICE) =
  1274.             DISPLAY_DEVICE_PRIMARY_DEVICE) then Include(result, dwscrtPrimary);
  1275.  
  1276.          if ((StateFlags and DISPLAY_DEVICE_REMOVABLE) =
  1277.             DISPLAY_DEVICE_REMOVABLE) then Include(result, dwscrtRemovable);
  1278.  
  1279.          if ((StateFlags and DISPLAY_DEVICE_VGA_COMPATIBLE) =
  1280.             DISPLAY_DEVICE_VGA_COMPATIBLE) then Include(result, dwscrtVGA);
  1281.       end;
  1282.    end;
  1283. end;
  1284.  
  1285. function ScreenFrequency(const Index: Byte): Integer;
  1286. var
  1287.    DevMode: TDeviceMode;
  1288. begin
  1289.    result:= 0;
  1290.    if EnumDisplaySettings(PChar(ScreenDeviceName(Index)), ENUM_CURRENT_SETTINGS,
  1291.                           DevMode) then begin
  1292.       result:= DevMode.dmDisplayFrequency;
  1293.    end;
  1294. end;
  1295.  
  1296. function ScreenResolution(const Index: Byte): TDWDimension;
  1297. var
  1298.    DevMode: TDeviceMode;
  1299. begin
  1300.    with result do begin
  1301.       Height:= 0;
  1302.       Width:= 0;
  1303.    end;
  1304.    if EnumDisplaySettings(PChar(ScreenDeviceName(Index)), ENUM_CURRENT_SETTINGS,
  1305.                           DevMode) then begin
  1306.       with result do begin
  1307.          Height:= DevMode.dmPelsHeight;
  1308.          Width:= DevMode.dmPelsWidth;
  1309.       end;
  1310.    end;
  1311. end;
  1312.  
  1313. function ScreenMonitorString(const Index: Byte): String;
  1314. var
  1315.    DisDev, DisDevMon: TDisplayDevice;
  1316. begin
  1317.    result:= '';
  1318.    DisDev.cb:= SizeOf(TDisplayDevice);
  1319.    DisDevMon.cb:= SizeOf(TDisplayDevice);
  1320.    if EnumDisplayDevices(NIL, Index, DisDev, 0) then begin
  1321.       if DisDev.StateFlags = DISPLAY_DEVICE_MIRRORING_DRIVER then exit;
  1322.       while EnumDisplayDevices(@DisDev.DeviceName, 0, DisDevMon, 0) do begin
  1323.          result:= DisDevMon.DeviceString;
  1324.          if (DisDevMon.StateFlags <> DISPLAY_DEVICE_ACTIVE) then break;
  1325.       end;
  1326.    end;
  1327. end;
  1328.  
  1329. function ScreenMonitorName(const Index: Byte): String;
  1330. var
  1331.    DisDev, DisDevMon: TDisplayDevice;
  1332. begin
  1333.    result:= '';
  1334.    DisDev.cb:= SizeOf(TDisplayDevice);
  1335.    DisDevMon.cb:= SizeOf(TDisplayDevice);
  1336.    if EnumDisplayDevices(NIL, Index, DisDev, 0) then begin
  1337.       if DisDev.StateFlags = DISPLAY_DEVICE_MIRRORING_DRIVER then exit;
  1338.       while EnumDisplayDevices(@DisDev.DeviceName, 0, DisDevMon, 0) do begin
  1339.          result:= DisDevMon.DeviceName;
  1340.          if (DisDevMon.StateFlags <> DISPLAY_DEVICE_ACTIVE) then break;
  1341.       end;
  1342.    end;
  1343. end;
  1344.    function EnumDisplaySettingsExW(lpszDeviceName: PChar;
  1345.             iModeNum: DWord;
  1346.             lpDevMode: _devicemodeA_0500;
  1347.             dwFlags: DWord):Boolean; external 'user32.dll';
  1348.  
  1349. function ScreenMonitorPosition(const Index: Byte; var Point: TPoint): Boolean;
  1350.  
  1351. type
  1352. {   _EnumDisplaySettingsEx = function(lpszDeviceName: PChar;
  1353.                                     iModeNum: DWord;
  1354.                                     lpDevMode: _devicemodeA_0500;
  1355.                                     dwFlags: DWord):Boolean; StdCall;}
  1356.    MONITORINFO = record
  1357.       cbSize: DWord;
  1358.       rcMonitor,
  1359.       rcWork: TRect;
  1360.       dwFlags: Dword;
  1361.    end;
  1362. const
  1363.    DLLName: PChar = 'User32.dll';
  1364.    FcnName: PChar = 'EnumDisplaySettingsExW';
  1365. var
  1366. //   DLLHndl: THandle;
  1367.    bCanLoadDLL,
  1368.    bCanLoadFcn,
  1369.    bCanEnumDevice,
  1370.    bCanEnumExMonitor: Boolean;
  1371. //   EnumDisplaySettingsEx: _EnumDisplaySettingsEx;
  1372.    DisDev, DisDevMon: TDisplayDevice;
  1373.    DevMode: _devicemodeA_0500;
  1374.    MI: MONITORINFO;
  1375.    HM: THandle;
  1376. begin
  1377.    with Point do begin
  1378.       x:= 0;
  1379.       y:= 0;
  1380.    end;
  1381.    bCanLoadFcn:= FALSE;
  1382.    bCanEnumDevice:= FALSE;
  1383.    bCanEnumExMonitor:= FALSE;
  1384.    ZeroMemory(@DisDev, SizeOf(TDisplayDevice));
  1385.    DisDev.cb:= SizeOf(TDisplayDevice);
  1386. //   DLLHndl:= LoadLibrary(DLLName);
  1387. //   bCanLoadDLL:= (DLLHndl <> 0);
  1388.    if bCanLoadDLL then begin
  1389. //      EnumDisplaySettingsEx:= GetProcAddress(DLLHndl, FcnName);
  1390. //      if Assigned(EnumDisplaySettingsEx) then begin
  1391. //          bCanLoadFcn:= Assigned(EnumDisplaySettingsEx);
  1392.           bCanEnumDevice:= EnumDisplayDevices(nil, Index, DisDev, 0);
  1393.           DisDevMon.cb:= SizeOf(TDisplayDevice);
  1394.           EnumDisplayDevices(@DisDev.DeviceName, 0, DisDevMon, 0);
  1395.           ZeroMemory(@DevMode, SizeOf(_devicemodeA_0500));
  1396.           DevMode.dmSize:= SizeOf(_devicemodeA_0500);
  1397.     {ERR!}bCanEnumExMonitor:= EnumDisplaySettingsExW(@DisDev.DeviceName[0], ENUM_CURRENT_SETTINGS, DevMode, 0);
  1398.           if bCanEnumExMonitor then begin
  1399.              ZeroMemory(@MI, SizeOf(MONITORINFO));
  1400.              MI.cbSize:= SizeOf(MONITORINFO);
  1401.              if DisDev.StateFlags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP then begin
  1402.                 Point.x:= DevMode.dmPosition.x;
  1403.                 Point.y:= DevMode.dmPosition.y;
  1404.                 hm:= MonitorFromPoint(Point, MONITOR_DEFAULTTONULL);
  1405.                  if (hm <> 0) then GetMonitorInfo(hm, @mi);
  1406.             end;
  1407.           end;
  1408.       end;
  1409. //   end;
  1410. //   FreeLibrary(DLLHndl);
  1411.    result:= bCanLoadDLL and bCanLoadFcn and bCanEnumDevice and bCanEnumExMonitor;
  1412. end;
  1413.  
  1414.  
  1415. function MenuHilightColor: TColor;
  1416. const
  1417.   COLOR_MENUHILIGHT = 29;
  1418. begin
  1419.    result:= clNone;
  1420.    if not IsWinXP then exit;
  1421.    result:= GetSysColor(COLOR_MENUHILIGHT);
  1422. end;
  1423.  
  1424. function MenuBarColor: TColor;
  1425. const
  1426.   COLOR_MENUBAR = 30;
  1427. begin
  1428.    result:= clNone;
  1429.    if not IsWinXP then exit;
  1430.    result:= GetSysColor(COLOR_MENUBAR);
  1431. end;
  1432.  
  1433. function HotLightColor: TColor;
  1434. const
  1435.   COLOR_HOTLIGHT = 26;
  1436. begin
  1437.    result:= clNone;
  1438.    if IsWin95 or IsNT351 or IsNT4 then exit;
  1439.    result:= GetSysColor(COLOR_HOTLIGHT);
  1440. end;
  1441.  
  1442. function ActiveCaptionGradientColor: TColor;
  1443. const
  1444.   COLOR_GRADIENTACTIVECAPTION = 27;
  1445. begin
  1446.    result:= clNone;
  1447.    if IsWin95 or IsNT351 or IsNT4 then exit;
  1448.    result:= GetSysColor(COLOR_GRADIENTACTIVECAPTION);
  1449. end;
  1450.  
  1451. function InactiveCaptionGradientColor: TColor;
  1452. const
  1453.   COLOR_GRADIENTINACTIVECAPTION = 28;
  1454. begin
  1455.    result:= clNone;
  1456.    if IsWin95 or IsNT351 or IsNT4 then exit;
  1457.    result:= GetSysColor(COLOR_GRADIENTINACTIVECAPTION);
  1458. end;
  1459.  
  1460. function MouseButtonsSwaped: Boolean;
  1461. begin
  1462.    result:= GetSystemMetrics(SM_SWAPBUTTON)<>0;
  1463. end;
  1464.  
  1465. function GetMenuAlignment: TDWMenuAlignment;
  1466. begin
  1467.    if GetSystemMetrics(SM_MENUDROPALIGNMENT)<>0 then
  1468.       result:= dwmaRight else
  1469.       result:= dwmaLeft;
  1470. end;
  1471.  
  1472. function GetMouseButtons: Integer;
  1473. begin
  1474.    result:= GetSystemMetrics(SM_CMOUSEBUTTONS);
  1475. end;
  1476.  
  1477. function GetMinimizedWindowArrangement: TDWMinimizedWindowArrangement;
  1478. begin
  1479.    case GetSystemMetrics(SM_ARRANGE) of
  1480.    ARW_BOTTOMRIGHT: result:= dwmwaBottomRight;
  1481.    ARW_HIDE:        result:= dwmwaHide;
  1482.    ARW_TOPLEFT:     result:= dwmwaTopLeft;
  1483.    ARW_TOPRIGHT:    result:= dwmwaTopRight
  1484.    else             result:= dwmwaBottomLeft;
  1485.    end;  
  1486. end;
  1487.  
  1488. function NetworkIsPresent: Boolean;
  1489. begin
  1490.    result:= (GetSystemMetrics(SM_NETWORK)<>0);
  1491. end;
  1492.  
  1493. function GetCapslock: Boolean;
  1494. var
  1495.    KS: TKeyboardState;
  1496. begin
  1497.    GetKeyboardState(KS);
  1498.    result:= (KS[VK_CAPITAL]<>0);
  1499. end;
  1500.  
  1501. function GetNumLock: Boolean;
  1502. var
  1503.    KS: TKeyboardState;
  1504. begin
  1505.    GetKeyboardState(KS);
  1506.    result:= (KS[VK_NUMLOCK]<>0);
  1507. end;
  1508.  
  1509. function GetScrollLock: Boolean;
  1510. var
  1511.    KS: TKeyboardState;
  1512. begin
  1513.    GetKeyboardState(KS);
  1514.    result:= (KS[VK_SCROLL]<>0);
  1515. end;
  1516.  
  1517. procedure SetCapsLock(const CapsLockOn: Boolean);
  1518. var
  1519.    KS: TKeyboardState;
  1520. begin
  1521.    GetKeyboardState(KS);
  1522.    if CapsLockOn then KS[VK_CAPITAL]:= 1 else KS[VK_CAPITAL]:= 0;
  1523.    SetKeyboardState(KS);
  1524. end;
  1525.  
  1526. procedure SetNumLock(const NumLockOn: Boolean);
  1527. var
  1528.    KS: TKeyboardState;
  1529. begin
  1530.    GetKeyboardState(KS);
  1531.    if NumLockOn then KS[VK_NUMLOCK]:= 1 else KS[VK_NUMLOCK]:= 0;
  1532.    SetKeyboardState(KS);
  1533. end;
  1534.  
  1535. procedure SetScrollLock(const ScrollLockOn: Boolean);
  1536. var
  1537.    KS: TKeyboardState;
  1538. begin
  1539.    GetKeyboardState(KS);
  1540.    if ScrollLockOn then KS[VK_SCROLL]:= 1 else KS[VK_SCROLL]:= 0;
  1541.    SetKeyboardState(KS);
  1542. end;
  1543.  
  1544. function GetBootOption: TDWBootOption;
  1545. begin
  1546.    case GetSystemMetrics(SM_CLEANBOOT) of
  1547.    1: result:= dwboFailSafe;
  1548.    2: result:= dwboFailSaveNet;
  1549.    else result:= dwboNormal;
  1550.    end;
  1551. end;
  1552.  
  1553. function MouseHasWheel: Boolean;
  1554. begin
  1555.    result:= (GetSystemMetrics(SM_MOUSEWHEELPRESENT)<>0);
  1556. end;
  1557.  
  1558. function MouseIsPresent: Boolean;
  1559. begin
  1560.   result:= (GetSystemMetrics(SM_MOUSEPRESENT)<>0);
  1561. end;
  1562.  
  1563. procedure BuzzerSound(const Frequency: Word; const Delay: Cardinal);
  1564.  
  1565.  function InPort(PortAddr:word): byte; assembler; stdcall;
  1566.  asm
  1567.    mov dx,PortAddr
  1568.    in al,dx
  1569.  end;
  1570.  
  1571.  procedure OutPort(PortAddr: word; Databyte: byte); assembler; stdcall;
  1572.  asm
  1573.    mov al,Databyte
  1574.    mov dx,PortAddr
  1575.    out dx,al
  1576.  end;
  1577.  
  1578.  procedure Sound(Hz : Word);
  1579.  var TmpW : Word;
  1580.  begin
  1581.    OutPort($43,182);
  1582.    TmpW :=InPort($61);
  1583.    OutPort($61,TmpW or 3);
  1584.    OutPort($42,lo(1193180 div hz));
  1585.    OutPort($42, hi(1193180 div hz));
  1586.  end;
  1587.  
  1588.  procedure NoSound;
  1589.  var TmpW : Word;
  1590.  begin
  1591.    OutPort($43,182);
  1592.    TmpW := InPort($61);
  1593.    OutPort($61,TmpW and 3);
  1594.  end;
  1595.  
  1596. begin
  1597.  if IsNTMachine then
  1598.    Windows.Beep(Frequency, Delay) else
  1599.  begin
  1600.    Sound(Frequency);
  1601.    Sleep(Delay);
  1602.    NoSound;
  1603.  end;
  1604. end;
  1605.  
  1606. function AvailablePageMemory: Int64;
  1607. var
  1608.    MemStat: TMemoryStatus;
  1609. begin
  1610.    MemStat.dwLength:= SizeOf(MemStat);
  1611.    GlobalMemoryStatus(MemStat);
  1612.    result:= MemStat.dwAvailPageFile;
  1613. end;
  1614.  
  1615. function AvailablePhysicalMemory: Int64;
  1616. var
  1617.    MemStat: TMemoryStatus;
  1618. begin
  1619.    MemStat.dwLength:= SizeOf(MemStat);
  1620.    GlobalMemoryStatus(MemStat);
  1621.    result:= MemStat.dwAvailPhys;
  1622. end;
  1623.  
  1624. function AvailableVirtualMemory: Int64;
  1625. var
  1626.    MemStat: TMemoryStatus;
  1627. begin
  1628.    MemStat.dwLength:= SizeOf(MemStat);
  1629.    GlobalMemoryStatus(MemStat);
  1630.    result:= MemStat.dwAvailVirtual;
  1631. end;
  1632.  
  1633. function MemoryUsedPercentage: Integer;
  1634. var
  1635.    MemStat: TMemoryStatus;
  1636. begin
  1637.    MemStat.dwLength:= SizeOf(MemStat);
  1638.    GlobalMemoryStatus(MemStat);
  1639.    result:= MemStat.dwMemoryLoad;
  1640. end;
  1641.  
  1642. function SoundCardInstalled: Boolean;
  1643. begin
  1644.    result:= WaveOutGetNumDevs > 0;
  1645. end;
  1646.  
  1647. function TotalPageMemory: Int64;
  1648. var
  1649.    MemStat: TMemoryStatus;
  1650. begin
  1651.    MemStat.dwLength:= SizeOf(MemStat);
  1652.    GlobalMemoryStatus(MemStat);
  1653.    result:= MemStat.dwTotalPageFile;
  1654. end;
  1655.  
  1656. function TotalPhysicalMemory: Int64;
  1657. var
  1658.    MemStat: TMemoryStatus;
  1659. begin
  1660.    MemStat.dwLength:= SizeOf(MemStat);
  1661.    GlobalMemoryStatus(MemStat);
  1662.    result:= MemStat.dwTotalPhys;
  1663. end;
  1664.  
  1665. function TotalVirtualMemory: Int64;
  1666. var
  1667.    MemStat: TMemoryStatus;
  1668. begin
  1669.    MemStat.dwLength:= SizeOf(MemStat);
  1670.    GlobalMemoryStatus(MemStat);
  1671.    result:= MemStat.dwTotalVirtual;
  1672. end;
  1673.  
  1674. function EmptyRecycleBin(const Confirmation, GUI, Sound: Boolean): Boolean;
  1675. const
  1676.   SHERB_NOCONFIRMATION = $00000001;
  1677.   SHERB_NOPROGRESSUI = $00000002;
  1678.   SHERB_NOSOUND = $00000004;
  1679. type
  1680.   TSHEmptyRecycleBin = function(Wnd: HWND;
  1681.                                 pszRootPath: PChar;
  1682.                                 dwFlags: DWORD): HRESULT;  stdcall;
  1683. var
  1684.   SHEmptyRecycleBin: TSHEmptyRecycleBin;
  1685.   LibHandle: THandle;
  1686.   Flags: DWord;
  1687. begin  { EmptyRecycleBin }
  1688.   result:= FALSE;
  1689.   Flags:= 0;
  1690.   if not Confirmation then Flags:= Flags or SHERB_NOCONFIRMATION;
  1691.   if not GUI          then Flags:= Flags or SHERB_NOPROGRESSUI;
  1692.   if not Sound        then Flags:= Flags or SHERB_NOSOUND;
  1693.   LibHandle := LoadLibrary(PChar('Shell32.dll'));
  1694.   if LibHandle <> 0 then @SHEmptyRecycleBin :=
  1695.       GetProcAddress(LibHandle, 'SHEmptyRecycleBinA')
  1696.   else
  1697.   begin
  1698.     MessageDlg('Shell32.dll konnte nicht geladen werden.', mtError, [mbOK], 0);
  1699.     Exit;
  1700.   end;
  1701.   if @SHEmptyRecycleBin <> nil then result:= (SHEmptyRecycleBin(GetCurrentProcess, nil, Flags)=S_OK);
  1702.   FreeLibrary(LibHandle); @SHEmptyRecycleBin := nil;
  1703. end;
  1704.  
  1705. function FilesInRecycleBin(var FileCount: Int64): Boolean;
  1706. type
  1707.   _SHQUERYRBINFO = record
  1708.      cbSize: DWord;
  1709.      i64Sizelow, i64Sizehigh,
  1710.      i64NumItemslow, i64NumItemshigh: DWord;
  1711.   end;
  1712.   TPSHQUERYRBINFO = ^_SHQUERYRBINFO;
  1713.   TSHQueryRecycleBin = function(pszRootPath: PChar;
  1714.                                 var pSHQueryRBInfo: TPSHQUERYRBINFO): HRESULT;  stdcall;
  1715. var
  1716.   SHQueryRecycleBin: TSHQueryRecycleBin;
  1717.   SHQueryRBInfo: _SHQUERYRBINFO;
  1718.   pSHQueryRBInfo : TPSHQUERYRBINFO;
  1719.   LibHandle: THandle;
  1720. begin  { EmptyRecycleBin }
  1721.   result:= FALSE;
  1722.   SHQueryRBInfo.cbSize:= SizeOf(SHQueryRBInfo);
  1723.   LibHandle := LoadLibrary(PChar('Shell32.dll'));
  1724.   if LibHandle <> 0 then @SHQueryRecycleBin :=
  1725.       GetProcAddress(LibHandle, 'SHQueryRecycleBinA')
  1726.   else
  1727.   begin
  1728.     MessageDlg('Shell32.dll konnte nicht geladen werden.', mtError, [mbOK], 0);
  1729.     Exit;
  1730.   end;
  1731.   if not Assigned(SHQueryRecycleBin) then begin
  1732.     MessageDlg('Shell32.dll konnte nicht geladen werden.', mtError, [mbOK], 0);
  1733.     Exit;
  1734.   end;
  1735.  
  1736.   pSHQueryRBInfo := @SHQueryRBInfo;
  1737.   SHQueryRBInfo.cbSize := sizeof(SHQueryRBInfo);
  1738.   SHQueryRBInfo.i64numitemslow := 0;
  1739.   SHQueryRBInfo.i64numitemshigh := 0;
  1740.  
  1741.   result:= ( SHQueryRecycleBin(PChar('c:'), pSHQueryRBInfo)=S_OK);
  1742.   filecount := SHQueryRBInfo.i64numitemslow;
  1743.   FreeLibrary(LibHandle); @SHQueryRecycleBin := nil;
  1744. end;
  1745.  
  1746. function CPUClock: Double;
  1747. const
  1748.  DelayTime= 500;
  1749. var
  1750.   TimerHigh,TimerLow:DWORD;
  1751. begin
  1752.   SetPriorityClass( GetCurrentProcess,REALTIME_PRIORITY_CLASS);
  1753.   SetThreadPriority( GetCurrentThread,THREAD_PRIORITY_TIME_CRITICAL);
  1754.   Sleep( 10);
  1755.   asm
  1756.     dw 310Fh
  1757.     mov TimerLow,eax
  1758.     mov TimerHigh,edx
  1759.   end;
  1760.   Sleep( DelayTime);
  1761.   asm
  1762.     dw 310Fh
  1763.     sub eax,TimerLow
  1764.     sbb edx,TimerHigh
  1765.     mov TimerLow,eax
  1766.     mov TimerHigh,edx
  1767.   end;
  1768.   Result:=TimerLow / (1000.0*DelayTime);
  1769. end;
  1770.  
  1771. procedure MonitorOff;
  1772. begin
  1773.    SendMessage(GetCurrentProcess, WM_SYSCOMMAND, SC_MONITORPOWER, 0);
  1774. end;
  1775.  
  1776. procedure MonitorOn;
  1777. begin
  1778.    SendMessage(GetCurrentProcess, WM_SYSCOMMAND, SC_MONITORPOWER, -1);
  1779. end;
  1780.  
  1781. procedure SetSystemClock(Year, Month, Day, Hour, Minute, Second, MSecond: Integer);
  1782. var
  1783.    SysTime: TSystemTime;
  1784.    DayTime: TDateTime;
  1785. begin
  1786.    DayTime:= EncodeDate(Year, Month, Day) +
  1787.              EncodeTime(Hour, Minute, Second, MSecond);
  1788.              DateTimeToSystemTime(DayTime, SysTime);
  1789.              SetLocalTime(SysTime);
  1790. end;
  1791.  
  1792. end.
  1793.