我看的例子只是给出Size,调用它,它会自动将值填充到里面吧
procedure BUtton1.Onclick(Sender: TObject);
var
OSVersionInfo: TOSVersionInfo;
begin
OSVersionInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
GetVersionEx(OSVersionInfo);
with OSVersionInfo do
if dwPlatformId = VER_PLATFORM_WIN32_NT then
ShowMessage('OSVersion : WinNT')
else
if dwPlatformID = VER_PLATFORM_WIN32_WINDOWS then
Showmessage('OSVersion := Windows')
else
if dwPlatformID = VER_PLATFORM_WIN32s then
ShowMessage('OSVersion: Win31');
end;
procedure BUtton1.Onclick(Sender: TObject);
var
OSVersionInfo: TOSVersionInfo;
begin
OSVersionInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
GetVersionEx(OSVersionInfo);
with OSVersionInfo do
if dwPlatformId = VER_PLATFORM_WIN32_NT then
ShowMessage('OSVersion : WinNT')
else
if dwPlatformID = VER_PLATFORM_WIN32_WINDOWS then
Showmessage('OSVersion := Windows')
else
if dwPlatformID = VER_PLATFORM_WIN32s then
ShowMessage('OSVersion: Win31');
end;
解决方案 »
- cxGrid如何实现此功能?
- 有没有显示目录树的控件?
- 关于edit控件显示问题,不是很难
- 动态创建线程?
- 表输入数据时如何防止数据误操作呢,我想破头了,帮忙!!!
- 请教有关在delphi下查询sql server或者access2000下unicode类型的数据
- 紧急!请问如何将EXCEL的提示信息屏蔽!
- 大家用过Delphi7开发web应用吗?据说Delphi7里有一套工具用来开发web非常方便,有这回事吗?
- 请教各位:如何利用filtercombobox控件?
- 三层结构中,两个不明白的问题,请帮忙。谢谢。
- 定义了一个tedit数组,怎样给每个数组成员定义触发事件,例如ONEXIT?
- 我的delphi程序不能在其他机器上用,是不是我的编译选项要改1下?
function WinVersion:Integer;
var
OSVI:OSVERSIONINFO;
begin
Result:=-1;
OSVI.dwOSVersionInfoSize:=SizeOf(OSVERSIONINFO);
GetVersionEx(OSVI);
if OSVI.dwPlatformId=2 then
begin
case OSVI.dwMajorVersion of
4:Result:=2;
5:Result:=3;
end;
end
else
Result:=OSVI.dwPlatformId;
{
返回值:
为0表示为win3x系统;
为1表示为win9x系统;
为2表示为winNT;
为3表示为win2000系统;
}
end;
可以判断 Win2K的版本、安装的系统服务等关键的问题不是取得wSuiteMask和wProductType的值,而是通过社么途径找资料可以获得这些值,关于结构_OSVERSIONINFOEXAtypedef struct _OSVERSIONINFOEX在Delphi6中也没有定义,真是令人费解。我自己定义了一个_OSVERSIONINFOEX结构,也能获得返回值(整数),但是没法把数值和这些参数CONST对应上去,苦恼啊!!!
typedef struct _OSVERSIONINFOEXA {
DWORD dwOSVersionInfoSize;
DWORD dwMajorVersion;
DWORD dwMinorVersion;
DWORD dwBuildNumber;
DWORD dwPlatformId;
TCHAR szCSDVersion[ 128 ];
WORD wServicePackMajor;
WORD wServicePackMinor;
WORD wReserved[2];
} OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
没办法呀。
This function obtains extended information about the version of the operating system that is currently running. A remote application interface (RAPI) version of this function exists, and it is named CeGetVersionEx.BOOL GetVersionEx(
LPOSVERSIONINFO lpVersionInformation);
Parameters
lpVersionInformation
[out] Pointer to an OSVERSIONINFO data structure that the function fills with operating system version information.
Before calling the GetVersionEx function, set the dwOSVersionInfoSize member of the OSVERSIONINFO data structure to sizeof(OSVERSIONINFO). Return Values
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError. The function fails if you specify an invalid value for the dwOSVersionInfoSize member of the OSVERSIONINFO. Res
When using the GetVersionEx function to determine whether your application is running on a particular version of the operating system, check for version numbers that are greater than or equal to the desired version numbers. This ensures that the test succeeds for later versions of the operating system. For example, if your application requires Windows 98, use the following test:GetVersionEx (&osvi);
bIsWindows98orLater =
(osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
( (osvi.dwMajorVersion > 4) ||
( (osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0) ) );
Identifying the current operating system is usually not the best way to determine whether a particular operating system feature is present. This is because the operating system may have had new features added in a redistributable DLL. Rather than using GetVersionEx to determine the operating system platform or version number, test for the presence of the feature itself.To determine the best way to test for a feature, refer to the documentation for the feature of interest. The following list discusses some common techniques for feature detection: You can test for the presence of the functions associated with a feature. To test for the presence of a function in a system DLL, call the LoadLibrary function to load the DLL. Then call the GetProcAddress function to determine whether the function of interest is present in the DLL. Use the pointer returned by GetProcAddress to call the function. Note that even if the function is present, it may be a stub that just returns an error code such as ERROR_CALL_NOT_IMPLEMENTED.
You can determine the presence of some features by using the GetSystemMetrics function. For example, you can detect multiple display monitors by calling GetSystemMetrics(SM_CMONITORS).
There are several versions of the redistributable DLLs that implement shell and common control features.
The value of the dwPlatformID member of the OSVERSIONINFO structure will be VER_PLATFORM_WIN32_CE.When writing applications for the Japanese version of Handheld PC Edition software, be aware that the toolbar indicates that the version is 2.0.Requirements Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winbase.h Coremain.lib Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.See Also
CeGetVersionEx, GetLastError, GetProcAddress, GetSystemMetrics, LoadLibrary, OSVERSIONINFO Built on Wednesday, February 14, 2001
GetVersionEx
The GetVersionEx function obtains extended information about the version of the operating system that is currently running.Windows 2000 or later: To compare the current system version to a required version, use the VerifyVersionInfo function instead of using GetVersionEx to perform the comparison yourself. BOOL GetVersionEx(
LPOSVERSIONINFO lpVersionInfo // version information
);
Parameters
lpVersionInfo
[in/out] Pointer to an OSVERSIONINFO data structure that the function fills with operating system version information.
Before calling the GetVersionEx function, set the dwOSVersionInfoSize member of the OSVERSIONINFO data structure to sizeof(OSVERSIONINFO). Windows NT 4.0 SP6 and later: This member can be a pointer to an OSVERSIONINFOEX structure. Set the dwOSVersionInfoSize member to sizeof(OSVERSIONINFOEX) to identify the structure type. Return Values
If the function succeeds, the return value is a nonzero value.If the function fails, the return value is zero. To get extended error information, call GetLastError. The function fails if you specify an invalid value for the dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure. Res
When using the GetVersionEx function to determine whether your application is running on a particular version of the operating system, check for version numbers that are greater than or equal to the desired version numbers. This ensures that the test succeeds for later versions of the operating system. For example, if your application requires Windows 98, use the following test:osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO)
GetVersionEx (&osvi);
bIsWindows98orLater =
(osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
( (osvi.dwMajorVersion > 4) ||
( (osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0) ) );
Identifying the current operating system is usually not the best way to determine whether a particular operating system feature is present. This is because the operating system may have had new features added in a redistributable DLL. Rather than using GetVersionEx to determine the operating system platform or version number, test for the presence of the feature itself. For more information, see Operating System Version. Example
For an example, see Getting the System Version. Requirements
Windows NT/2000 or later: Requires Windows NT 3.5 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.See Also
System Information Overview, System Information Functions, GetVersion, OSVERSIONINFO, OSVERSIONINFOEX, VerifyVersionInfo Microsoft Platform SDK, February 2001 Edition.
This content last built on Thursday, February 01, 2001.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, CommDlg;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TOSVersion = (osUnknown, os95, os95OSR2, os98, os98SE, osNT3, osNT4, os2K, osME, osXP);var
Form1: TForm1;implementation{$R *.DFM}function GetOS :TOSVersion;
var
OS :TOSVersionInfo;
begin
ZeroMemory(@OS,SizeOf(OS));
OS.dwOSVersionInfoSize:=SizeOf(OS);
GetVersionEx(OS);
Result:=osUnknown;
if OS.dwPlatformId=VER_PLATFORM_WIN32_NT then begin
case OS.dwMajorVersion of
3: Result:=osNT3;
4: Result:=osNT4;
5: Result:=os2K;
end;
if (OS.dwMajorVersion=5) and (OS.dwMinorVersion=1) then
Result:=osXP;
end else begin
if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=0) then begin
Result:=os95;
if (Trim(OS.szCSDVersion)='B') then
Result:=os95OSR2;
end else
if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=10) then begin
Result:=os98;
if (Trim(OS.szCSDVersion)='A') then
Result:=os98SE;
end else
if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=90) then
Result:=osME;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
os:TosVersion;
osVersion:string;
begin
os:=Getos;
case OS of
os95, os95OSR2: OSVersion:='Windows 95';
os98, os98SE: OSVersion:='Windows 98';
osME: OSVersion:='Windows Millenium Edition';
osNT3, osNT4: OSVersion:='Windows NT';
os2K: OSVersion:='Windows 2000';
osXP: OSVersion:='Windows XP';
end;
showmessage(osversion);
end;end. //---小米(宝祯)
//---2001-8-10
我就不明白微软闲着没事吃饱了撑着定义这么些常量,又不给出常量的数值描述,真是变态
这些资料真不知道去哪儿找wSuiteMask
VER_SUITE_BACKOFFICE Microsoft BackOffice components are installed.
VER_SUITE_DATACENTER Windows 2000 DataCenter Server is installed.
VER_SUITE_ENTERPRISE Windows 2000 Advanced Server is installed.
VER_SUITE_SMALLBUSINESS Microsoft Small Business Server is installed.
VER_SUITE_SMALLBUSINESS_RESTRICTED Microsoft Small Business Server is installed with the restrictive client license in force.
VER_SUITE_TERMINAL Terminal Services is installed.
VER_SUITE_PERSONAL Whistler: Whistler Personal is installed. 有谁能给出常量说明?