HRESULT CBkScanImp::QueryLastScanInfo( int nScanMode, BK_SCAN_INFO& scanInfo ) { BKSVC_DEBUG_TRACE( L"[CBkScanImp] QueryLastScanInfo\n" ); #ifdef _DEBUG //scanInfo.CantCleanVirus = 10; //scanInfo.CleanedVirus = 101; //scanInfo.CleanFailedCount = 2; //scanInfo.LastScanFileName = L"f:\\virus list\\2009-10-2\\YZ@=U~ZIOT"; //scanInfo.Progress = 100; //scanInfo.QueryFailedCount = 0; //scanInfo.RebootCount = 123; //scanInfo.SafeCount = 1111111; //scanInfo.ScanFinished = TRUE; #endif HRESULT hr = S_OK; hr = CheckInstance(); if ( FAILED( hr ) ) { goto Exit0; } scanInfo.ScanMode = nScanMode; hr = m_pScanIns->m_obj.QueryLastScanInfo( scanInfo ); Exit0: return hr; }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { MSG msg = {0}; INITCOMMONCONTROLSEX icex; DWORD dwICC = ICC_ANIMATE_CLASS | \ ICC_BAR_CLASSES | \ ICC_COOL_CLASSES | \ ICC_DATE_CLASSES | \ ICC_LISTVIEW_CLASSES | \ ICC_PROGRESS_CLASS | \ ICC_TAB_CLASSES | \ ICC_TREEVIEW_CLASSES | \ ICC_UPDOWN_CLASS | \ ICC_USEREX_CLASSES | \ ICC_WIN95_CLASSES; icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = dwICC; ::InitCommonControlsEx(&icex); if(CheckInstance() == TRUE) return FALSE; MainDialog mainDlg; return (int)mainDlg.Create(hInstance, NULL); };
HRESULT CBkScanImp::QueryCleanInfo( BK_CLEAN_INFO& cleanInfo ) { BKSVC_DEBUG_TRACE( L"[CBkScanImp] QueryCleanInfo\n" ); HRESULT hr = S_OK; hr = CheckInstance(); if ( FAILED( hr ) ) { goto Exit0; } hr = m_pScanIns->m_obj.QueryCleanInfo( cleanInfo ); Exit0: return hr; }
HRESULT CBkScanImp::SetScanSetting( BK_SCAN_SETTING& setting ) { BKSVC_DEBUG_TRACE( L"[CBkScanImp] SetScanSetting\n" ); HRESULT hr = S_OK; hr = CheckInstance(); if ( FAILED( hr ) ) { goto Exit0; } memcpy( &m_setting, &setting, sizeof( BK_SCAN_SETTING ) ); Exit0: return hr; }
HRESULT CBkScanImp::Clean( CAtlArray<DWORD>& fileIndex ) { BKSVC_DEBUG_TRACE( L"[CBkScanImp] Clean\n" ); HRESULT hr = S_OK; hr = CheckInstance(); if ( FAILED( hr ) ) { goto Exit0; } hr = m_pScanIns->m_obj.Clean( fileIndex ); Exit0: return hr; }
HRESULT CBkScanImp::QueryFileInfo( int nType, DWORD dwIndex, BK_FILE_INFO& fileInfo ) { BKSVC_DEBUG_TRACE( L"[CBkScanImp] QueryFileInfo\n" ); HRESULT hr = S_OK; hr = CheckInstance(); if ( FAILED( hr ) ) { goto Exit0; } hr = m_pScanIns->m_obj.QueryFileInfo( nType, dwIndex, fileInfo ); Exit0: return hr; }
HRESULT CBkScanImp::Stop() { BKSVC_DEBUG_TRACE( L"[CBkScanImp] Stop\n" ); HRESULT hr = S_OK; hr = CheckInstance(); if ( FAILED( hr ) ) { goto Exit0; } hr = m_pScanIns->m_obj.Stop(); Exit0: return hr; }
HRESULT CBkScanImp::GetScanSetting( BK_SCAN_SETTING& setting ) { BKSVC_DEBUG_TRACE( L"[CBkScanImp] GetScanSetting\n" ); HRESULT hr = S_OK; hr = CheckInstance(); if ( FAILED( hr ) ) { goto Exit0; } hr = m_pScanIns->m_obj.GetScanSetting( setting ); setting.bAutoClean = m_setting.bAutoClean; Exit0: return hr; }
BOOL Taiga::InitInstance() { // Check another instance if (CheckInstance(L"Taiga-33d5a63c-de90-432f-9a8b-f6f733dab258", L"TaigaMainW")) return FALSE; g_hInstance = GetInstanceHandle(); // Initialize InitCommonControls(ICC_STANDARD_CLASSES); OleInitialize(NULL); // Initialize logger #ifdef _DEBUG Logger.SetOutputPath(AddTrailingSlash(GetCurrentDirectory()) + L"Taiga_debug.log"); Logger.SetSeverityLevel(LevelDebug); #else Logger.SetOutputPath(AddTrailingSlash(GetPathOnly(GetModulePath())) + L"Taiga.log"); Logger.SetSeverityLevel(LevelWarning); #endif // Load data LoadData(); // Create API windows Skype.Create(); TaigaApi.Create(); if (Settings.Program.StartUp.check_new_version) { // Create update dialog ExecuteAction(L"CheckUpdates"); } else { // Create main dialog ExecuteAction(L"MainDialog"); } return TRUE; }
HRESULT CBkScanImp::Scan2( int nScanMode, BOOL bBackGround, CAtlArray<BK_SCAN_ADDITIONAL_PATH>& lpParam ) { BKSVC_DEBUG_TRACE( L"[CBkScanImp] Scan2\n" ); #ifdef _DEBUG for ( size_t i = 0; i < lpParam.GetCount(); i++ ) { BKSVC_DEBUG_TRACE( L"[CBkScanImp] path[%d]=%s\n", i, lpParam[ i ].strFilePath ); } #endif HRESULT hr = S_OK; hr = CheckInstance(); if ( FAILED( hr ) ) { goto Exit0; } m_pScanIns->m_obj.SetScanSetting( m_setting ); hr = m_pScanIns->m_obj.Scan2( nScanMode, bBackGround, lpParam ); Exit0: return hr; }
UINT_PTR CNavDesktopModule::Main() { if (!CheckInstance()) { return 0; } if (_InitDownInterface()) { _UpdateSelf();//程序升级 _UpdateXmlConfig();//更新界面布局xml文件 } CMessageLoop theLoop; _Module.AddMessageLoop(&theLoop); { TCHAR szPath[MAX_PATH + 1] = _T(""); ::GetModuleFileName(NULL, szPath, MAX_PATH); CPath ConfigFile; ConfigFile = szPath; ConfigFile.RemoveFileSpec(); ConfigFile.Append(L"config.dat"); CXmlReader XmlReader; if (XmlReader.LoadFile(CStringA(ConfigFile))) { if (XmlReader.Open("root\\SizeMode")) XmlReader.Read("value", Config::SizeMode); if (XmlReader.Open("root\\SkinTheme")) XmlReader.Read("value", Config::SkinTheme); if (XmlReader.Open("root\\ShowFloatBar")) XmlReader.Read("value", Config::ShowFloatBar); if (XmlReader.Open("root\\wVirtualKeyCode")) XmlReader.Read("value", (int&)Config::wVirtualKeyCode); if (XmlReader.Open("root\\wModifiers")) XmlReader.Read("value", (int&)Config::wModifiers); if (XmlReader.Open("root\\CloseMode")) XmlReader.Read("value", Config::CloseMode); if (XmlReader.Open("root\\StartupMode")) XmlReader.Read("value", Config::StartupMode); if (XmlReader.Open("root\\Transparent")) XmlReader.Read("value", Config::Transparent); if (XmlReader.Open("root\\TransparentPercent")) XmlReader.Read("value", Config::TransparentPercent); } } CMainWnd MainWnd; if (MainWnd.Create(NULL) == NULL) { ATLTRACE(_T("Main dialog creation failed!\n")); return 0; } int nRet = theLoop.Run(); _Module.RemoveMessageLoop(); return nRet; }
BOOL CiUMeApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); AfxEnableControlContainer(); // 创建 shell 管理器,以防对话框包含 // 任何 shell 树视图控件或 shell 列表视图控件。 CShellManager *pShellManager = new CShellManager; // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); m_strApp = GetApp(); CPaintManagerUI::SetInstance(m_hInstance); if (!CheckInstance()) // 检查是否有另一个实例运行 return FALSE; #if 0 CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("\\iUMe")); #else CPaintManagerUI::SetResourceZip(_T("iUMe.zip")); #endif HRESULT Hr = ::CoInitialize(NULL); if( FAILED(Hr) ) return 0; CClient* pFrame = new CClient(); if( pFrame == NULL ) return 0; pFrame->Create(NULL, _T("iUMe"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE); pFrame->SetIcon(IDR_Client); // 设置任务栏中的图标 pFrame->CenterWindow(); pFrame->ShowWindow(true); pFrame->SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); CPaintManagerUI::MessageLoop(); ::CoUninitialize(); // 删除上面创建的 shell 管理器。 if (pShellManager != NULL) { delete pShellManager; } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
//*================================================================================= //*原型: void TServer::RunService(LPCTSTR pszServiceName, //* LPCTSTR pszDisplayName, LPSTR lpCmdLine) //*功能: 服务器入口 //*参数: pszServiceName -- 服务器名称 //* pszDisplayName -- 服务器显示名称 //* lpCmdLine -- 命令行 //*返回: 无 //*说明: WINNT服务器基类 //*================================================================================= void TServer::RunService(LPCTSTR pszServiceName, LPCTSTR pszDisplayName, LPSTR lpCmdLine) { //检测操作系统版本 CheckOSVersion(); m_pszServiceName = pszServiceName ; m_pszDisplayName = pszDisplayName ; bDebug = TRUE; //add by lina 20050311 //帮助 if( !lstrcmp(lpCmdLine, "help") ) { PrintHelp(); return ; } //调试模式(仅供现场测试及内部测试用) else if( !lstrcmp(lpCmdLine, "debug") ) { bDebug = TRUE ; } //安装为服务器 else if( !lstrcmp(lpCmdLine, "install") ) { InstallService(m_pszServiceName, m_pszDisplayName); return ; } //删除服务器 else if( !lstrcmp(lpCmdLine, "delete") ) { DeleteService(m_pszServiceName); return ; } //Start服务器 else if( !lstrcmp(lpCmdLine, "start") ) { StartServer(m_pszServiceName); return ; } //停止服务器 else if( !lstrcmp(lpCmdLine, "stop") ) { WriteLog("停止服务器!!!!........\n"); printf("停止服务器!!!!........\n"); //StopServer(m_pszServiceName); EndService(m_pszServiceName); return ; } CheckInstance(); /*SECURITY_ATTRIBUTES sa; SECURITY_DESCRIPTOR sd; sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = TRUE; sa.lpSecurityDescriptor = &sd; if( InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION) ) { SetSecurityDescriptorDacl(&sd, TRUE, (PACL)NULL, FALSE); } m_hShutdown = CreateEvent(&sa, FALSE, FALSE, "__SMART_SERVER_SHUTDOWN__"); if( m_hShutdown == NULL ) { throw TException("Call CreateEvent() Faild!", GetLastError()); }*/ if( bDebug ) { SetConsole(); ServiceMain(0, NULL); } else { SERVICE_TABLE_ENTRY DispatchTable[] = { {(LPTSTR)m_pszServiceName, ServiceMain}, {NULL, NULL} }; //先试着从服务管理器中启动, 如失败, 则用无窗口的方式启动 if( !StartServiceCtrlDispatcher(DispatchTable)) { /* bDebug = TRUE; ServiceMain(0, NULL); MSG msg; while (GetMessage(&msg, 0, 0, 0)) DispatchMessage(&msg); */ } } }