⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dtwinver.cpp

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 CPP
📖 第 1 页 / 共 3 页
字号:
      // a multinet driver is installed
      if (LOBYTE(wNetType) & WNNC_SUBNET_WinWorkgroups) // It is WFW
        rVal = TRUE;
      else // It is not WFW
        rVal = FALSE;
    }
    else
     rVal = FALSE;
  }
  else
    rVal = FALSE;
   
  // Clean up the module instance
  if (hUserInst)
    FreeLibrary(hUserInst);
    
  return rVal;  
}
#endif //defined(_WINDOWS) && !defined(_WIN32)
             
#ifdef _DOS             
void GetWinInfo()
{ 
  BYTE MajorVer;
  BYTE MinorVer;

  //use some inline assembly to determine if Windows if
  //running and what version is active
  _asm
  {
  ; check for Windows 3.1
    mov     ax,160ah                ; WIN31CHECK
    int     2fh                     ; check if running under Win 3.1.
    or      ax,ax
    jz      RunningUnderWin31       ; can check if running in standard
                                    ; or enhanced mode
   
  ; check for Windows 3.0 enhanced mode
    mov     ax,1600h                ; WIN386CHECK
    int     2fh
    test    al,7fh
    jnz     RunningUnderWin30Enh    ; enhanced mode
   
  ; check for 3.0 WINOLDAP
    mov     ax,4680h                ; IS_WINOLDAP_ACTIVE
    int     2fh
    or      ax,ax                   ; running under 3.0 derivative?
    jnz     NotRunningUnderWin
   
  ; rule out MS-DOS 5.0 task switcher
    mov     ax,4b02h                ; detect switcher
    push    bx
    push    es
    push    di
    xor     bx,bx
    mov     di,bx
    mov     es,bx
    int     2fh
    pop     di
    pop     es
    pop     bx
    or      ax,ax
    jz      NotRunningUnderWin      ; MS-DOS 5.0 task switcher found
   
  ; check for standard mode Windows 3.0
    mov     ax,1605h                ; PMODE_START
    int     2fh
    cmp     cx,-1
    jz      RunningUnderWin30Std
   
  ; check for real mode Windows 3.0
    mov     ax,1606h                ; PMODE_STOP
    int     2fh                     ; in case someone is counting
    ; Real mode Windows 3.0 is running
    mov     byte ptr [bRunningWindows], 1
    mov     byte ptr [MajorVer], 3h    
    mov     byte ptr [MinorVer], 0h        
    jmp     ExitLabel
   
  RunningUnderWin30Std:
    ; Standard mode Windows 3.0 is running
    mov     byte ptr [bRunningWindows], 1
    mov     byte ptr [MajorVer], 3h    
    mov     byte ptr [MinorVer], 0h        
    jmp     ExitLabel
   
  RunningUnderWin31:
    ; At this point: CX == 3 means Windows 3.1 enhanced mode
    ;                CX == 2 means Windows 3.1 standard mode
    mov     byte ptr [bRunningWindows], 1
    
    ; Get the version of Windows 
    mov     ax, 1600h   ; Get Enhanced-Mode Windows Installed State
    int     2Fh
    mov     byte ptr [MajorVer], al
    mov     byte ptr [MinorVer], ah
    jmp     ExitLabel
   
  RunningUnderWin30Enh:
    ; Enhanced mode Windows 3.0 is running
    mov     byte ptr [bRunningWindows], 1    
    mov     byte ptr [MajorVer], 3h    
    mov     byte ptr [MinorVer], 0h        
    jmp     ExitLabel
   
  NotRunningUnderWin:                    
    mov     byte ptr [bRunningWindows], 0
    
  ExitLabel:
  }             
  
  WinVer = (WORD) ((MajorVer << 8) + MinorVer);
} 
#endif //_DOS 

BOOL IsWindowsCE(LPOS_VERSION_INFO lpVersionInformation)
{
  return (lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_WINDOWS_CE);
}

BOOL IsWindows95(LPOS_VERSION_INFO lpVersionInformation)
{
  return (lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_WINDOWS &&
          lpVersionInformation->dwUnderlyingMajorVersion == 4 && 
          lpVersionInformation->dwUnderlyingMinorVersion == 0 &&
          lpVersionInformation->dwUnderlyingBuildNumber == 950);
}

