Example #1
0
CString CUtils::GetOsName( void )
{
	static CString szOsName;
	if (szOsName.IsEmpty())
	{
		if (IsXP())
		{
			szOsName = L"windowsxp";
		}
		if (IsVista())
		{
			szOsName = L"windowsvista";
		}
		if (IsWin7())
		{
			szOsName = L"windows7";
		}
		if (IsWin8())
		{
			szOsName = L"windows8";
		}
		if (IsWin8_1())
		{
			szOsName = L"windows81";
		}
		if (IsWin10())
		{
			szOsName = L"windows10";
		}
	}

	return szOsName;
}
/**
* uninstall service

*/
HRESULT CGtserviceModule::UnInstallTaskScheduler() throw()
{
	HRESULT hr= E_UNEXPECTED;
	if (IsXP())
	{
		CString apppath = GetPath();
		apppath +=_T("\\autoupdate.exe");
		CString appname = _T("gtservice");
		hr = AutoBoot(apppath,0,0,appname,false);
	}
	else
	{
		/*CTaskScheduler tsch;
		hr = tsch.DeleteTask(_T("gtservice"),_T("gtplatform"));
		if(FAILED(hr))
		{
		CString apppath = GetPath();
		apppath +=_T("\\autoupdate.exe");
		CString appname = _T("gtservice");
		hr = AutoBoot(apppath,0,0,appname,false);
		}*/
	}
	if(FAILED(hr))
	{
		LogEvent(_T("install task error."));
	}
	return hr;
}
//=============================================================================
// Set the list view to desired mode.
BOOL CXFileOpenListView::SetViewMode(int cmd)
//=============================================================================
{
	TRACE(_T("in CXFileOpenListView::SetViewMode:  0x%X\n"), cmd);

	if (IsWindow(m_hWnd)) 
	{
		// SHELLDLL_DefView window found: send it the command.
		if (cmd == 0)
		{
			if (IsXP())	
				cmd = XLVM_XP_LIST;
			else if (IsVista())
				cmd = XLVM_VISTA_LIST;
		}

		SendMessage(WM_COMMAND, cmd);

		// Send parent dialog a Refresh command (F5) to force repaint.
		// The command ID value was obtained by inspection using Spy++.
		const UINT CMD_REFRESH = 40966;
		GetParent()->SendMessage(WM_COMMAND, CMD_REFRESH);

		return TRUE;
	}
	else
	{
		TRACE(_T("ERROR - no m_hWnd\n"));
	}
	return FALSE;
}
//=============================================================================
// Get current list view mode in the form of WM_COMMAND code that can be
// passed to SetViewMode.
int CXFileOpenListView::GetViewMode()
//=============================================================================
{
	TRACE(_T("in CXFileOpenListView::GetViewMode\n"));

	int nViewMode = 0;

	if (IsWindow(m_hWnd))
	{
		// Get the child list view window.
		HWND hlc = ::FindWindowEx(m_hWnd, NULL, _T("SysListView32"), NULL);
		if (hlc)
		{
			CListCtrl* plc = (CListCtrl*)CWnd::FromHandle(hlc);
			if (plc)
			{
				long lView = (long)plc->SendMessage(LVM_GETVIEW);

				TRACE(_T("lView=%X\n"), lView);

				if (IsXP())	
					nViewMode = GetXpViewMode(lView, plc);
				else if (IsVista())
					nViewMode = GetVistaViewMode(lView, plc);
			}
		}
	}

	return nViewMode;
}
/**
* install as service,
* i knick out windows service because of the right too high
* 
*/
HRESULT CGtserviceModule::InstallTaskScheduler()
{
	HRESULT hr=E_UNEXPECTED;
	CString apppath = GetPath();
	apppath +=_T("\\autoupdate.exe");
	if (IsXP())
	{
		CString appname = _T("gtservice");
		hr = AutoBoot(apppath,0,0,appname,true);
	}
	else
	{
		/*try{
			TaskScheduler tsch;
			CComPtr<ITaskFolder> appfoloder = tsch.CreateFolder(_T("gtplatform"));
			if(appfoloder)
			{
			hr = tsch.CreateTask(appfoloder,_T("gtservice"),apppath,0,_T("mytrigger")
			,TaskScheduler::GetDomainUser(),0,0,0);
			}
			}catch(...)
			{
			LogEvent(_T("install task error."));
			}
			if(FAILED(hr))
			{
			CString appname = _T("gtservice");
			hr = AutoBoot(apppath,0,0,appname,true);
			}*/
	}
	if(FAILED(hr))
	{
		LogEvent(_T("install task error."));
	}
	return hr;
}
Example #6
0
void main ( void ) 
{
    // Get the real list of modules.
    DWORD dwModCount = 0 ;
    HMODULE * hProcessMods = 
                AllocAndFillProcessModuleList ( GetProcessHeap ( ) ,
                                                &dwModCount         ) ;
    ASSERT ( NULL != hProcessMods ) ;
    if ( NULL == hProcessMods )
    {
        _tprintf ( _T ( "Unable to get the process module list.\n" ) ) ;
        return ;
    }                                                

    DWORD  dwProcID = GetCurrentProcessId ( ) ;
    HANDLE hProcHandle = GetCurrentProcess ( ) ;
    
    // Do the BSUGetModuleBaseName tests with good data.
    char szAnsi[ MAX_PATH ] ;
    DWORD dwRet = BSUGetModuleBaseNameA ( hProcHandle , 
                                          NULL        , 
                                          szAnsi      , 
                                          MAX_PATH     ) ;
    ASSERT ( 0 != dwRet ) ;
    if ( 0 == dwRet )
    {
        _tprintf ( _T ( "BSUGetModuleBaseNameA failed!!\n" ) ) ;
        return ;
    }
    _tprintf ( _T ( "BSUGetModuleBaseNameA returned : %S\n" ) , 
               szAnsi                                          ) ;
               
    wchar_t szWide[ MAX_PATH ] ;               
    dwRet = BSUGetModuleBaseNameW ( hProcHandle , 
                                    NULL        , 
                                    szWide      , 
                                    MAX_PATH     ) ;
    ASSERT ( 0 != dwRet ) ;
    if ( 0 == dwRet )
    {
        _tprintf ( _T ( "BSUGetModuleBaseNameW failed!!\n" ) ) ;
        return ;
    }
    _tprintf ( _T ( "BSUGetModuleBaseNameW returned : %s\n" ) , 
               szWide                                          ) ;

    ////////////////////////////////////////////////////////
    
    dwRet = BSUGetModuleFileNameExA ( dwProcID          ,
                                      hProcHandle       , 
                                      hProcessMods[ 0 ] , 
                                      szAnsi            , 
                                      MAX_PATH           ) ;
    ASSERT ( 0 != dwRet ) ;
    if ( 0 == dwRet )
    {
        _tprintf ( _T ( "BSUGetModuleFileNameExA failed!!\n" ) ) ;
        return ;
    }
    _tprintf ( _T ( "BSUGetModuleFileNameExA returned : %S\n" ) , 
               szAnsi                                            ) ;
               
    dwRet = BSUGetModuleFileNameExW ( dwProcID          ,
                                      hProcHandle       , 
                                      hProcessMods[ 0 ] , 
                                      szWide            , 
                                      MAX_PATH           ) ;
    ASSERT ( 0 != dwRet ) ;
    if ( 0 == dwRet )
    {
        _tprintf ( _T ( "BSUGetModuleFileNameExW failed!!\n" ) ) ;
        return ;
    }
    _tprintf ( _T ( "BSUGetModuleFileNameExW returned : %s\n" ) , 
               szWide                                            ) ;
    
    ////////////////////////////////////////////////////////
    
    BSUSetCurrentThreadNameW ( _T ( "Wide Thread Name" ) ) ;
    
    BSUSetCurrentThreadNameA ( "Ansi Thread Name" ) ;

    ////////////////////////////////////////////////////////
    
    _tprintf ( _T ( "IsNT                   = %d\n" ) , IsNT ( ) ) ;
    _tprintf ( _T ( "IsNT4                  = %d\n" ) , IsNT4 ( ) ) ;
    _tprintf ( _T ( "IsW2K                  = %d\n" ) , IsW2K ( ) ) ;
    _tprintf ( _T ( "IsXP                   = %d\n" ) , IsXP ( ) ) ;
    _tprintf ( _T ( "IsServer2003           = %d\n" ) , IsServer2003 ( ) ) ;
    _tprintf ( _T ( "IsW2KorBetter          = %d\n" ) , IsW2KorBetter ( ) ) ;
    _tprintf ( _T ( "IsXPorBetter           = %d\n" ) , IsXPorBetter ( ) ) ;
    _tprintf ( _T ( "IsServer2003orBetter   = %d\n" ) , IsServer2003orBetter ( ) ) ;
    
    
    ////////////////////////////////////////////////////////
    
    BOOL bRet = BSUSymInitializeA ( dwProcID , hProcHandle , NULL , TRUE ) ;
    ASSERT ( TRUE == bRet ) ;
    if ( FALSE == bRet )
    {
        _tprintf ( _T ( "BSUSymInitializeA failed!!\n" ) ) ;
        return ;
    }
    SymCleanup ( hProcHandle ) ;
    
    bRet = BSUSymInitializeW ( dwProcID , hProcHandle , NULL , TRUE ) ;
    ASSERT ( TRUE == bRet ) ;
    if ( FALSE == bRet )
    {
        _tprintf ( _T ( "BSUSymInitializeW failed!!\n" ) ) ;
        return ;
    }
    SymCleanup ( hProcHandle ) ;
    
    ////////////////////////////////////////////////////////
    int iCount = GetSuperAssertionCount ( ) ;
    if ( 0 != iCount )
    {
        _tprintf ( _T ( "One of the tests failed!!\n" ) ) ;
    }
    
    DiagOutputW ( _T ( "All done!\n" ) ) ;
    
    MemStressInitializeA ( "BSU_Is_Tests.exe" ) ;
    MemStressTerminate ( ) ;
    
    // Get rid of the allocate list of modules.
    HeapFree ( GetProcessHeap ( ) , 0 , hProcessMods ) ;
}