请问有个函数判断是否是2000还是98,在XP与WIN2000里函数是一样的吗?(10分)

  • 主题发起人 主题发起人 aipingren
  • 开始时间 开始时间
A

aipingren

Unregistered / Unconfirmed
GUEST, unregistred user!
就是说怎么区别是XP还是WIN2000操作系统?用什么函数?
 
可以通过读注册表来判断
 
Windows API<br>GetVersionEx<br>The GetVersionEx function obtains extended information about the version of the operating system that is currently running.<br><br>BOOL GetVersionEx(<br><br>&nbsp; &nbsp; LPOSVERSIONINFO lpVersionInformation // pointer to version information structure<br>&nbsp; &nbsp;); <br>&nbsp;<br><br>Parameters<br><br>lpVersionInformation<br><br>Pointer to an OSVERSIONINFO data structure that the function fills with operating system version information.<br>Before calling the GetVersionEx function, set the dwOSVersionInfoSize member of the OSVERSIONINFO data structure to <br>sizeof(OSVERSIONINFO).<br><br>&nbsp;<br><br>Return Values<br><br>If the function succeeds, the return value is nonzero.<br>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 structure. <br><br>Remarks<br><br>The GetVersionEx function supersedes the GetVersion function and is the preferred method for obtaining operating system version number information. New applications should use the GetVersionEx function rather than the GetVersion function.<br><br>See Also<br><br>OSVERSIONINFO<br><br>------------------------<br><br>The OSVERSIONINFO data structure contains operating system version information. The information includes major and minor version numbers, a build number, a platform identifier, and descriptive text about the operating system. This structure is used with the GetVersionEx function.<br><br>typedef struct _OSVERSIONINFO{ &nbsp;<br>&nbsp; &nbsp; DWORD dwOSVersionInfoSize; <br>&nbsp; &nbsp; DWORD dwMajorVersion; <br>&nbsp; &nbsp; DWORD dwMinorVersion; <br>&nbsp; &nbsp; DWORD dwBuildNumber; <br>&nbsp; &nbsp; DWORD dwPlatformId; <br>&nbsp; &nbsp; TCHAR szCSDVersion[ 128 ]; <br>} OSVERSIONINFO; <br>&nbsp;<br><br>Members<br><br>dwOSVersionInfoSize<br><br>Specifies the size, in bytes, of this data structure. Set this member to sizeof(OSVERSIONINFO) before calling the GetVersionEx function.<br><br>dwMajorVersion<br><br>Identifies the major version number of the operating system. For example, for Windows NT version 3.51, the major version number is 3; and for Windows NT version 4.0, the major version number is 4.<br><br>dwMinorVersion<br><br>Identifies the minor version number of the operating system. For example, for Windows NT version 3.51, the minor version number is 51; and for Windows NT version 4.0, the minor version number is 0.<br><br>dwBuildNumber<br><br>Windows NT: Identifies the build number of the operating system.<br>Windows 95: Identifies the build number of the operating system in the low-order word. The high-order word contains the major and minor version numbers.<br><br>dwPlatformId<br><br>Identifies the operating system platform. This member can be one of the following values: <br><br>Value Platform<br>VER_PLATFORM_WIN32s Win32s on Windows 3.1. <br>VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95.<br>VER_PLATFORM_WIN32_NT Win32 on Windows NT.<br>&nbsp;<br><br>szCSDVersion<br><br>Windows NT: Contains a null-terminated string, such as "Service Pack 3", that indicates the latest Service Pack installed on the system. If no Service Pack has been installed, the string is empty.<br>Windows 95: Contains a null-terminated string that provides arbitrary additional information about the operating system.
 
对头,就是:<br>if Win32Platform = VER_PLATFORM_WIN32_NT then<br>&nbsp; &nbsp;MessageBox(0,'当前系统是 2000 or XP','Platform Test',mb_Ok);<br>If Win32Platform = VER_PLATFORM_WIN32_WINDOWS Then<br>&nbsp; &nbsp;MessageBox(0,'当前系统是 95 or 98 or ME','Platform Test',mb_Ok);<br><br>更详细的讨论在:<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=1358134
 
Open you MSDN and type GetVersionEx !<br>
 
接受答案了.
 
后退
顶部