• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GetVersionEx函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetVersionEx函数的典型用法代码示例。如果您正苦于以下问题:C++ GetVersionEx函数的具体用法?C++ GetVersionEx怎么用?C++ GetVersionEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetVersionEx函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ShowOpenDirectoryDialog

String ShowOpenDirectoryDialog()
{
	String ret;
	bool pathSelected = false;

	// check current OS version
	OSVERSIONINFO osvi;
	memset(&osvi, 0, sizeof(OSVERSIONINFO));
	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	
	if (GetVersionEx(&osvi) && (osvi.dwMajorVersion >= 6))
	{
		// for Vista or later, use the MSDN-preferred implementation of the Open File dialog in pick folders mode
		IFileDialog *pfd;
		if (SUCCEEDED(CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd))))
		{
			// configure the dialog to Select Folders only
			DWORD dwOptions;
			if (SUCCEEDED(pfd->GetOptions(&dwOptions)))
			{
				pfd->SetOptions(dwOptions | FOS_PICKFOLDERS | FOS_DONTADDTORECENT);

				if (SUCCEEDED(pfd->Show(GetActiveWindow())))
				{
					IShellItem *psi;
					if (SUCCEEDED(pfd->GetResult(&psi)))
					{
						LPWSTR lpwszName = NULL;
						if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, (LPWSTR*) &lpwszName)))
						{
							// Add directory path to the result
							//ConvertToUnixPath(pathName);
							ret = lpwszName;
							pathSelected = true;

							::CoTaskMemFree(lpwszName);
						}

						psi->Release();
					}
				}
			}

			pfd->Release();
		}
	}
	else
	{
		// for XP, use the old-styled SHBrowseForFolder() implementation
		BROWSEINFO bi = {0};
		bi.hwndOwner = GetActiveWindow();
		bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX;

		LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
		if (pidl != 0)
		{
			TCHAR szFile[MAX_PATH];
			szFile[0] = 0;

			if (SHGetPathFromIDList(pidl, szFile))
			{
				// Add directory path to the result
				//ConvertToUnixPath(pathName);
				ret = szFile;
				pathSelected = true;
			}

			IMalloc* pMalloc = NULL;
			SHGetMalloc(&pMalloc);
			if (pMalloc)
			{
				pMalloc->Free(pidl);
				pMalloc->Release();
			}
		}
	}

	return ret;
}
开发者ID:AlienX,项目名称:zephyros,代码行数:79,代码来源:file_util_win.cpp


示例2: defined

// Big messy function to figure out the default config file/path,
// depending on the OS.
// TODO: For easier portability, stuff like that should probably
//       be put somewhere collectively...
UString ConfigManager::getDefaultConfigFile() {
	UString file;

#if defined(WIN32)
	#warning getDefaultConfigFile WIN32 needs testing
	// Windows: Huge fucking mess

	char configFile[MAXPATHLEN];

	OSVERSIONINFO win32OsVersion;
	ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO));
	win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&win32OsVersion);
	// Check for non-9X version of Windows.
	if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) {
		// Use the Application Data directory of the user profile.
		if (win32OsVersion.dwMajorVersion >= 5) {
			if (!GetEnvironmentVariable("APPDATA", configFile, sizeof(configFile)))
				error("Unable to access application data directory");
		} else {
			if (!GetEnvironmentVariable("USERPROFILE", configFile, sizeof(configFile)))
				error("Unable to access user profile directory");

			strcat(configFile, "\\Application Data");
			CreateDirectory(configFile, 0);
		}

		strcat(configFile, "\\xoreos");
		CreateDirectory(configFile, 0);
		strcat(configFile, "\\" DEFAULT_CONFIG_FILE);

		FILE *tmp = 0;
		if ((tmp = fopen(configFile, "r")) == 0) {
			// Check windows directory
			char oldConfigFile[MAXPATHLEN];
			GetWindowsDirectory(oldConfigFile, MAXPATHLEN);
			strcat(oldConfigFile, "\\" DEFAULT_CONFIG_FILE);
			if ((tmp = fopen(oldConfigFile, "r"))) {
				strcpy(configFile, oldConfigFile);

				fclose(tmp);
			}
		} else {
			fclose(tmp);
		}
	} else {
		// Check windows directory
		GetWindowsDirectory(configFile, MAXPATHLEN);
		strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
	}

	file = configFile;
#elif defined(MACOSX)
	// Mac OS X: Home directory
	const char *dir = getenv("HOME");
	if (dir) {
		file  = dir;
		file += "/";
	}

	file += DEFAULT_CONFIG_FILE;
#elif defined(UNIX)
	// Default Unixoid: XDG_CONFIG_HOME
	const char *dir = getenv("XDG_CONFIG_HOME");
	if (dir) {
		file  = dir;
		file += "/";
	} else if ((dir = getenv("HOME"))) {
		file  = dir;
		file += "/.config/";
	}

	file += DEFAULT_CONFIG_FILE;
#else
	// Fallback: Current directory
	file = DEFAULT_CONFIG_FILE;
#endif

	return file;
}
开发者ID:Hellzed,项目名称:xoreos,代码行数:84,代码来源:configman.cpp


示例3: void

