
var
Info: OSVERSIONINFO
begin
FillChar(Info, sizeof(Info), 0)
Info.dwOSVersionInfoSize := sizeof(OSVERSIONINFO)
GetVersionEx(Info)
end
//完全没问题,我的是win8 ,取的版本号是6.2.9200
delphiXE如何判断 *** 作系统是win7还是winXP?delphi7的代码在XE上无效,没有那些函数,有哪位大大知道如何准确判断吗?不知道xe有没有这方面的函数
Msdn查一下GetVersionEx这个函数,
看下Getting the System Version 这个例子
我在偶的Vs2010的msdn里搜索到的
D7上的可以话, 可以写在DLL, 然后调用通过返回值来判断.
XE比d7不是强一点半点,难道没有直接获取系统版本的函数?或更方便的方法?
以下代码 XE + XP下正确, WIN 7没有条件测试
Delphi/Pascal code?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function GetWindowsVersionString: AnsiString
var
ver: _OSVERSIONINFOA
begin
if GetVersionExA(ver) then
with ver do
Result := Trim(
Format(
'%d.%d build %d %s',
[dwMajorVersion, dwMinorVersion, dwBuildNumber, szCSDVersion]))
else
Result := ''
end
function GetWindowsVersion: String// 读取 *** 作系统版本
var
AWin32Version: Extended
os: string
begin
os := 'Windows '
AWin32Version := StrtoFloat(Format('%d.%d', [Win32MajorVersion, Win32MinorVersion]))
if Win32Platform = VER_PLATFORM_WIN32S then
Result := os + '32'
else if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then
begin
if AWin32Version = 4.0 thenResult := os + '95'
else if AWin32Version = 4.1 then Result := os + '98'
else if AWin32Version = 4.9 then Result := os + 'Me'
else Result := os + '9x'
end
else if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
if AWin32Version = 3.51 thenResult := os + 'NT 3.51'
else if AWin32Version = 4.0 thenResult := os + 'NT 4.0'
else if AWin32Version = 5.0 thenResult := os + '2000'
else if AWin32Version = 5.1 thenResult := os + 'XP'
else if AWin32Version = 5.2 thenResult := os + '2003'
else if AWin32Version = 6.0 thenResult := os + 'Vista'
else if AWin32Version = 6.1 thenResult := os + '7'
elseResult := os
end
else Result := os + '??'
Result := Result + ' ' + GetWindowsVersionString
end
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)