Parsi Coders
C++ GetOS - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Software Development Programming (http://parsicoders.com/forumdisplay.php?fid=37)
+--- انجمن: C and C++ (http://parsicoders.com/forumdisplay.php?fid=54)
+--- موضوع: C++ GetOS (/showthread.php?tid=1026)



C++ GetOS - Amin_Mansouri - 10-11-2011

با سورس زیر متیونید نوع سیستم عامل رو شناسایی کنید.
کد:
void GetOS(char theos[256])
{
OSVERSIONINFO OS;
OS.dwOSVersionInfoSize = sizeof(OS);
GetVersionEx(&OS);
    switch (OS.dwPlatformId)
    {
    case 0:
        strcpy(theos,"Win3.1");
        break;
    case 1:
        switch (OS.dwMinorVersion)
        {
        case 0:
            strcpy(theos,"Win95");
            break;
        case 10:
            strcpy(theos,"Win98");
            break;
        case 98:
            strcpy(theos,"WinMe");
            break;
        }
        break;
    case 2:
        switch (OS.dwMajorVersion)
        {
        case 3:
            strcpy(theos,"WinNT");
            break;
        case 4:
            strcpy(theos,"WinNT");
            break;
        case 5:
            switch (OS.dwMinorVersion)
            {
            case 0:
                strcpy(theos,"Win2000");
                break;
            case 1:
                strcpy(theos,"WinXP");
                break;
            }
            break;

        case 6:
            switch (OS.dwMinorVersion)
            {
            case  0:
                strcpy(theos,"Vista");
                break;
            case 1:
                strcpy(theos,"Win7");
                break;
            }
            break;
        }
        break;
    }