/** get uname for windows **/
char *getuname()
{
    int ret_size = OS_SIZE_1024 -2;
    char *ret = NULL;
    char os_v[128 +1];

    typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
    typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);


    /* Extracted from ms web site
     * http://msdn.microsoft.com/library/en-us/sysinfo/base/getting_the_system_version.asp
     */
    OSVERSIONINFOEX osvi;
    SYSTEM_INFO si;
    PGNSI pGNSI;
    PGPI pGPI;
    BOOL bOsVersionInfoEx;
    DWORD dwType;

    ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

    if(!(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)))
    {
        osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
        if (!GetVersionEx((OSVERSIONINFO *)&osvi))
            return(NULL);
    }

    /* Allocating the memory */
    os_calloc(OS_SIZE_1024 +1, sizeof(char), ret);
    ret[OS_SIZE_1024] = '\0';

    switch(osvi.dwPlatformId)
    {
        /* Test for the Windows NT product family. */
        case VER_PLATFORM_WIN32_NT:
            if(osvi.dwMajorVersion == 6)
            {
                if(osvi.dwMinorVersion == 0)
                {
                    if(osvi.wProductType == VER_NT_WORKSTATION )
                        strncat(ret, "Microsoft Windows Vista ", ret_size -1);
                    else
                    {
                        strncat(ret, "Microsoft Windows Server 2008 ", ret_size -1);
                    }
                }
                else if(osvi.dwMinorVersion == 1)
                {
                    if(osvi.wProductType == VER_NT_WORKSTATION )
                        strncat(ret, "Microsoft Windows 7 ", ret_size -1);
                    else
                    {
                        strncat(ret, "Microsoft Windows Server 2008 R2 ", ret_size -1);
                    }
                }
                else if(osvi.dwMinorVersion == 2)
                {
                    if(osvi.wProductType == VER_NT_WORKSTATION )
                        strncat(ret, "Microsoft Windows 8 ", ret_size -1);
                    else
                    {
                        strncat(ret, "Microsoft Windows Server 2012 ", ret_size -1);
                    }
                }
                else if(osvi.dwMinorVersion == 3)
                {
                    if(osvi.wProductType == VER_NT_WORKSTATION )
                        strncat(ret, "Microsoft Windows 8.1 ", ret_size -1);
                    else
                    {
                        strncat(ret, "Microsoft Windows Server 2012 R2 ", ret_size -1);
                    }
                }

                ret_size-=strlen(ret) +1;


                /* Getting product version. */
                pGPI = (PGPI) GetProcAddress(
                              GetModuleHandle(TEXT("kernel32.dll")),
                                                   "GetProductInfo");

                pGPI( 6, 0, 0, 0, &dwType);

                switch(dwType)
                {
                    case PRODUCT_UNLICENSED:
                        strncat(ret, PRODUCT_UNLICENSED_C, ret_size -1);
                        break;
                    case PRODUCT_BUSINESS:
                        strncat(ret, PRODUCT_BUSINESS_C, ret_size -1);
                        break;
                    case PRODUCT_BUSINESS_N:
                        strncat(ret, PRODUCT_BUSINESS_N_C, ret_size -1);
                        break;
                    case PRODUCT_CLUSTER_SERVER:
//.........这里部分代码省略.........
开发者ID:Ar0xA,项目名称:ossec-hids,代码行数:101,代码来源:file_op.c


示例4: SemOp

int
SemOp(int semid, struct sembuf *semopbuf, DWORD procid, int piid, IPCT *ipct)
{
	int	i;
	BOOL	ret;
	DWORD	dwret;
	HANDLE	hsem;
#ifndef	TERMINAL_SERVICE
	char	semstr[16];
#else
	char	semstr[30];
#endif	/* TERMINAL_SERVICE */

#ifndef	TERMINAL_SERVICE
	MakeSemstr(semstr, semopbuf->sem_num, semid, ipct->semt[semid].key);
#else
	OSVERSIONINFOEX osvi;

	ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

	if( !GetVersionEx ((OSVERSIONINFO *) &osvi) )
	{
	  // If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.
		osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
		GetVersionEx( (OSVERSIONINFO *) &osvi );
	}

	if( osvi.dwMajorVersion >= 5 )	/* Windows 2000 */
		MakeGlobalSemstr(semstr, semopbuf->sem_num, semid, ipct->semt[semid].key);
	else
		MakeSemstr(semstr, semopbuf->sem_num, semid, ipct->semt[semid].key);
#endif	/* TERMINAL_SERVICE */
	hsem=OpenSemaphore(SEMAPHORE_ALL_ACCESS, TRUE, semstr);
	if (hsem==NULL)
	{
		errno=GetLastError();

		return -1;
	}

	if (semopbuf->sem_op<0)
	{
		if (ipct->semb[semid][semopbuf->sem_num].semval
			>= abs((int)semopbuf->sem_op))
			ipct->semb[semid][semopbuf->sem_num].semncnt++;

		if (ipct->semb[semid][semopbuf->sem_num].semval
			< abs((int)semopbuf->sem_op))
		{
			if (semopbuf->sem_flg & IPC_NOWAIT)
			{
				ipct->semb[semid][semopbuf->sem_num].sempid=procid;
				CloseHandle(hsem);
				return 0;
			}
		}

		for (i=0; i<abs((int)semopbuf->sem_op); i++)
		{
/**************
			do
			{
				dwret=MsgWaitForMultipleObjects(1, &hsem, 
					FALSE, INFINITE, 
					QS_SENDMESSAGE|QS_POSTMESSAGE|QS_TIMER);
***************/
			dwret=WaitForSingleObject(hsem, INFINITE);
			switch (dwret)
			{
/*****************
			case	WAIT_OBJECT_0 + 1 :
				if (l_peekmessage()<0)
				{
					CloseHandle(hsem);
					return -1;
				}
				break;
*****************/

			case	WAIT_OBJECT_0	:
/* by KJC 98.09.24 **************************************
				ipct->semb[semid][semopbuf->sem_num].semval--;
***********************************************************/
				InterlockedDecrement(&ipct->semb[semid][semopbuf->sem_num].semval);
/***********************************************************/
				break;
			case	WAIT_TIMEOUT	:
			case	WAIT_FAILED	:
				errno=GetLastError();
			default	:
				CloseHandle(hsem);
				return -1;
			}
/***************
			} while (dwret==(WAIT_OBJECT_0 + 1));
***************/

			if (semopbuf->sem_flg & SEM_UNDO)
			{
//.........这里部分代码省略.........
开发者ID:nawhizz,项目名称:KAIT,代码行数:101,代码来源:semop.c


示例5: findDriver

	//---------------------------------------------------------------------
	D3D9Device* D3D9DeviceManager::selectDevice(D3D9RenderWindow* renderWindow, D3D9RenderWindowList& renderWindowsGroup)
	{
		D3D9RenderSystem*		renderSystem	 = static_cast<D3D9RenderSystem*>(Root::getSingleton().getRenderSystem());
		D3D9Device*				renderDevice	 = NULL;	
		IDirect3D9*				direct3D9	     = D3D9RenderSystem::getDirect3D9();
		UINT					nAdapterOrdinal  = D3DADAPTER_DEFAULT;
		D3DDEVTYPE				devType			 = D3DDEVTYPE_HAL;						
		DWORD					extraFlags		 = 0;					
		D3D9DriverList*			driverList = renderSystem->getDirect3DDrivers();
		bool					nvAdapterFound = false;


		// Default group includes at least the given render window.
		renderWindowsGroup.push_back(renderWindow);

		// Case we use nvidia performance HUD, override the device settings. 
		if (renderWindow->isNvPerfHUDEnable())
		{
			// Look for 'NVIDIA NVPerfHUD' adapter (<= v4)
			// or 'NVIDIA PerfHUD' (v5)
			// If it is present, override default settings
			for (UINT adapter=0; adapter < direct3D9->GetAdapterCount(); ++adapter)
			{
				D3D9Driver* currDriver = driverList->item(adapter);
				const D3DADAPTER_IDENTIFIER9& currAdapterIdentifier = currDriver->getAdapterIdentifier();

				if(strstr(currAdapterIdentifier.Description, "PerfHUD") != NULL)
				{
					renderDevice = NULL;
					nAdapterOrdinal = adapter;
					renderSystem->mActiveD3DDriver = currDriver;
					devType = D3DDEVTYPE_REF;
					nvAdapterFound = true;
					break;
				}
			}		
		}

		// No special adapter should be used.
		if (nvAdapterFound == false)
		{
			renderSystem->mActiveD3DDriver = findDriver(renderWindow);
			nAdapterOrdinal = renderSystem->mActiveD3DDriver->getAdapterNumber();

			bool bTryUsingMultiheadDevice = false;

			if (renderWindow->isFullScreen())
			{
				bTryUsingMultiheadDevice = true;
				if (renderSystem->getMultiheadUse() == D3D9RenderSystem::mutAuto)
				{
					OSVERSIONINFO osVersionInfo;
					
					osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
					
					// Case version info failed -> assume we run on XP.
					if (FALSE == GetVersionEx(&osVersionInfo))
					{
						osVersionInfo.dwMajorVersion = 5;
					}

					// XP and below - multi-head will cause artifacts when vsync is on.
					if (osVersionInfo.dwMajorVersion <= 5 && renderWindow->isVSync())
					{
						bTryUsingMultiheadDevice = false;
						LogManager::getSingleton().logMessage("D3D9 : Multi head disabled. It causes horizontal line when used in XP + VSync combination");
					}		

					// Vista and SP1 or SP2 - multi-head device can not be reset - it causes memory corruption.
					if (osVersionInfo.dwMajorVersion == 6 &&
						(_stricmp(osVersionInfo.szCSDVersion, "Service Pack 1") == 0 ||
						 _stricmp(osVersionInfo.szCSDVersion, "Service Pack 2") == 0))

					{
						bTryUsingMultiheadDevice = false;
						LogManager::getSingleton().logMessage("D3D9 : Multi head disabled. It causes application run time crashes when used in Vista + SP 1 or 2 combination");
					}	
				}
				else
				{
					bTryUsingMultiheadDevice = renderSystem->getMultiheadUse() == D3D9RenderSystem::mutYes ? true : false;
				}
			}
			
			
			// Check if we can create a group of render windows 
			// on the same device using the multi-head feature.
			if (bTryUsingMultiheadDevice)
			{
				const D3DCAPS9& targetAdapterCaps = renderSystem->mActiveD3DDriver->getD3D9DeviceCaps();
				D3DCAPS9        masterAdapterCaps;

				// Find the master device caps.
				if (targetAdapterCaps.MasterAdapterOrdinal == targetAdapterCaps.AdapterOrdinal)
				{
					masterAdapterCaps = targetAdapterCaps;
				}
				else
				{
//.........这里部分代码省略.........
开发者ID:JoeyZh,项目名称:ogre-android,代码行数:101,代码来源:OgreD3D9DeviceManager.cpp


示例6: LoadSecurityDll

HMODULE LoadSecurityDll(loginfo_t* logger) {

   HMODULE hModule;
   BOOL    fAllFunctionsLoaded = FALSE;
   TCHAR   lpszDLL[MAX_PATH];
   OSVERSIONINFO VerInfo;

   //
   //  Find out which security DLL to use, depending on
   //  whether we are on NT or Win95 or 2000 or XP or Windows Server 2003
   //  We have to use security.dll on Windows NT 4.0.
   //  All other operating systems, we have to use Secur32.dll
   //
   VerInfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
   if (!GetVersionEx (&VerInfo))   // If this fails, something has gone wrong
   {
      shaj_log_error(logger, "problem determining windows version");
      return FALSE;
   }

   if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
      VerInfo.dwMajorVersion == 4 &&
      VerInfo.dwMinorVersion == 0)
   {
      lstrcpy (lpszDLL, _T("security.dll"));
   }
   else
   {
      lstrcpy (lpszDLL, _T("secur32.dll"));
   }


   hModule = LoadLibrary(lpszDLL);
   if (!hModule) {
      shaj_log_error(logger, "problem loading %s", (char*)lpszDLL);
      return NULL;
   }

   __try {

      _AcceptSecurityContext = (ACCEPT_SECURITY_CONTEXT_FN)
            GetProcAddress(hModule, "AcceptSecurityContext");
      if (!_AcceptSecurityContext) {
        shaj_log_error(logger, "problem with function AcceptSecurityContext");
         __leave;
      }

#ifdef UNICODE
      _AcquireCredentialsHandle = (ACQUIRE_CREDENTIALS_HANDLE_FN)
            GetProcAddress(hModule, "AcquireCredentialsHandleW");
#else
      _AcquireCredentialsHandle = (ACQUIRE_CREDENTIALS_HANDLE_FN)
            GetProcAddress(hModule, "AcquireCredentialsHandleA");
#endif
      if (!_AcquireCredentialsHandle) {
          shaj_log_error(logger, "problem with function AcquireCredentialsHandle");
         __leave;
      }

      // CompleteAuthToken is not present on Windows 9x Secur32.dll
      // Do not check for the availablity of the function if it is NULL;
      _CompleteAuthToken = (COMPLETE_AUTH_TOKEN_FN)
            GetProcAddress(hModule, "CompleteAuthToken");

      _DeleteSecurityContext = (DELETE_SECURITY_CONTEXT_FN)
            GetProcAddress(hModule, "DeleteSecurityContext");
      if (!_DeleteSecurityContext) {
          shaj_log_error(logger, "problem with function DeleteSecurityContext");
         __leave;
      }

      _FreeContextBuffer = (FREE_CONTEXT_BUFFER_FN)
            GetProcAddress(hModule, "FreeContextBuffer");
      if (!_FreeContextBuffer) {
          shaj_log_error(logger, "problem with function FreeContextBuffer");
         __leave;
      }

      _FreeCredentialsHandle = (FREE_CREDENTIALS_HANDLE_FN)
            GetProcAddress(hModule, "FreeCredentialsHandle");
      if (!_FreeCredentialsHandle) {
          shaj_log_error(logger, "problem with function FreeCredentialsHandle");
         __leave;
      }

#ifdef UNICODE
      _InitializeSecurityContext = (INITIALIZE_SECURITY_CONTEXT_FN)
            GetProcAddress(hModule, "InitializeSecurityContextW");
#else
      _InitializeSecurityContext = (INITIALIZE_SECURITY_CONTEXT_FN)
            GetProcAddress(hModule, "InitializeSecurityContextA");
#endif
      if (!_InitializeSecurityContext) {
          shaj_log_error(logger, "problem with function InitializeSecurityContext");
         __leave;
      }

#ifdef UNICODE
      _QuerySecurityPackageInfo = (QUERY_SECURITY_PACKAGE_INFO_FN)
            GetProcAddress(hModule, "QuerySecurityPackageInfoW");
//.........这里部分代码省略.........
开发者ID:jirutka,项目名称:shaj,代码行数:101,代码来源:shaj_sspi.c


示例7: GetWinVer

///////////////////////////////////////////////////////////////////////////////
// GetWinVer
BOOL GetWinVer(LPTSTR pszVersion, int *nVersion, LPTSTR pszMajorMinorBuild)
{
	if (!pszVersion || !nVersion || !pszMajorMinorBuild)
		return FALSE;
	lstrcpy(pszVersion, WUNKNOWNSTR);
	*nVersion = WUNKNOWN;

	OSVERSIONINFO osinfo;
	osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

	if (!GetVersionEx((OSVERSIONINFO*)&osinfo))
		return FALSE;

	DWORD dwPlatformId   = osinfo.dwPlatformId;
	DWORD dwMinorVersion = osinfo.dwMinorVersion;
	DWORD dwMajorVersion = osinfo.dwMajorVersion;
	DWORD dwBuildNumber  = osinfo.dwBuildNumber & 0xFFFF;	// Win 95 needs this

	wsprintf(pszMajorMinorBuild, _T("%u.%u.%u"), dwMajorVersion, dwMinorVersion, dwBuildNumber);

	if ((dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && (dwMajorVersion == 4))
	{
		if ((dwMinorVersion < 10) && (dwBuildNumber == 950))
		{
			lstrcpy(pszVersion, W95STR);
			*nVersion = W95;
		}
		else if ((dwMinorVersion < 10) && 
				((dwBuildNumber > 950) && (dwBuildNumber <= 1080)))
		{
			lstrcpy(pszVersion, W95SP1STR);
			*nVersion = W95SP1;
		}
		else if ((dwMinorVersion < 10) && (dwBuildNumber > 1080))
		{
			lstrcpy(pszVersion, W95OSR2STR);
			*nVersion = W95OSR2;
		}
		else if ((dwMinorVersion == 10) && (dwBuildNumber == 1998))
		{
			lstrcpy(pszVersion, W98STR);
			*nVersion = W98;
		}
		else if ((dwMinorVersion == 10) && 
				((dwBuildNumber > 1998) && (dwBuildNumber < 2183)))
		{
			lstrcpy(pszVersion, W98SP1STR);
			*nVersion = W98SP1;
		}
		else if ((dwMinorVersion == 10) && (dwBuildNumber >= 2183))
		{
			lstrcpy(pszVersion, W98SESTR);
			*nVersion = W98SE;
		}
		else if (dwMinorVersion == 90)
		{
			lstrcpy(pszVersion, WMESTR);
			*nVersion = WME;
		}
	}
	else if (dwPlatformId == VER_PLATFORM_WIN32_NT)
	{
		if ((dwMajorVersion == 3) && (dwMinorVersion == 51))
		{
			lstrcpy(pszVersion, WNT351STR);
			*nVersion = WNT351;
		}
		else if ((dwMajorVersion == 4) && (dwMinorVersion == 0))
		{
			lstrcpy(pszVersion, WNT4STR);
			*nVersion = WNT4;
		}
		else if ((dwMajorVersion == 5) && (dwMinorVersion == 0))
		{
			lstrcpy(pszVersion, W2KSTR);
			*nVersion = W2K;
		}
		else if ((dwMajorVersion == 5) && (dwMinorVersion == 1))
		{
			lstrcpy(pszVersion, WXPSTR);
			*nVersion = WXP;
		}
		else if ((dwMajorVersion == 5) && (dwMinorVersion == 2))
		{
			lstrcpy(pszVersion, W2003SERVERSTR);
			*nVersion = W2003SERVER;
		}
		else if ((dwMajorVersion == 6) && (dwMinorVersion == 0))
		{
			lstrcpy(pszVersion, WVISTASTR);
			*nVersion = WVISTA;
		}
		else if ((dwMajorVersion == 6) && (dwMinorVersion == 1))
		{
			lstrcpy(pszVersion, WWIN7STR);
			*nVersion = WWIN7;
		}
	}
//.........这里部分代码省略.........
开发者ID:zhangf911,项目名称:GCEDemo,代码行数:101,代码来源:XGetWinVer.cpp


示例8: OS

/*! 
  Fills \c buff with a string describing the current OS (including version)
  \return  0 on success, 1 if buffer too small, -1 if failed to determine 
           OS version
  \author  jfpatry
  \date    Created:  2000-10-30
  \date    Modified: 2000-10-30
*/
int get_os_version( char *buff, int size )
{

#ifdef WIN32
    /* Win32 Version */

    /* See http://www.mvps.org/vb/index2.html?tips/getversionex.htm for 
       a table mapping OSVERSIONINFOEX entries to Windows version */

    char tmp_buff[BUFF_LEN];
    int tmp_buff_size = BUFF_LEN;
    char *ptr = tmp_buff;
    int len;
    
    OSVERSIONINFO osvi;
    
    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    
    if ( !GetVersionEx( (OSVERSIONINFO *) &osvi) ) {
	return -1;
    }
    
    switch (osvi.dwPlatformId)
    {
    case VER_PLATFORM_WIN32_NT:
	
	/* Check for NT versus 2000 */
	if ( osvi.dwMajorVersion <= 4 ) {
	    if ( !append_to_buff( &ptr, &tmp_buff_size, 
				  "Microsoft Windows NT" ) )
	    {
		return -1;
	    }
	}
	
	if ( osvi.dwMajorVersion == 5 ) {
	    if ( !append_to_buff( &ptr, &tmp_buff_size, 
				  "Microsoft Windows 2000" ) )
	    {
		return -1;
	    }
	}
	

	/* Display version, service pack (if any), and build number. */
	len = snprintf(ptr, tmp_buff_size, " version %d.%d %s (Build %d)",
		       osvi.dwMajorVersion,
		       osvi.dwMinorVersion,
		       osvi.szCSDVersion,
		       osvi.dwBuildNumber & 0xFFFF);

	check_assertion( len >= 0, "tmp_buff too small" );
	if ( len < 0 ) {
	    return -1;
	}

	ptr += len;
	tmp_buff_size -= len;
	
	break;
	
    case VER_PLATFORM_WIN32_WINDOWS:
	
	if ((osvi.dwMajorVersion > 4) || 
            ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0)))
	{
	    if ( osvi.dwMinorVersion <= 10 ) {
		if ( strcmp( osvi.szCSDVersion, "A" ) == 0 ) {
		    if ( !append_to_buff( &ptr, &tmp_buff_size, 
					  "Microsoft Windows 98 SE") )
		    {
			return -1;
		    }
		} else {
		    if ( !append_to_buff( &ptr, &tmp_buff_size, 
					  "Microsoft Windows 98") )
		    {
			return -1;
		    }
		}
	    } else {
		if ( !append_to_buff( &ptr, &tmp_buff_size, 
				      "Microsoft Windows ME") )
		{
		    return -1;
		}
	    }
	} else {
	    if ( strcmp( osvi.szCSDVersion, "B" ) == 0 ) {
		if ( !append_to_buff( &ptr, &tmp_buff_size, 
				      "Microsoft Windows 95 OSR2") )
//.........这里部分代码省略.........
开发者ID:FeeJai,项目名称:Tux-Racer-4-iOS,代码行数:101,代码来源:os_util.c


示例9: ZeroMemory

bool PerfCounterMuninNodePlugin::OpenCounter()
{
  PDH_STATUS status;  

  m_Name = m_SectionName.substr(strlen(PerfCounterMuninNodePlugin::SectionPrefix));

  OSVERSIONINFO osvi;    
  ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  if (!GetVersionEx(&osvi) || (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT)) {
	  _Module.LogError("PerfCounter plugin: %s: unknown OS or not NT based", m_Name.c_str());
	  return false; //unknown OS or not NT based
  }

  // Create a PDH query
  status = PdhOpenQuery(NULL, 0, &m_PerfQuery);
  if (status != ERROR_SUCCESS) {
	  _Module.LogError("PerfCounter plugin: %s: PdhOpenQuery error=%x", m_Name.c_str(), status);
	  return false;
  }

  TString objectName = A2TConvert(g_Config.GetValue(m_SectionName, "Object", "LogicalDisk"));
  TString counterName = A2TConvert(g_Config.GetValue(m_SectionName, "Counter", "% Disk Time"));
  
  DWORD counterListLength = 0;  
  DWORD instanceListLength = 0;
  if (g_Config.GetValueB(m_SectionName, "UseEnglishObjectNames", true)) {
	  counterName = GetPdhCounterLocalizedName(counterName.c_str());
	  objectName = GetPdhCounterLocalizedName(objectName.c_str());
  }
  status = PdhEnumObjectItems(NULL, NULL, objectName.c_str(), NULL, &counterListLength, NULL, &instanceListLength, PERF_DETAIL_EXPERT, 0);
  if (status != PDH_MORE_DATA) {
	  _Module.LogError("PerfCounter plugin: %s: PdhEnumObjectItems error=%x", m_Name.c_str(), status);
	  return false;
  }

  TCHAR *counterList = new TCHAR[counterListLength+2];
  TCHAR *instanceList = new TCHAR[instanceListLength+2];
  counterList[0] = NULL;
  instanceList[0] = NULL;
  counterList[1] = NULL;
  instanceList[1] = NULL;

  status = PdhEnumObjectItems(NULL, NULL, objectName.c_str(), counterList, &counterListLength, instanceList, &instanceListLength, PERF_DETAIL_EXPERT, 0);
  if (status != ERROR_SUCCESS) {
    delete [] counterList;
    delete [] instanceList;
	_Module.LogError("PerfCounter plugin: %s: PdhEnumObjectItems error=%x", m_Name.c_str(), status);
    return false;  
  }

  int pos = 0;
  TCHAR *instanceName = instanceList;
  while (instanceName[0] != NULL) {
    std::string counterInstanceName = T2AConvert(instanceName);
    m_CounterNames.push_back(counterInstanceName);
    while (instanceName[0] != NULL)
      instanceName++;
    instanceName++;
  }
  delete [] counterList;
  delete [] instanceList;

  TCHAR counterPath[MAX_PATH] = {0};
  HCOUNTER counterHandle;
  if (!m_CounterNames.empty()) {
    if (g_Config.GetValueB(m_SectionName, "DropTotal", true)) {
      assert(m_CounterNames.back().compare("_Total") == 0);
      // We drop the last instance name as it is _Total
      m_CounterNames.pop_back();
    }

    for (size_t i = 0; i < m_CounterNames.size(); i++) {
      TString instanceNameStr = A2TConvert(m_CounterNames[i]);
      _sntprintf(counterPath, MAX_PATH, _T("\\%s(%s)\\%s"), objectName.c_str(), instanceNameStr.c_str(), counterName.c_str());
      // Associate the uptime counter with the query
      status = PdhAddCounter(m_PerfQuery, counterPath, 0, &counterHandle);
	  if (status != ERROR_SUCCESS) {
		  _Module.LogError("PerfCounter plugin: %s: PDH add counter error=%x", m_Name.c_str(), status);
		  return false;
	  }
      
      m_Counters.push_back(counterHandle);
    }
  } else {
    // A counter with a single instance (Uptime for example)
    m_CounterNames.push_back("0");
    _sntprintf(counterPath, MAX_PATH, _T("\\%s\\%s"), objectName.c_str(), counterName.c_str());
    // Associate the uptime counter with the query
    status = PdhAddCounter(m_PerfQuery, counterPath, 0, &counterHandle);
	if (status != ERROR_SUCCESS) {
		_Module.LogError("PerfCounter plugin: %s: PDH add counter error=%x", m_Name.c_str(), status);
		return false;
	}
    
    m_Counters.push_back(counterHandle);
  }
  
  // Collect init data
  status = PdhCollectQueryData(m_PerfQuery);
//.........这里部分代码省略.........
开发者ID:NoICE,项目名称:munin-node-win32,代码行数:101,代码来源:PerfCounterMuninNodePlugin.cpp


示例10: defined

QString OSInfo::getOSDisplayableVersion() {
#if defined(Q_OS_WIN)
	QString osdispver;

	OSVERSIONINFOEXW ovi;
	memset(&ovi, 0, sizeof(ovi));
	ovi.dwOSVersionInfoSize = sizeof(ovi);
	if (!GetVersionEx(reinterpret_cast<OSVERSIONINFOW *>(&ovi))) {
		return QString();
	}

	_SYSTEM_INFO si;
	GetNativeSystemInfo(&si);

	if (ovi.dwMajorVersion >= 6) {
		if (ovi.dwMajorVersion == 10) {
			if (ovi.wProductType == VER_NT_WORKSTATION) {
				osdispver = QLatin1String("Windows 10");
			} else {
				osdispver = QLatin1String("Windows 10 Server");
			}
		} else if (ovi.dwMajorVersion == 6) {
			if (ovi.dwMinorVersion == 0) {
				if (ovi.wProductType == VER_NT_WORKSTATION) {
					osdispver = QLatin1String("Windows Vista");
				} else {
					osdispver = QLatin1String("Windows Server 2008");
				}
			} else if (ovi.dwMinorVersion == 1) {
				if (ovi.wProductType == VER_NT_WORKSTATION) {
					osdispver = QLatin1String("Windows 7");
				} else {
					osdispver = QLatin1String("Windows Server 2008 R2");
				}
			} else if (ovi.dwMinorVersion == 2) {
				if (ovi.wProductType == VER_NT_WORKSTATION) {
					osdispver = QLatin1String("Windows 8");
				} else {
					osdispver = QLatin1String("Windows Server 2012");
				}
			} else if (ovi.dwMinorVersion == 3) {
				if (ovi.wProductType == VER_NT_WORKSTATION) {
					osdispver = QLatin1String("Windows 8.1");
				} else {
					osdispver = QLatin1String("Windows Server 2012 R2");
				}
			} else if (ovi.dwMinorVersion == 4) {
				if (ovi.wProductType == VER_NT_WORKSTATION) {
					osdispver = QLatin1String("Windows 10");
				} else {
					osdispver = QLatin1String("Windows 10 Server");
				}
			}
		}

		typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
		PGPI pGetProductInfo = (PGPI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo");
		if (pGetProductInfo == NULL) {
			return QString();
		}

		DWORD dwType = 0;
		if (!pGetProductInfo(ovi.dwMajorVersion, ovi.dwMinorVersion, 0, 0, &dwType)) {
			return QString();
		}

		switch(dwType) {
		case PRODUCT_ULTIMATE:
			osdispver.append(QLatin1String(" Ultimate Edition"));
			break;
		case PRODUCT_PROFESSIONAL:
			osdispver.append(QLatin1String(" Professional"));
			break;
		case PRODUCT_HOME_PREMIUM:
			osdispver.append(QLatin1String(" Home Premium Edition"));
			break;
		case PRODUCT_HOME_BASIC:
			osdispver.append(QLatin1String(" Home Basic Edition"));
			break;
		case PRODUCT_ENTERPRISE:
			osdispver.append(QLatin1String(" Enterprise Edition"));
			break;
		case PRODUCT_BUSINESS:
			osdispver.append(QLatin1String(" Business Edition"));
			break;
		case PRODUCT_STARTER:
			osdispver.append(QLatin1String(" Starter Edition"));
			break;
		case PRODUCT_CLUSTER_SERVER:
			osdispver.append(QLatin1String(" Cluster Server Edition"));
			break;
		case PRODUCT_DATACENTER_SERVER:
			osdispver.append(QLatin1String(" Datacenter Edition"));
			break;
		case PRODUCT_DATACENTER_SERVER_CORE:
			osdispver.append(QLatin1String(" Datacenter Edition (core installation)"));
			break;
		case PRODUCT_ENTERPRISE_SERVER:
			osdispver.append(QLatin1String(" Enterprise Edition"));
			break;
//.........这里部分代码省略.........
开发者ID:Githlar,项目名称:mumble,代码行数:101,代码来源:OSInfo.cpp


示例11: QString

QString OSInfo::getOSVersion() {
	static QString qsCached;

	if (! qsCached.isNull())
		return qsCached.isEmpty() ? QString() : qsCached;

	QString os;

#if defined(Q_OS_WIN)
	OSVERSIONINFOEXW ovi;
	memset(&ovi, 0, sizeof(ovi));

	ovi.dwOSVersionInfoSize=sizeof(ovi);
	if (!GetVersionEx(reinterpret_cast<OSVERSIONINFOW *>(&ovi))) {
		return QString();
	}

	os.sprintf("%d.%d.%d.%d", ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber, (ovi.wProductType == VER_NT_WORKSTATION) ? 1 : 0);
#elif defined(Q_OS_MAC)
	SInt32 major, minor, bugfix;
	OSErr err = Gestalt(gestaltSystemVersionMajor, &major);
	if (err == noErr)
		err = Gestalt(gestaltSystemVersionMinor, &minor);
	if (err == noErr)
		err = Gestalt(gestaltSystemVersionBugFix, &bugfix);
	if (err != noErr)
		return QString::number(QSysInfo::MacintoshVersion, 16);

	const NXArchInfo *local = NXGetLocalArchInfo();
	const NXArchInfo *ai = local ? NXGetArchInfoFromCpuType(local->cputype, CPU_SUBTYPE_MULTIPLE) : NULL;
	const char *arch = ai ? ai->name : "unknown";

	os.sprintf("%i.%i.%i (%s)", major, minor, bugfix, arch);
#else
#ifdef Q_OS_LINUX
	QProcess qp;
	QStringList args;
	args << QLatin1String("-s");
	args << QLatin1String("-d");
	qp.start(QLatin1String("lsb_release"), args);
	if (qp.waitForFinished(5000)) {
		os = QString::fromUtf8(qp.readAll()).simplified();
		if (os.startsWith(QLatin1Char('"')) && os.endsWith(QLatin1Char('"')))
			os = os.mid(1, os.length() - 2).trimmed();
	}
	if (os.isEmpty())
		qWarning("OSInfo: Failed to execute lsb_release");

	qp.terminate();
	if (! qp.waitForFinished(1000))
		qp.kill();
#endif
	if (os.isEmpty()) {
		struct utsname un;
		if (uname(&un) == 0) {
			os.sprintf("%s %s", un.sysname, un.release);
		}
	}
#endif

	if (! os.isNull())
		qsCached = os;
	else
		qsCached = QLatin1String("");

	return qsCached;
}
开发者ID:Githlar,项目名称:mumble,代码行数:67,代码来源:OSInfo.cpp


示例12: memset

LONG CMirageManager::SetupDriver(CRegKey& regKeyDevice, DISPLAY_DEVICE& deviceInfo, Esc_dmf_Qvi_OUT& qvi_out)
{
	DFEXT_DEVMODE deviceMode;
	memset(&deviceMode, 0, sizeof(deviceMode));
	deviceMode.dmSize = sizeof(DEVMODE);

	WORD drvExtraSaved = deviceMode.dmDriverExtra;
	memset(&deviceMode, 0, sizeof(DEVMODE));
	deviceMode.dmSize = sizeof(DEVMODE);
	deviceMode.dmDriverExtra = drvExtraSaved;

	POINTL pos;
	pos.x = pos.y = 0;
	deviceMode.dmPelsWidth = 100;
	deviceMode.dmPelsHeight = 100;
	deviceMode.dmBitsPerPel = 32;
	deviceMode.dmPosition = pos;

	deviceMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION;
	deviceMode.dmDeviceName[0] = '\0';

	CMirageManager::WriteDiagnostics(_T("Attaching to desktop"));
	LONG retval = regKeyDevice.SetDWORDValue(_T("Attach.ToDesktop"), true);
	if (ERROR_SUCCESS != retval)
	{
		CMirageManager::WriteDiagnostics(_T("Failed to attach to desktop"));
		return retval;
	}

	CMirageManager::WriteDiagnostics(_T("Committing display changes"));
	retval = CMirageManager::CommitDisplayChanges(&deviceMode, deviceInfo);
	if (ERROR_SUCCESS != retval)
	{
		CMirageManager::WriteDiagnostics(_T("Failed to commit display changes"));
		return retval;
	}

	CMirageManager::WriteDiagnostics(_T("Creating device context"));
	HDC driverDC;
	driverDC = CreateDC(deviceInfo.DeviceName, NULL, NULL, NULL);
	if (!driverDC)
	{
		CMirageManager::WriteDiagnostics(_T("Failed to create device context"));
		return ERROR_DC_NOT_FOUND;
	}

	CMirageManager::WriteDiagnostics(_T("Querying Driver Version"));
	Esc_dmf_Qvi_IN qvi_in;
	qvi_in.cbSize = sizeof(qvi_in);
	qvi_in.app_actual_version = DMF_PROTO_VER_CURRENT;
	qvi_in.display_minreq_version = DMF_PROTO_VER_MINCOMPAT;
	qvi_in.connect_options = 0;

	qvi_out.cbSize = sizeof(qvi_out);
	ExtEscape(driverDC, ESC_QVI, sizeof(qvi_in), (LPSTR) &qvi_in, sizeof(qvi_out), (LPSTR) &qvi_out);
	
	std::wstringstream driverVersion(_T(""));
	driverVersion << _T("Driver Version : ") << BYTE3(qvi_out.display_actual_version) << _T(".") << BYTE2(qvi_out.display_actual_version)
		<< _T(".") << BYTE1(qvi_out.display_actual_version) << _T(".") << BYTE0(qvi_out.display_actual_version)
		<< _T(" build(") << qvi_out.display_buildno << _T(")");
	CMirageManager::WriteDiagnostics(driverVersion.str());

	if (driverDC)
	{
		CMirageManager::WriteDiagnostics(_T("Deleting device context"));
		::DeleteDC(driverDC);
		driverDC = NULL;
	}

	CMirageManager::WriteDiagnostics(_T("Detaching from desktop"));
	retval = regKeyDevice.SetDWORDValue(_T("Attach.ToDesktop"), false);
	if (ERROR_SUCCESS != retval)
		return retval;

	deviceMode.dmPelsWidth = 0;
	deviceMode.dmPelsHeight = 0;
	OSVERSIONINFO osvi;
	osvi.dwOSVersionInfoSize = sizeof(osvi);
	GetVersionEx(&osvi);
	
	DEVMODE* pdm = NULL;
	if (osvi.dwMajorVersion > 5 || (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion > 0))
		pdm = &deviceMode;

	CMirageManager::WriteDiagnostics(_T("Committing display changes"));
	retval = CommitDisplayChanges(pdm, deviceInfo);
	if (ERROR_SUCCESS != retval)
		return retval;

	return ERROR_SUCCESS;
}
开发者ID:AsherBond,项目名称:DimSim,代码行数:91,代码来源:MirageManager.cpp


示例13: Cadthread

DWORD WINAPI Cadthread(LPVOID lpParam)
{
	OSVERSIONINFO OSversion;	
	OSversion.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
	GetVersionEx(&OSversion);


	HDESK desktop=NULL;
	desktop = OpenInputDesktop(0, FALSE,
								DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
								DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |
								DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
								DESKTOP_SWITCHDESKTOP | GENERIC_WRITE
								);


	
	if (desktop == NULL)
		vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop Error \n"));
	else 
		vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop OK\n"));

	HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
	DWORD dummy;

	char new_name[256];
	if (desktop)
	{
	if (!GetUserObjectInformation(desktop, UOI_NAME, &new_name, 256, &dummy))
	{
		vnclog.Print(LL_INTERR, VNCLOG("!GetUserObjectInformation \n"));
	}

	vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK to %s (%x) from %x\n"), new_name, desktop, old_desktop);

	if (!SetThreadDesktop(desktop))
	{
		vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK:!SetThreadDesktop \n"));
	}
	}

	//////
	if(OSversion.dwMajorVersion>=6 && vncService::RunningAsService())
			{
				/*if (OSversion.dwMinorVersion==0) //Vista
				{
					if (ISUACENabled() && !IsSoftwareCadEnabled())//ok
					{
						
					}
					if (!ISUACENabled() && IsSoftwareCadEnabled())
					{
						
					}
					if (!ISUACENabled() && !IsSoftwareCadEnabled())
					{
						DWORD result=MessageBoxSecure(NULL,"UAC is Disable, make registry changes to allow cad","Warning",MB_YESNO);
						if (result==IDYES)
						{
							HANDLE hProcess,hPToken;
							DWORD id=GetExplorerLogonPid();
							if (id!=0) 
								{
									hProcess = OpenProcess(MAXIMUM_ALLOWED,FALSE,id);
									if(!OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY
													|TOKEN_DUPLICATE|TOKEN_ASSIGN_PRIMARY|TOKEN_ADJUST_SESSIONID
													|TOKEN_READ|TOKEN_WRITE,&hPToken)) return 0;

									char dir[MAX_PATH];
									char exe_file_name[MAX_PATH];
									GetModuleFileName(0, exe_file_name, MAX_PATH);
									strcpy(dir, exe_file_name);
									strcat(dir, " -softwarecadhelper");
		
							
									STARTUPINFO          StartUPInfo;
									PROCESS_INFORMATION  ProcessInfo;
									HANDLE Token=NULL;
									HANDLE process=NULL;
									ZeroMemory(&StartUPInfo,sizeof(STARTUPINFO));
									ZeroMemory(&ProcessInfo,sizeof(PROCESS_INFORMATION));
									StartUPInfo.wShowWindow = SW_SHOW;
									StartUPInfo.lpDesktop = "Winsta0\\Default";
									StartUPInfo.cb = sizeof(STARTUPINFO);
				
									CreateProcessAsUser(hPToken,NULL,dir,NULL,NULL,FALSE,DETACHED_PROCESS,NULL,NULL,&StartUPInfo,&ProcessInfo);
									DWORD errorcode=GetLastError();
									if (process) CloseHandle(process);
									if (Token) CloseHandle(Token);
									if (ProcessInfo.hProcess) CloseHandle(ProcessInfo.hProcess);
									if (ProcessInfo.hThread) CloseHandle(ProcessInfo.hThread);
									if (errorcode==1314)
									{
										Enable_softwareCAD_elevated();
									}
								}
						}
					}
					if (ISUACENabled() && IsSoftwareCadEnabled())
					{
//.........这里部分代码省略.........
开发者ID:polyu,项目名称:Cloud_Game,代码行数:101,代码来源:vistahook.cpp


示例14: main

int __cdecl main(int argc, char *argv[]) 
{
	
    OSVERSIONINFO TheVersionInfo;
    OSVERSIONINFO* pVersionInfo = &TheVersionInfo;
 
    /*
     * Initialize the PAL and return FAILURE if this fails
     */

    if(0 != (PAL_Initialize(argc, argv)))
    {
        return FAIL;
    }

    /* This needs to be done before using GetVersionEx */
    pVersionInfo->dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  
    /* If GetVersionEx fails, then the test fails */
    if(GetVersionEx(pVersionInfo) == 0) 
    {
        Fail("ERROR: The GetVersionEx function returned 0, which indicates " 
             "failure.");
    }
  
    /* These values are fixed, ensure they're set properly */
    if(pVersionInfo->dwMajorVersion != 5) 
    {
        Fail("ERROR: The fixed value of dwMajorVersion shoud be 5, but is "
             " really %d.",pVersionInfo->dwMajorVersion);
    }

    /* The minor version values for Win2k and XP are different 
       for Win2k minor version equals 0 and for XP minor version
       equals 1.  Both values are excepted here. */
    if((pVersionInfo->dwMinorVersion != 0) && 
       (pVersionInfo->dwMinorVersion != 1)) 
    {
        Fail("ERROR: The fixed value of dwMinorVersion shoud be 0 or 1, "
             "but is really %d.",pVersionInfo->dwMinorVersion);
    }

    if(pVersionInfo->dwBuildNumber_PAL_Undefined < 0) 
    {
        Fail("ERROR: The value of dwBuildNumber shoud be at least 0, but is "
             "really %d.",pVersionInfo->dwBuildNumber_PAL_Undefined);
    }

#if !WIN32


    /* Under BSD, the PlatformID should be UNIX and the Service Pack
       version should be set to "".
    */

    if(pVersionInfo->dwPlatformId != VER_PLATFORM_UNIX ||
       pVersionInfo->szCSDVersion_PAL_Undefined[0] != 0) 
    {
        Fail("ERROR: The dwPlatformId should be %d but is really %d.  And the "
             "szCSDVerion should be NULL.",VER_PLATFORM_UNIX,
             pVersionInfo->dwPlatformId);
    }
#endif
  
    
    PAL_Terminate();
    return PASS;
}
开发者ID:ArildF,项目名称:masters,代码行数:68,代码来源:test.c


示例15: VBoxDisplayInit

int VBoxDisplayInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread)
{
    Log(("VBoxTray: VBoxDisplayInit ...\n"));

    OSVERSIONINFO OSinfo;
    OSinfo.dwOSVersionInfoSize = sizeof (OSinfo);
    GetVersionEx (&OSinfo);

    HMODULE hUser = GetModuleHandle("user32.dll");

    gCtx.pEnv = pEnv;

    if (NULL == hUser)
    {
        Log(("VBoxTray: VBoxDisplayInit: Could not get module handle of USER32.DLL!\n"));
        return VERR_NOT_IMPLEMENTED;
    }
    else if (OSinfo.dwMajorVersion >= 5)        /* APIs available only on W2K and up! */
    {
        *(uintptr_t *)&gCtx.pfnChangeDisplaySettingsEx = (uintptr_t)GetProcAddress(hUser, "ChangeDisplaySettingsExA");
        Log(("VBoxTray: VBoxDisplayInit: pfnChangeDisplaySettingsEx = %p\n", gCtx.pfnChangeDisplaySettingsEx));

        *(uintptr_t *)&gCtx.pfnEnumDisplayDevices = (uintptr_t)GetProcAddress(hUser, "EnumDisplayDevicesA");
        Log(("VBoxTray: VBoxDisplayInit: pfnEnumDisplayDevices = %p\n", gCtx.pfnEnumDisplayDevices));

#ifdef VBOX_WITH_WDDM
        if (OSinfo.dwMajorVersion >= 6)
        {
            /* this is vista and up, check if we need to switch the display driver if to WDDM mode */
            Log(("VBoxTray: VBoxDisplayInit: this is Windows Vista and up\n"));
            VBOXDISPLAY_DRIVER_TYPE enmType = getVBoxDisplayDriverType (&gCtx);
            if (enmType == VBOXDISPLAY_DRIVER_TYPE_WDDM)
    

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetVersionExA函数代码示例发布时间:2022-05-30
下一篇:
C++ GetVersion函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap