⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setup.dpr

📁 Delphi 开发的的热键操作 很值得看的
💻 DPR
字号:
program Setup;

uses
  Windows;

{$R RESOURCE.RES}

{$I-}
const
  InfFile : array[0..70] of string =
          ( '[Version]',
            'Signature=$Chicago$',
            'Provider=%Author%',
            '[DefaultInstall]',
            'CopyFiles=Hotkeys.Files.Install',
            'UpdateInis=Hotkeys.Add.Inis',
            'AddReg=Hotkeys.Add.Reg',
            '[DefaultUnInstall]',
            'DelFiles=Hotkeys.Files.UnInstall',
            'UpdateInis=Hotkeys.Del.Inis',
            'DelReg=Hotkeys.Del.Reg',
            '[DestinationDirs]',
            'Hotkeys.Files.Install=24,%InstallDir%',
            'Hotkeys.Files.UnInstall=24,%InstallDir%',
            'Hotkeys.Files.Other=24,%InstallDir%',
            '[SourceDisksNames]',
            '1="%Hotkeys%","",1',
            '[SourceDisksFiles]',
            'HOTKEYS.EXE=1',
            'HKRESTRT.EXE=1',
            'HKTODOS.PIF=1',
            'HOTKEYS.HLP=1',
            'HOTKEYS.HKD=1',
            'SETUP.EXE=1',
            '[Hotkeys.Files.Install]',
            'HOTKEYS.EXE',
            'HOTKEYS.HLP',
            'HOTKEYS.HKD,,,16',
            'HKRESTRT.EXE',
            'HKTODOS.PIF',
            'UNINSTAL.EXE,SETUP.EXE',
            '[Hotkeys.Files.UnInstall]',
            'HOTKEYS.EXE',
            'HOTKEYS.HLP',
            'HOTKEYS.HKD',
            'HKRESTRT.EXE',
            'HKTODOS.PIF',
            'HOTKEYS.GID',
            'HOTKEYS.FTS',
            'HOTKEYS.INI',
            'HKSETUP.INF',
            'UNINSTAL.EXE,,,1',
            '[Hotkeys.Add.Inis]',
            'setup.ini, progman.groups,, "group1=""Hotkeys"""',
            'setup.ini, group1,, """%Hotkeys%"", ""%24%\%InstallDir%\HOTKEYS.EXE"",,,,,%Hotkeys%',
            'setup.ini, group1,, """%Hothelp%"", ""%24%\%InstallDir%\HOTKEYS.HLP"",,,,,%Hothelp%',
            'setup.ini, group1,, """%Hotinst%"", ""%24%\%InstallDir%\UNINSTAL.EXE"",""%24%\%InstallDir%\UNINSTAL.EXE"",1,,,%Hotinst%',
            '[Hotkeys.Del.Inis]',
            'setup.ini, progman.groups,, "group1=""Hotkeys"""',
            'setup.ini, group1,, """%Hotkeys%""',
            'setup.ini, group1,, """%Hothelp%""',
            'setup.ini, group1,, """%Hotinst%""',
            '[Hotkeys.Add.Reg]',
            'HKLM,%UIF%',
            'HKLM,%UIF%,DisplayName,,"%Hotkeys% %Version%"',
            'HKLM,%UIF%,UninstallString,,"%24%\%InstallDir%\UNINSTAL.EXE"',
            'HKLM,%RUN%,Hotkeys,,"%24%\%InstallDir%\HOTKEYS.EXE"',
            'HKLM,%RNO%,Hotkeys,,"%24%\%InstallDir%\UNINSTAL.EXE RunHotkeys"',
            '[Hotkeys.Del.Reg]',
            'HKLM,%UIF%',
            'HKLM,%RUN%,Hotkeys',
            '[Strings]',
            'Hotkeys="Hotkeys"',
            'Version="version 1.3"',
            'Hothelp="Hotkeys Help"',
            'Hotinst="Hotkeys Uninstall"',
            'InstallDir="Progra~1\Hotkeys"',
            'Author="SheAr software"',
            'UIF="Software\Microsoft\Windows\CurrentVersion\Uninstall\Hotkeys"',
            'RUN="Software\Microsoft\Windows\CurrentVersion\Run"',
            'RNO="Software\Microsoft\Windows\CurrentVersion\RunOnce"');

