浏览代码

More cleanup...

Martijn Laan 1 年之前
父节点
当前提交
e98cdc36d7
共有 9 个文件被更改,包括 50 次插入173 次删除
  1. 1 7
      Components/ScintEdit.pas
  2. 33 73
      Projects/CmnFunc2.pas
  3. 1 4
      Projects/CompFunc.pas
  4. 3 3
      Projects/CompMsgs.pas
  5. 1 3
      Projects/FileClass.pas
  6. 1 2
      Projects/InstFunc.pas
  7. 0 12
      Projects/Main.pas
  8. 10 15
      Projects/RegSvr.pas
  9. 0 54
      Projects/SelLangForm.pas

+ 1 - 7
Components/ScintEdit.pas

@@ -2,7 +2,7 @@ unit ScintEdit;
 
 {
   Inno Setup
-  Copyright (C) 1997-2020 Jordan Russell
+  Copyright (C) 1997-2024 Jordan Russell
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
 
@@ -633,12 +633,6 @@ begin
   Call(SCI_SETSCROLLWIDTHTRACKING, 1, 0);
   { The default popup menu conflicts with the VCL's PopupMenu on Delphi 3 }
   Call(SCI_USEPOPUP, 0, 0);
-{$IFNDEF UNICODE}
-  { This hack is needed because non-Unicode VCL replaces the Scintilla's
-    default Unicode window proc with an ANSI one }
-  if Win32Platform = VER_PLATFORM_WIN32_NT then
-    Call(SCI_SETKEYSUNICODE, 1, 0);
-{$ENDIF}
   SetDefaultWordChars;
   ApplyOptions;
   UpdateStyleAttributes;

+ 33 - 73
Projects/CmnFunc2.pas

@@ -766,13 +766,11 @@ begin
   Result := GetEnv('TEMP');
   if (Result <> '') and DirExists(Result) then
     goto 1;
-  if Win32Platform = VER_PLATFORM_WIN32_NT then begin
-    { Like Windows 2000's GetTempPath, return USERPROFILE when TMP and TEMP
-      are not set }
-    Result := GetEnv('USERPROFILE');
-    if (Result <> '') and DirExists(Result) then
-      goto 1;
-  end;
+  { Like Windows 2000's GetTempPath, return USERPROFILE when TMP and TEMP
+    are not set }
+  Result := GetEnv('USERPROFILE');
+  if (Result <> '') and DirExists(Result) then
+    goto 1;
   Result := GetWinDir;
 1:Result := AddBackslash(PathExpand(Result));
 end;
@@ -912,33 +910,8 @@ end;
 function RegValueExists(H: HKEY; Name: PChar): Boolean;
 { Returns True if the specified value exists. Requires KEY_QUERY_VALUE access
   to the key. }
-var
-  I: Integer;
-  EnumName: array[0..1] of Char;
-  Count: DWORD;
-  ErrorCode: Longint;
 begin
   Result := RegQueryValueEx(H, Name, nil, nil, nil, nil) = ERROR_SUCCESS;
-  if Result and ((Name = nil) or (Name^ = #0)) and
-     (Win32Platform <> VER_PLATFORM_WIN32_NT) then begin
-    { On Win9x/Me a default value always exists according to RegQueryValueEx,
-      so it must use RegEnumValue instead to check if a default value
-      really exists }
-    Result := False;
-    I := 0;
-    while True do begin
-      Count := SizeOf(EnumName) div SizeOf(EnumName[0]);
-      ErrorCode := RegEnumValue(H, I, EnumName, Count, nil, nil, nil, nil);
-      if (ErrorCode <> ERROR_SUCCESS) and (ErrorCode <> ERROR_MORE_DATA) then
-        Break;
-      { is it the default value? }
-      if (ErrorCode = ERROR_SUCCESS) and (EnumName[0] = #0) then begin
-        Result := True;
-        Break;
-      end;
-      Inc(I);
-    end;
-  end;
 end;
 
 function RegCreateKeyExView(const RegView: TRegView; hKey: HKEY; lpSubKey: PChar;
@@ -999,32 +972,30 @@ begin
     Result := ERROR_INVALID_PARAMETER;
     Exit;
   end;
-  if Win32Platform = VER_PLATFORM_WIN32_NT then begin
-    if RegOpenKeyExView(RegView, Key, Name, 0, KEY_ENUMERATE_SUB_KEYS, H) = ERROR_SUCCESS then begin
-      try
-        SetString(KeyName, nil, 256);
-        I := 0;
-        while True do begin
-          KeyNameCount := Length(KeyName);
-          ErrorCode := RegEnumKeyEx(H, I, @KeyName[1], KeyNameCount, nil, nil, nil, nil);
-          if ErrorCode = ERROR_MORE_DATA then begin
-            { Double the size of the buffer and try again }
-            if Length(KeyName) >= 65536 then begin
-              { Sanity check: If we tried a 64 KB buffer and it's still saying
-                there's more data, something must be seriously wrong. Bail. }
-              Break;
-            end;
-            SetString(KeyName, nil, Length(KeyName) * 2);
-            Continue;
-          end;
-          if ErrorCode <> ERROR_SUCCESS then
+  if RegOpenKeyExView(RegView, Key, Name, 0, KEY_ENUMERATE_SUB_KEYS, H) = ERROR_SUCCESS then begin
+    try
+      SetString(KeyName, nil, 256);
+      I := 0;
+      while True do begin
+        KeyNameCount := Length(KeyName);
+        ErrorCode := RegEnumKeyEx(H, I, @KeyName[1], KeyNameCount, nil, nil, nil, nil);
+        if ErrorCode = ERROR_MORE_DATA then begin
+          { Double the size of the buffer and try again }
+          if Length(KeyName) >= 65536 then begin
+            { Sanity check: If we tried a 64 KB buffer and it's still saying
+              there's more data, something must be seriously wrong. Bail. }
             Break;
-          if RegDeleteKeyIncludingSubkeys(RegView, H, PChar(KeyName)) <> ERROR_SUCCESS then
-            Inc(I);
+          end;
+          SetString(KeyName, nil, Length(KeyName) * 2);
+          Continue;
         end;
-      finally
-        RegCloseKey(H);
+        if ErrorCode <> ERROR_SUCCESS then
+          Break;
+        if RegDeleteKeyIncludingSubkeys(RegView, H, PChar(KeyName)) <> ERROR_SUCCESS then
+          Inc(I);
       end;
+    finally
+      RegCloseKey(H);
     end;
   end;
   Result := RegDeleteKeyView(RegView, Key, Name);
@@ -1136,22 +1107,18 @@ begin
       access token. This function eliminates potential misinterpretations of
       the active group membership if changes to access tokens are made in
       future releases." }
-    CheckTokenMembership := nil;
-    if Lo(GetVersion) >= 5 then
-      CheckTokenMembership := GetProcAddress(GetModuleHandle(advapi32),
-        'CheckTokenMembership');
+    CheckTokenMembership := GetProcAddress(GetModuleHandle(advapi32),
+      'CheckTokenMembership');
     if Assigned(CheckTokenMembership) then begin
       if CheckTokenMembership(0, Sid, IsMember) then
         Result := IsMember;
     end
-    else begin
+    else begin { Should never happen }
       GroupInfo := nil;
-      if not OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True,
-         {$IFDEF Delphi3orHigher} Token {$ELSE} @Token {$ENDIF}) then begin
+      if not OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, Token) then begin
         if GetLastError <> ERROR_NO_TOKEN then
           Exit;
-        if not OpenProcessToken(GetCurrentProcess, TOKEN_QUERY,
-           {$IFDEF Delphi3orHigher} Token {$ELSE} @Token {$ENDIF}) then
+        if not OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, Token) then
           Exit;
       end;
       try
@@ -1639,15 +1606,8 @@ end;
 
 function MoveFileReplace(const ExistingFileName, NewFileName: String): Boolean;
 begin
-  if Win32Platform = VER_PLATFORM_WIN32_NT then begin
-    Result := MoveFileEx(PChar(ExistingFileName), PChar(NewFileName),
-      MOVEFILE_REPLACE_EXISTING);
-  end
-  else begin
-    Result := DeleteFile(PChar(NewFileName));
-    if Result or (GetLastError = ERROR_FILE_NOT_FOUND) then
-      Result := MoveFile(PChar(ExistingFileName), PChar(NewFileName));
-  end;
+  Result := MoveFileEx(PChar(ExistingFileName), PChar(NewFileName),
+    MOVEFILE_REPLACE_EXISTING);
 end;
 
 var

+ 1 - 4
Projects/CompFunc.pas

@@ -466,10 +466,7 @@ var
   StartupInfo: TStartupInfo;
   ProcessInfo: TProcessInformation;
 begin
-  if Win32Platform = VER_PLATFORM_WIN32_NT then
-    Dir := GetSystemDir
-  else
-    Dir := GetWinDir;
+  Dir := GetSystemDir;
 
   FillChar(StartupInfo, SizeOf(StartupInfo), 0);
   StartupInfo.cb := SizeOf(StartupInfo);

+ 3 - 3
Projects/CompMsgs.pas

@@ -184,9 +184,9 @@ const
   SCompilerEntryInvalid2 = 'Value of [%s] section directive "%s" is invalid';
   SCompilerEntryAlreadySpecified = '[%s] section directive "%s" already specified';
   SCompilerAppVersionOrAppVerNameRequired = 'The [Setup] section must include an AppVersion or AppVerName directive';
-  SCompilerMinVersionWinMustBeZero = 'Minimum Windows version specified by MinVersion must be 0. (Windows 95/98/Me are no longer supported.)';
-  SCompilerMinVersionNTTooLow = 'Minimum NT version specified by MinVersion must be at least %s. (Windows Vista/Server 2008 R2 are no longer supported.)';
-  SCompilerMinVersionRecommendation = 'Minimum NT version is set to %s but using %s instead (which is the default) is recommended.';
+  SCompilerMinVersionWinMustBeZero = 'Minimum non NT version specified by MinVersion must be 0. (Windows 95/98/Me are no longer supported.)';
+  SCompilerMinVersionNTTooLow = 'Minimum version specified by MinVersion must be at least %s. (Windows Vista/Server 2008 R2 are no longer supported.)';
+  SCompilerMinVersionRecommendation = 'Minimum version is set to %s but using %s instead (which is the default) is recommended.';
   SCompilerDiskSliceSizeInvalid = 'DiskSliceSize must be between %d and %d, or "max"';
   SCompilerDiskClusterSizeInvalid = 'DiskClusterSize must be between 1 and 32768';
   SCompilerInstallModeObsolete = 'The [%s] section directive "%s" is obsolete and ignored in this version of Inno Setup. Use command line parameters instead.';

+ 1 - 3
Projects/FileClass.pas

@@ -629,9 +629,7 @@ const
 begin
   inherited Create;
 
-  { Dynamically import RtlNtStatusToDosError since Windows 95 doesn't have it }
-  if not Assigned(_RtlNtStatusToDosError) and
-     (Win32Platform = VER_PLATFORM_WIN32_NT) then
+  if not Assigned(_RtlNtStatusToDosError) then
     _RtlNtStatusToDosError := GetProcAddress(GetModuleHandle('ntdll.dll'),
       'RtlNtStatusToDosError');
 

+ 1 - 2
Projects/InstFunc.pas

@@ -1269,8 +1269,7 @@ end;
 
 procedure RefreshEnvironment;
 { Notifies other applications (Explorer) that environment variables have
-  changed. Based on code from KB article 104011.
-  Note: Win9x's Explorer ignores this message. }
+  changed. Based on code from KB article 104011. }
 var
   MsgResult: DWORD_PTR;
 begin

+ 0 - 12
Projects/Main.pas

@@ -258,7 +258,6 @@ function ShouldProcessRunEntry(const WizardComponents, WizardTasks: TStringList;
   const RunEntry: PSetupRunEntry): Boolean;
 function TestPassword(const Password: String): Boolean;
 procedure UnloadSHFolderDLL;
-function WindowsVersionAtLeast(const AMajor, AMinor: Byte): Boolean;
 
 implementation
 
@@ -302,18 +301,11 @@ type
 
 { Misc. functions }
 
-function WindowsVersionAtLeast(const AMajor, AMinor: Byte): Boolean;
-begin
-  Result := (WindowsVersion >= Cardinal((AMajor shl 24) or (AMinor shl 16)));
-end;
-
 function GetUninstallRegKeyBaseName(const ExpandedAppId: String): String;
-{$IFDEF UNICODE}
 var
   UseAnsiCRC32: Boolean;
   S: AnsiString;
   I: Integer;
-{$ENDIF}
 begin
   { Set uninstall registry key base name }
   Result := ExpandedAppId;
@@ -325,7 +317,6 @@ begin
       resulting string is 57 characters long. On Unicode, only do this if we
       can get a CRC32 compatible with ANSI versions, else there's no point
       in shortening since Unicode doesn't run on Win95. }
-{$IFDEF UNICODE}
     UseAnsiCRC32 := True;
     for I := 1 to Length(Result) do begin
       if Ord(Result[I]) > 126 then begin
@@ -337,9 +328,6 @@ begin
       S := AnsiString(Result);
       FmtStr(Result, '%.48s~%.8x', [Result, GetCRC32(S[1], Length(S)*SizeOf(S[1]))]);
     end;
-{$ELSE}
-    FmtStr(Result, '%.48s~%.8x', [Result, GetCRC32(Result[1], Length(Result)*SizeOf(Result[1]))]);
-{$ENDIF}
   end;
 end;
 

+ 10 - 15
Projects/RegSvr.pas

@@ -2,7 +2,7 @@ unit RegSvr;
 
 {
   Inno Setup
-  Copyright (C) 1997-2012 Jordan Russell
+  Copyright (C) 1997-2024 Jordan Russell
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
 
@@ -53,8 +53,7 @@ end;
 
 function RenameToNonRandomTempName(const Filename: String): String;
 { Renames Filename to a name in the format: isRS-nnn.tmp. Returns the new
-  filename if successful, or '' if not.
-  Note: This is an NT-only function, as it calls MoveFileEx. }
+  filename if successful, or '' if not. Calls MoveFileEx. }
 var
   Path, NewFilename: String;
   Attribs: DWORD;
@@ -91,18 +90,14 @@ var
   SelfFilename, NewFilename: String;
 begin
   SelfFilename := NewParamStr(0);
-  if Win32Platform = VER_PLATFORM_WIN32_NT then begin
-    { On NT, RestartReplace will fail if the user doesn't have admin
-      privileges. We don't want to leak temporary files, so try to rename
-      ourself to a non-random name. This way, future runs should just keep
-      overwriting the same temp file. }
-    DeleteOldTempFiles(PathExtractPath(SelfFilename));
-    NewFilename := RenameToNonRandomTempName(SelfFilename);
-    if NewFilename <> '' then
-      RestartReplace(False, NewFilename, '')
-    else
-      RestartReplace(False, SelfFilename, '');
-  end
+  { RestartReplace will fail if the user doesn't have admin
+    privileges. We don't want to leak temporary files, so try to rename
+    ourself to a non-random name. This way, future runs should just keep
+    overwriting the same temp file. }
+  DeleteOldTempFiles(PathExtractPath(SelfFilename));
+  NewFilename := RenameToNonRandomTempName(SelfFilename);
+  if NewFilename <> '' then
+    RestartReplace(False, NewFilename, '')
   else
     RestartReplace(False, SelfFilename, '');
 end;

+ 0 - 54
Projects/SelLangForm.pas

@@ -42,24 +42,6 @@ uses
 
 {$R *.DFM}
 
-var
-  DefComboWndProcW, PrevComboWndProc: Pointer;
-
-function NewComboWndProc(Wnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT;
-stdcall;
-begin
-  case Msg of
-    { CB_ADDSTRING must pass to the default Unicode combo box window procedure
-      since PrevWndProc is an ANSI window procedure and calling it would result
-      in Unicode->ANSI conversion. Do the same for CB_GETLBTEXT(LEN) so that
-      MSAA sees Unicode strings. }
-    CB_ADDSTRING, CB_GETLBTEXT, CB_GETLBTEXTLEN:
-      Result := CallWindowProcW(DefComboWndProcW, Wnd, Msg, wParam, lParam)
-  else
-    Result := CallWindowProcW(PrevComboWndProc, Wnd, Msg, wParam, lParam);
-  end;
-end;
-
 function AskForLanguage: Boolean;
 { Creates and shows the "Select Language" dialog. Returns True and activates
   the selected language if the user clicks OK, or False otherwise. }
@@ -67,47 +49,13 @@ var
   LangForm: TSelectLanguageForm;
   I, J: Integer;
   LangEntry: PSetupLanguageEntry;
-{$IFNDEF UNICODE}
-  ClassInfo: TWndClassW;
-  N: String;
-{$ENDIF}
 begin
   LangForm := TSelectLanguageForm.Create(Application);
   try
-{$IFNDEF UNICODE}
-    { On NT, make it possible to add Unicode strings to our ANSI combo box by
-      installing a window procedure with special CB_ADDSTRING handling.
-      Yeah, this is a hack; it's too hard to create a native Unicode control
-      in Delphi. }
-    if Win32Platform = VER_PLATFORM_WIN32_NT then begin
-      if GetClassInfoW(0, 'COMBOBOX', ClassInfo) then begin
-        DefComboWndProcW := ClassInfo.lpfnWndProc;
-        Longint(PrevComboWndProc) := SetWindowLongW(LangForm.LangCombo.Handle,
-          GWL_WNDPROC, Longint(@NewComboWndProc));
-      end;
-    end;
-{$ENDIF}
-
     for I := 0 to Entries[seLanguage].Count-1 do begin
       LangEntry := Entries[seLanguage][I];
-{$IFDEF UNICODE}
       J := LangForm.LangCombo.Items.Add(LangEntry.LanguageName);
       LangForm.LangCombo.Items.Objects[J] := TObject(I);
-{$ELSE}
-      if (I = ActiveLanguage) or (LangEntry.LanguageCodePage = 0) or
-         (LangEntry.LanguageCodePage = GetACP) or
-         (shShowUndisplayableLanguages in SetupHeader.Options) then begin
-        { Note: LanguageName is Unicode }
-        N := LangEntry.LanguageName + #0#0;  { need wide null! }
-        if Win32Platform = VER_PLATFORM_WIN32_NT then
-          J := SendMessageW(LangForm.LangCombo.Handle, CB_ADDSTRING, 0,
-            Longint(PWideChar(Pointer(N))))
-        else
-          J := LangForm.LangCombo.Items.Add(WideCharToString(PWideChar(Pointer(N))));
-        if J >= 0 then
-          LangForm.LangCombo.Items.Objects[J] := TObject(I);
-      end;
-{$ENDIF}
     end;
 
    { If there's multiple languages, select the previous language, if available }
@@ -150,9 +98,7 @@ constructor TSelectLanguageForm.Create(AOwner: TComponent);
 begin
   inherited;
 
-{$IFDEF IS_D7}
   MainPanel.ParentBackground := False;
-{$ENDIF}
 
   InitializeFont;