求救~~我想取得操作系统的一些相关信息,比如版本号,,怎么取得?有没有代码,发一个例子~谢谢了(0分)

  • 主题发起人 主题发起人 dabing
  • 开始时间 开始时间
D

dabing

Unregistered / Unconfirmed
GUEST, unregistred user!
求救~~我想取得操作系统的一些相关信息,比如版本号,,怎么取得?有没有代码,发一个例子~谢谢了
 
给一点分,我给你一个例子!!
 
GetMem(VerBuf, InfoSize); //申请内存<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; if GetFileVersionInfo(PChar(FileName), Wnd, InfoSize, VerBuf) then //获取版本信息<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Value := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; VerQueryValue(VerBuf, '/VarFileInfo/Translation', Value, Len); //读出有关<br>&nbsp; &nbsp; &nbsp; &nbsp; if Value &lt;&gt; nil then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TransString := IntToHex(MakeLong(HiWord(Longint(Value^)), LoWord(Longint(Value^))), 8);<br>&nbsp; &nbsp; &nbsp; &nbsp; //Get FileVersion<br>&nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(szName, '/StringFileInfo/' + Transstring + '/FileVersion');<br>&nbsp; &nbsp; &nbsp; &nbsp; if VerQueryValue(VerBuf, szName, Value, Len) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FVsFileVersion := StrPas(PChar(Value));<br>&nbsp; &nbsp; &nbsp; &nbsp; //Get CompanyName<br>&nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(szName, '/StringFileInfo/' + Transstring + '/CompanyName');<br>&nbsp; &nbsp; &nbsp; &nbsp; if VerQueryValue(VerBuf, szName, Value, Len) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FVsCompanyName := StrPas(PChar(Value));<br>&nbsp; &nbsp; &nbsp; &nbsp; //Get FileDescription<br>&nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(szName, '/StringFileInfo/' + Transstring + '/FileDescription');<br>&nbsp; &nbsp; &nbsp; &nbsp; if VerQueryValue(VerBuf, szName, Value, Len) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FVsFileDescription := StrPas(PChar(Value));<br>&nbsp; &nbsp; &nbsp; &nbsp; //Get InternalName<br>&nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(szName, '/StringFileInfo/' + Transstring + '/InternalName');<br>&nbsp; &nbsp; &nbsp; &nbsp; if VerQueryValue(VerBuf, szName, Value, Len) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FVsInternalName := StrPas(PChar(Value));<br>&nbsp; &nbsp; &nbsp; &nbsp; //Get LegalCopyright<br>&nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(szName, '/StringFileInfo/' + Transstring + '/LegalCopyright');<br>&nbsp; &nbsp; &nbsp; &nbsp; if VerQueryValue(VerBuf, szName, Value, Len) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FVsLegalCopyright := StrPas(PChar(Value));<br>&nbsp; &nbsp; &nbsp; &nbsp; //Get OriginalFilename<br>&nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(szName, '/StringFileInfo/' + Transstring + '/OriginalFilename');<br>&nbsp; &nbsp; &nbsp; &nbsp; if VerQueryValue(VerBuf, szName, Value, Len) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FVsOriginalFilename := StrPas(PChar(Value));<br>&nbsp; &nbsp; &nbsp; &nbsp; //Get ProductName<br>&nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(szName, '/StringFileInfo/' + Transstring + '/ProductName');<br>&nbsp; &nbsp; &nbsp; &nbsp; if VerQueryValue(VerBuf, szName, Value, Len) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FVsProductName := StrPas(PChar(Value));<br>&nbsp; &nbsp; &nbsp; &nbsp; //Get ProductVersion<br>&nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(szName, '/StringFileInfo/' + Transstring + '/ProductVersion');<br>&nbsp; &nbsp; &nbsp; &nbsp; if VerQueryValue(VerBuf, szName, Value, Len) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FVsProductVersion := StrPas(PChar(Value));<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; FIsVerInfo := true;<br>&nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; FreeMem(VerBuf);<br>&nbsp; &nbsp; end;
 
function GetWinVersion: String;<br>&nbsp; var<br>&nbsp; &nbsp; &nbsp;OSName &nbsp; &nbsp; &nbsp;: String;<br>&nbsp; begin<br>&nbsp; &nbsp; &nbsp;// set the size of the record<br>&nbsp; &nbsp; &nbsp;VersionInfo.dwOSVersionInfoSize := SizeOf( TOSVersionInfo );<br><br>&nbsp; &nbsp; &nbsp;if Windows.GetVersionEx( VersionInfo ) then<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;with VersionInfo do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case dwPlatformId of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;VER_PLATFORM_WIN32s &nbsp; : OSName := 'Win32s';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;VER_PLATFORM_WIN32_WINDOWS : OSName := 'Windows 95';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;VER_PLATFORM_WIN32_NT &nbsp; &nbsp; &nbsp;: OSName := 'Windows NT';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; // case dwPlatformId<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if osname='Windows NT' then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if dwMinorVersion=0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; osname:='Windows 2000'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if dwMinorVersion=1 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; osname:='Windows XP';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result := OSName + ' 版本 ' + IntToStr( dwMajorVersion ) + '.' + IntToStr( dwMinorVersion ) +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #13#10' (内部版本 ' + IntToStr( dwBuildNumber ) + ': ' + szCSDVersion + ')';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end; // with VersionInfo<br>&nbsp; &nbsp; &nbsp; &nbsp; end // if GetVersionEx<br>&nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; Result := '';<br>&nbsp; end;
 
后退
顶部