BOOL IsWindows95SP1(LPOS_VERSION_INFO lpVersionInformation)
{
  return (lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_WINDOWS &&
          lpVersionInformation->dwUnderlyingMajorVersion == 4 && 
          lpVersionInformation->dwUnderlyingBuildNumber > 950 && 
          lpVersionInformation->dwUnderlyingBuildNumber <= 1080);
}

BOOL IsWindows95OSR2(LPOS_VERSION_INFO lpVersionInformation)
{
  return (lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_WINDOWS &&
          lpVersionInformation->dwUnderlyingMajorVersion == 4 && 
          lpVersionInformation->dwUnderlyingMinorVersion < 10 &&
          lpVersionInformation->dwUnderlyingBuildNumber > 1080);
}

BOOL IsWindows98(LPOS_VERSION_INFO lpVersionInformation)
{
  return (lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_WINDOWS &&
          lpVersionInformation->dwUnderlyingMajorVersion == 4 && 
          lpVersionInformation->dwUnderlyingMinorVersion == 10 &&
          lpVersionInformation->dwUnderlyingBuildNumber == 1998);
}

BOOL IsWindows98SP1(LPOS_VERSION_INFO lpVersionInformation)
{
  return (lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_WINDOWS &&
          lpVersionInformation->dwUnderlyingMajorVersion == 4 && 
          lpVersionInformation->dwUnderlyingMinorVersion == 10 &&
          lpVersionInformation->dwUnderlyingBuildNumber > 1998 &&
          lpVersionInformation->dwUnderlyingBuildNumber < 2183);
}

BOOL IsWindows98SE(LPOS_VERSION_INFO lpVersionInformation)
{
  return (lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_WINDOWS &&
          (lpVersionInformation->dwUnderlyingMajorVersion > 4) || (lpVersionInformation->dwUnderlyingMajorVersion == 4 && 
          lpVersionInformation->dwUnderlyingBuildNumber >= 2183));
}

BOOL IsWindowsNT31(LPOS_VERSION_INFO lpVersionInformation)
{
  return ((lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_STAND_ALONE_SERVER || 
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_PRIMARY_DOMAIN_CONTROLLER ||  
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_BACKUP_DOMAIN_CONTROLLER ||  
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_WORKSTATION) &&
          lpVersionInformation->dwUnderlyingMajorVersion == 3 && 
          lpVersionInformation->dwUnderlyingMinorVersion == 10);
}

BOOL IsWindowsNT35(LPOS_VERSION_INFO lpVersionInformation)
{
  return ((lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_STAND_ALONE_SERVER || 
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_PRIMARY_DOMAIN_CONTROLLER ||  
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_BACKUP_DOMAIN_CONTROLLER ||  
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_WORKSTATION) &&
          lpVersionInformation->dwUnderlyingMajorVersion == 3 && 
          lpVersionInformation->dwUnderlyingMinorVersion == 50);
}

BOOL IsWindowsNT351(LPOS_VERSION_INFO lpVersionInformation)
{
  return ((lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_STAND_ALONE_SERVER || 
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_PRIMARY_DOMAIN_CONTROLLER ||  
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_BACKUP_DOMAIN_CONTROLLER ||  
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_WORKSTATION) &&
          lpVersionInformation->dwUnderlyingMajorVersion == 3 && 
          lpVersionInformation->dwUnderlyingMinorVersion == 51);
}

BOOL IsWindowsNT4(LPOS_VERSION_INFO lpVersionInformation)
{
  return ((lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_STAND_ALONE_SERVER || 
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_PRIMARY_DOMAIN_CONTROLLER ||  
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_BACKUP_DOMAIN_CONTROLLER ||  
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_WORKSTATION) &&
          lpVersionInformation->dwUnderlyingMajorVersion == 4);
}

BOOL IsWindows2000(LPOS_VERSION_INFO lpVersionInformation)
{
  return ((lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_STAND_ALONE_SERVER || 
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_PRIMARY_DOMAIN_CONTROLLER ||  
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_BACKUP_DOMAIN_CONTROLLER ||  
           lpVersionInformation->dwUnderlyingPlatformId == PLATFORM_NT_WORKSTATION) &&
          lpVersionInformation->dwUnderlyingMajorVersion == 5);
}

#if defined(_WINDOWS) && defined(_WIN32) && !defined(UNDER_CE)
WORD GetNTServicePackFromCSDString(LPCTSTR pszCSDVersion)
{
  WORD wServicePack = 0;
  if (_tcslen(pszCSDVersion))
  {
    //Parse out the CSDVersion string
    int i=0;      
    while (pszCSDVersion[i] != _T('\0') && !_istdigit(pszCSDVersion[i]))
      i++;
    wServicePack = (WORD) (_ttoi(&pszCSDVersion[i]));
  }

  return wServicePack;
}


