MSDN上有详细介绍,做个标记:
#include <windows.h>
#include <stdio.h>
void main()
{
OSVERSIONINFO osvi;
BOOL bIsWindowsXPorLater;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
bIsWindowsXPorLater =
( (osvi.dwMajorVersion > 5) ||
( (osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion >= 1) ));
if(bIsWindowsXPorLater)
printf("The system meets the requirements.\n");
else printf("The system does not meet the requirements.\n");
}
Operating System Version (Windows)
Operating system Version number
Windows 8 6.2
Windows Server 2012 6.2
Windows 7 6.1
Windows Server 2008 R2 6.1
Windows Server 2008 6.0
Windows Vista 6.0
Windows Server 2003 R2 5.2
Windows Server 2003 5.2
Windows XP 64-Bit Edition5.2
Windows XP 5.1
Windows 2000 5.0
http://msdn.microsoft.com/ZH-CN/library/windows/desktop/ms724832(v=vs.85).aspx
//使用控制台打开另外的程序,并把控制台隐藏掉
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
#include <Windows.h>
int main()
{
/*以下启动另一exe*/
SHELLEXECUTEINFO ShExecInfo;
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = NULL;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = ("E:\\Work_Project\\ParaExe\\ParaExe\\bin\\Debug\\ParaExe.exe");
ShExecInfo.lpParameters = NULL;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_MAXIMIZE;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
/*以下检测插件安装情况*/
return 0;
}
// ChooseExeVersion.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
typedef struct ExeOsPair_tag
{
char osVersion[300];
char exeVersion[300];
}ExeOsPair;
ExeOsPair g_exeOsPairs[100];
int g_exeOsPairsSize = 0;
int AddExeOsParis(const char *osVersion, const char* exeVersion)
{
strcpy(g_exeOsPairs[g_exeOsPairsSize].exeVersion, exeVersion);
strcpy(g_exeOsPairs[g_exeOsPairsSize].osVersion, osVersion);
g_exeOsPairsSize++;
return 0;
}
//int _tmain(int argc, _TCHAR* argv[])
int main()
{
/*****************************************************/
//add new exe and os pairs here
/*
Operating System Version (Windows):
http://msdn.microsoft.com/ZH-CN/library/windows/desktop/ms724832(v=vs.85).aspx
Operating systemVersion number
Windows 86.2
Windows Server 20126.2
Windows 76.1
Windows Server 2008 R26.1
Windows Server 20086.0
Windows Vista6.0
Windows Server 2003 R25.2
Windows Server 20035.2
Windows XP5.1
Windows 20005.0
*/
AddExeOsParis("6.1", "notepad.exe f:\\调用程序.txt");
AddExeOsParis("6.0", "2.exe");
AddExeOsParis("5.1", "3.exe");
/*****************************************************/
OSVERSIONINFO osvi;
BOOL bIsWindowsXPorLater;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (GetVersionEx(&osvi) == 0)
{
printf("Error: %d\n", GetLastError());
return -1;
}
char osVersion[100];
sprintf(osVersion, "%d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion);
#ifdef _DEBUG
printf("Version is %d.%d (%d)\n",
osvi.dwMajorVersion,
osvi.dwMinorVersion,
osvi.dwBuildNumber);
#endif
for (int i = 0; i< g_exeOsPairsSize; ++i)
{
if (strcmp(g_exeOsPairs.osVersion, osVersion) == 0)
{
WinExec(g_exeOsPairs.exeVersion, SW_SHOW);
break;
}
}
return 0;
}
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com