function IsWinNT: Boolean;
var
  OsVersionInfo: TOSVersionInfo;
begin
  OsVersionInfo.dwOSVersionInfoSize := sizeof(TOsVersionInfo);
  GetVersionEx(OsVersionInfo);
  Result := OsVersionInfo.dwPlatformID = VER_PLATFORM_WIN32_NT;
end;


function GetWinDir: String;
var
  Buf: array[0..MAX_PATH] of char;
begin
  GetWindowsDirectory(Buf, MAX_PATH);
  Result := Buf;
  if Result[Length(Result)]<>'\' then Result := Result + '\';
end;

function GetAppDir: String;
begin
  Result := ParamStr(0);
  while (Result<>'') and (Result[Length(Result)]<>'\') do Delete(Result, Length(Result), 1);
end;

function WinExecAndWait(FileName: String; Visibility: Integer): Integer;
var
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
begin
  FillChar(StartupInfo,Sizeof(StartupInfo),#0);
  StartupInfo.cb := Sizeof(StartupInfo);

  StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartupInfo.wShowWindow := Visibility;
  if not CreateProcess(nil, PChar(FileName), nil, nil, False, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo) then
   Result := -1
  else
   begin
     WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
     GetExitCodeProcess(ProcessInfo.hProcess,Result);
   end;
end;

var
  F : Text;
  Command, AppDir: String;

const
  InfFileName = 'HKSETUP.INF';

procedure ExportInfFile;
var
  i : integer;
begin
  AssignFile(F, AppDir + InfFileName);
  Rewrite(F);
  for i:=Low(InfFile) to High(InfFile) do WriteLn(F, InfFile[i]);
  CloseFile(F);
end;

procedure CloseHotkeys;
var
  hwndHotkeys: THandle;
const
  WM_USER     = $0400;
  WM_QUITHOTK = WM_USER+2004;
begin
  hwndHotkeys := FindWindow('TfrmHotkeyEdit', nil);
  if hwndHotkeys<>0 then
   begin
     SendMessage(hwndHotkeys, WM_QUITHOTK, WM_QUITHOTK, 0);
     Sleep(500);
   end;
end;

begin
  AppDir := GetAppDir;

  if IsWinNT then
   Command := 'rundll32.exe setupapi'
  else
   Command := 'rundll.exe setupx.dll';

  Command := Command + ',InstallHinfSection Default';

  if ParamStr(1)='RunHotkeys' then
   WinExec(PChar(Copy(GetWinDir, 1, 3) + 'PROGRA~1\HOTKEYS\HOTKEYS.EXE'), SW_SHOW)
  else if Pos('UNINSTAL.EXE', CharUpper(PChar(ParamStr(0))))>0 then
   begin
     if MessageBox(0, 'Are you sure you want to completely remove the Hotkeys application from your system?', 'Hotkeys 1.3 Uninstall', MB_ICONQUESTION or MB_YESNO)=IDYES then
      begin
        CloseHotkeys;
        // Deletes the hotkeys application
        ExportInfFile;
        WinExecAndWait(Command +'Uninstall 132 ' + AppDir + InfFileName, SW_SHOW);
        DeleteFile(PChar(ParamStr(0)));
      end;
   end
  else
   begin
     if MessageBox(0, 'This will install the Hotkeys application on your harddisk. Press ''Ok'' to continue with installation or ''Cancel'' to cancel the installation.', 'Hotkeys 1.3 Installation', MB_OKCANCEL)=IDOK then
      begin
        CloseHotkeys;
        ExportInfFile;
        WinExecAndWait(Command + 'Install 132 ' + AppDir + InfFileName, SW_SHOW);
        Erase(F);
      end;
   end;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -