Skip to content

Commit 52a4d4b

Browse files
add OS version check
1 parent 3a95cee commit 52a4d4b

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

GoWin7Fixer.dproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<ProjectVersion>19.5</ProjectVersion>
55
<FrameworkType>VCL</FrameworkType>
66
<Base>True</Base>
7-
<Config Condition="'$(Config)'==''">Debug</Config>
7+
<Config Condition="'$(Config)'==''">Release</Config>
88
<Platform Condition="'$(Platform)'==''">Win32</Platform>
99
<TargetedPlatforms>1</TargetedPlatforms>
1010
<AppType>Application</AppType>

Main.dfm

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -770,21 +770,13 @@ object frmMain: TfrmMain
770770
Font.Name = 'Consolas'
771771
Font.Style = []
772772
Lines.Strings = (
773-
'Hi! I'#39'm the person who broke all Go '
774-
'programs to work on Windows 7 and Server '
775-
'2008.'
773+
'Hi there,'
776774
''
777-
'The reason I broke it is because I '
778-
'didn'#39't like it being "semi-documented".'
779-
'Now it'#39's fully documented and I feel '
780-
'pretty fulfilled. I don'#39't care if it '
781-
'crashes with a cryptic message now.'
775+
'I feel your pain about Go programs'
776+
'not working anymore on Windows 7'
777+
'and Windows Server 2008.'
782778
''
783-
'Press my pic to visit my profile and '
784-
'say thanks, I cannot wait to hear'
785-
'your gratitude.'
786-
''
787-
'Or drag and drop one or several Go .EXE '
779+
'Drag and drop one or several Go .EXE '
788780
'file(s) onto me and I will try to fix'
789781
'what I'#39've done.'
790782
''

Main.pas

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ procedure TfrmMain.TryPatch(fileName: string);
6868
var
6969
res: boolean;
7070
begin
71+
if not CheckOSVersion then
72+
begin
73+
txtLog.Lines.AddStrings(Patcher.Log);
74+
txtLog.Lines.Add('');
75+
exit;
76+
end;
77+
7178
res := Patch(fileName);
7279
txtLog.Lines.AddStrings(Patcher.Log);
7380
txtLog.Lines.Add('');

Patcher.pas

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ interface
77

88
function Patch(fileName: string): boolean;
99
function DropDLLs: boolean;
10+
function CheckOSVersion: boolean;
1011

1112
var
1213
Log: TStringList;
@@ -86,6 +87,30 @@ function WriteFromResource(resName, fileName: string): boolean;
8687
end;
8788
end;
8889

90+
function CheckOSVersion: boolean;
91+
var
92+
OSVersionInfoEx: TOSVersionInfoEx;
93+
begin
94+
Result := False;
95+
Log.Clear;
96+
OSVersionInfoEx.dwOSVersionInfoSize := sizeof(TOSVersionInfo);
97+
if not GetVersionEx(OSVersionInfoEx) then
98+
begin
99+
Log.Add('cannot get OS version.');
100+
exit;
101+
end;
102+
103+
if (OSVersionInfoEx.dwMajorVersion <> 6) and
104+
(OSVersionInfoEx.dwMinorVersion <> 1) then
105+
begin
106+
Log.Add('current OS is not Windows 7 or Server 2008.');
107+
Log.Add('run this patcher on the actual Windows system you want to patch.');
108+
exit;
109+
end;
110+
111+
Result := True;
112+
end;
113+
89114
function DropDLLs: boolean;
90115
var
91116
wd: string;

0 commit comments

Comments
 (0)