[英]Tell difference between Vista and XP [C]
Is their a way in C to diferentiate between Vista and XP. 是他们在C中区分Vista和XP的一种方法。 Reason being is the the path I use is different in both.
原因是两者使用的路径都不相同。
You can get the version of your Windows OS by calling GetVersionEx
. 您可以通过调用
GetVersionEx
来获取Windows操作系统的版本。
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof vi;
GetVersionEx(&vi);
if (vi.dwMajorVersion >= 6)
// Windows Vista or newer
else
// Windows XP or older
You shouldn't have platform specific paths hard-coded into your application. 您不应将平台特定的路径硬编码到您的应用程序中。 There are environment variables for these things.
这些东西有环境变量。
Open up a command prompt and type "set" to view a list of them. 打开命令提示符并键入“ set”以查看它们的列表。 Several of these have been standard since Windows 95. Important environment variables to note are...
自Windows 95以来,其中一些已成为标准。要注意的重要环境变量是...
So for example... 例如
char * path; path = getenv("HOME"); printf(path);
Have a poke around your target versions of windows to see what variables are common between the two. 围绕您的Windows目标版本查看一下两者之间共有哪些变量。
edit: python has made me lazy with string manipulation, fixed example code. 编辑:python使我懒于字符串操作和固定的示例代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.