0
I’m having trouble in a routine that identifies the windows version. In case I’m using Delphi 7, I put the routine in a program that solves and puts in a textbox, beauty worked, I made some changes and perfect the answer checks with the windows operating system I am using 'WINSEVEN00PRO2610000000000' but when I copy the whole routine and put in the system I give maintenance the execution response is WINXP00000PRO2510000000000, different, how to explain and how to solve. Thank you for your cooperation:
const
VER_NT_WORKSTATION :Integer = 1;
VER_SUITE_ENTERPRISE :Integer = 2;
VER_NT_SERVER :Integer = 3;
VER_SUITE_DATACENTER :Integer = 128;
VER_SUITE_PERSONAL :Integer = 512;
vSONAOIDENTIFICADO :String = 'WINDOWS';
vSOWIN9X :String = 'WIN9X';
vSOWIN2000 :String = 'WIN2K';
vSOWINXP :String = 'WINXP';
vSOWINXPpro :String = 'WINXPPRO';
vSOWIN7 :String = 'WINSEVEN';
vSOWIN8 :String = 'WINEIGHT';
vSOVISTA :String = 'WINVISTA';
vULTIMATE :String = 'ULT';
vHOMEPREMIUM :String = 'HPR';
vHOMEBASIC :String = 'HBS';
vPROFESSIONAL :String = 'PRO';
vSTANDARD :String = 'STD';
function TForm1.GetSO: string;
function CompletarZeros(sString: string; iTamanho: Integer): String;
begin
Result := sString;
while Length(Result) < iTamanho do
Result := Result+'0';
end;
var
NTBres, BRes: Boolean;
verInfo: TOSVersionInfo;
verInfo_NT: TOSVersionInfoW;
i: word;
str, ProductName, ProductNameEx, VersionL : string;
pdwReturnedProductType : DWORD;
begin
Result := 'Error';
NTBres := False;
try
verInfo_NT.dwOSVersionInfoSize := SizeOf(TOSVERSIONINFOEX);
NTBRes := GetVersionEx(verInfo);
verInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
BRes := GetVersionEx(verInfo);
except
verInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
BRes := GetVersionEx(verInfo);
end;
if (not BRes) and (not NTBres) then
Exit;
Move( verInfo, verInfo_NT, SizeOf(TOSVersionInfo) );
verInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if GetVersionEx(verInfo) then
VersionL := IntToStr(verInfo.dwPlatformId)+IntToStr(verInfo.dwMajorVersion) + IntToStr(verInfo.dwMinorVersion);
case verInfo.dwPlatformId of
VER_PLATFORM_WIN32s : ProductName := vSOWIN9X;
VER_PLATFORM_WIN32_WINDOWS : ProductName := vSOWIN9X;
VER_PLATFORM_WIN32_NT:
begin
case verInfo.dwMajorVersion of
0..4: ProductName := vSONAOIDENTIFICADO;
5: begin
case verInfo.dwMinorVersion of
0: ProductName := vSOWIN2000;//;//'Windows 2000';
1: ProductName := vSOWINXP;//'Windows XP';
2: productName := vSOWINXPpro;//'Windows XP Prof';
else
Result := IntToStr(verInfo.dwMajorVersion)+IntToStr(verInfo.dwMinorVersion)+ vSONAOIDENTIFICADO;
end;
end;
6: begin
case verInfo.dwMinorVersion of
0:ProductName := vSOVISTA ;//'Windows Vista';
1:ProductName := vSOWIN7;//'Windows 7';
2:ProductName := vSOWIN8;//'Windows 8';
else
ProductName := IntToStr(verInfo.dwMajorVersion)+IntToStr(verInfo.dwMinorVersion)+ vSONAOIDENTIFICADO;
end;
end;
else
ProductName := IntToStr(verInfo.dwMajorVersion)+IntToStr(verInfo.dwMinorVersion)+vSONAOIDENTIFICADO;
end;
end;
ELSE
ProductName := IntToStr(verInfo.dwMajorVersion)+IntToStr(verInfo.dwMinorVersion)+vSONAOIDENTIFICADO
end;
str := '';
ProductNameEx :=IntToStr(verInfo.dwMajorVersion)+IntToStr(verInfo.dwMinorVersion)+vSONAOIDENTIFICADO+IntToStr(-1);
if Assigned ( GetProductInfo) then
begin
ProductNameEx :='';
GetProductInfo(verInfo.dwMajorVersion, verInfo.dwMinorVersion, 0,0, pdwReturnedProductType);
case pdwReturnedProductType of
0: begin
if (verInfo.dwMajorVersion = 5) and (verInfo.dwMinorVersion=1) then
ProductNameEx := vPROFESSIONAL //'Professional'
else
ProductNameEx := vSTANDARD;//'Standard';
end;
1: ProductNameEx:= vULTIMATE;
2: ProductNameEx:= vHOMEBASIC;
3: ProductNameEx:= vHOMEPREMIUM;//'Home Premium';
5: ProductNameEx:= vHOMEBASIC;// 'Home Basic' ;
28: ProductNameEx:= vULTIMATE;// 'Ultimate';
48,49: ProductNameEx:= vPROFESSIONAL;// 'Professional' ;
68: ProductNameEx:= vHOMEPREMIUM;// 'Home Premium';
69: ProductNameEx:= vPROFESSIONAL;// 'Professional';
71: ProductNameEx:= vULTIMATE;// 'Ultimate';
else ;
ProductNameEx :=IntToStr(verInfo.dwMajorVersion)+IntToStr(verInfo.dwMinorVersion)+vSONAOIDENTIFICADO+IntToStr(pdwReturnedProductType);
end;
end;
for I := 0 to 127 do
str := str + verInfo.szCSDVersion[i];
// STR := StringReplace(UpperCase(str), 's', 'S', [rfReplaceAll]);
// STR := StringReplace(UpperCase(str), 'p', 'P', [rfReplaceAll]);
STR := StringReplace(UpperCase(str), ' ', '', [rfReplaceAll]);
STR := Trim(str);
if Length(Version) < 4 then
VersionL := CompletarZeros(VersionL, 4);
if Length(str) < 3 then
str := CompletarZeros(str, 3);
str := str+' >'+IntToStr(pdwReturnedProductType);
Result := CompletarZeros(ProductName,10)+CompletarZeros(ProductNameEx+VersionL,16); //+ Version + str;
end;
What is the version of the other S.O?
– stderr
WINDOWS 7 PROFESSIONAL 32
– Luiz Vichiatto