WORD GetNTServicePackFromRegistry()
{
  //By default assume no service pack
  WORD wServicePack = 0;

  HKEY hCurrentVersion;
  if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows NT\\CurrentVersion"),
                   0, KEY_READ, &hCurrentVersion) == ERROR_SUCCESS)
  {
    BYTE byData[128];
    DWORD dwType;
    DWORD dwSize = 128;
    if (RegQueryValueEx(hCurrentVersion, _T("CSDVersion"), NULL, &dwType, byData, &dwSize) == ERROR_SUCCESS)
    {
      if (dwType == REG_SZ)
      {
        //Stored as a string on all other versions of NT
        wServicePack = GetNTServicePackFromCSDString((TCHAR*) byData);
      }
      else if (dwType == REG_DWORD)
      {
        //Handle the service pack number being stored as a DWORD which happens on NT 3.1
        wServicePack = HIBYTE((WORD) *((DWORD*) &byData));
      }
    }

    //Don't forget to close the registry key we were using      
    RegCloseKey(hCurrentVersion);
  }

  return wServicePack;
}

BOOL IsTerminalServicesEnabled() 
{
  // The return value
  BOOL bResult = FALSE;

  // Are we running on Windows NT?
  DWORD dwVersion = GetVersion();
  if (!(dwVersion & 0x80000000)) 
  {
    //Yes then check to see if we are running on Terminal Server
    bResult = ValidateProductSuite(_T("Terminal Server"));
  }

  return bResult;
}

BOOL IsEnterpriseServer()
{
  // The return value
  BOOL bResult = FALSE;

  // Are we running on Windows NT?
  DWORD dwVersion = GetVersion();
  if (!(dwVersion & 0x80000000)) 
  {
    //Yes then check to see if we are running on Terminal Server
    bResult = ValidateProductSuite(_T("Enterprise"));
  }

  return bResult;
}

BOOL ValidateProductSuite(LPCTSTR lpszSuiteToValidate) 
{
  // Open the ProductOptions key.
  HKEY hKey = NULL;
  LONG lResult = RegOpenKey(HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\Control\\ProductOptions"), &hKey);
  if (lResult != ERROR_SUCCESS)
    return FALSE;

  // Determine required size of ProductSuite buffer.
  DWORD dwType = 0;
  DWORD dwSize = 0;
  lResult = RegQueryValueEx(hKey, _T("ProductSuite"), NULL, &dwType, NULL, &dwSize);
  if (lResult != ERROR_SUCCESS || !dwSize)
  {
    RegCloseKey(hKey);
    return FALSE;
  }

  // Allocate buffer.
  LPTSTR lpszProductSuites = (LPTSTR) new BYTE[dwSize];

  // Retrieve array of product suite strings.
  lResult = RegQueryValueEx(hKey, _T("ProductSuite"), NULL, &dwType, (LPBYTE) lpszProductSuites, &dwSize);
  if (lResult != ERROR_SUCCESS || dwType != REG_MULTI_SZ)
  {
    //Don't forget to free up the resource we used
    delete [] lpszProductSuites;
    RegCloseKey(hKey);

    return FALSE;
  }

  //All string comparisons will be sub string only and case insensitive
  LPTSTR lpszLocalSuite = new TCHAR[_tcslen(lpszSuiteToValidate)+1];
  _tcscpy(lpszLocalSuite, lpszSuiteToValidate);
  _tcsupr(lpszLocalSuite);

  // Search for suite name in array of strings.
  BOOL bValidated = FALSE;
  LPTSTR lpszSuite = lpszProductSuites;
  while (*lpszSuite) 
  {
    //Ensure the string is upper case
    _tcsupr(lpszSuite);

    //Does the suite match up with the current item?
    if (_tcsstr(lpszSuite, lpszLocalSuite)) 
    {
      bValidated = TRUE;
      break;
    }
    lpszSuite += (lstrlen(lpszSuite) + 1);
  }

  //Don't forget to free up the resource we used
  delete [] lpszLocalSuite;
  delete [] lpszProductSuites;
  RegCloseKey(hKey);

  return bValidated;
}
#endif //#if defined(_WINDOWS) && defined(_WIN32)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -