bool RegisterComDLL(HINSTANCE hin,LPCTSTR dll) { TCHAR curpath[MAX_PATH]; GetModuleFileName( hin, curpath, MAX_PATH ); PathRemoveFileSpec(curpath); ATL::CString file; file += "regsvr32 \""; file += curpath; file += "\\"; file += dll; file += "\" /s"; STARTUPINFO si={0}; si.cb = sizeof(si); PROCESS_INFORMATION pi={0}; if(!CreateProcess( NULL,(LPWSTR)file.GetString(), NULL,NULL,FALSE,0, NULL,NULL,&si, &pi )) { DebugOutF(filelog::log_error,"CreateProcess failed with %d",GetLastError() ); return false; } WaitForSingleObject(pi.hProcess,-1); DWORD exitcode = 0; GetExitCodeProcess(pi.hProcess,&exitcode); if(pi.hProcess)CloseHandle(pi.hProcess); if(pi.hThread)CloseHandle(pi.hThread); return exitcode == 0; }
LRESULT CSiteSelectedBoxWnd::OnClicked_BtnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { ATL::CString strName; m_ctrlSiteCombo.GetLBText(m_ctrlSiteCombo.GetCurSel(), strName); map<TSTLSTRING, TSTLSTRING>::iterator iterSite = m_SiteMap.find(strName.GetString()); if(iterSite == m_SiteMap.end()) { MessageBox(TEXT("您没有选择站点?"), TEXT("提示"), MB_OK|MB_ICONINFORMATION); bHandled = TRUE; return 0; } try { ConfigureManager::GetInstance().SetSettingValue(TEXT("sitename"), iterSite->second); ConfigureManager::GetInstance().Save(); } catch(Exception& error) { MessageBox(error.GetMessage().c_str(), TEXT("错误"), MB_OK|MB_ICONERROR); } DestroyWindow(); if(!OnSelected.m_EventList.empty()) { Event< SiteSelected >::EventIterator iter; for( iter = OnSelected.m_EventList.begin(); iter != OnSelected.m_EventList.end(); ++iter ) { InvokeEvent(true, iterSite->second); } } bHandled = TRUE; return 0; }