void CFilterDialog::OnSelchangeFltList() { // TODO: Add your control notification handler code here UpdateData(); m_cfg = m_setting.SelectParm((LPCTSTR)m_name); MyWriteProfileString(_T("cfg"),_T("cur_filter"),m_name); CFGToSetting(); UpdateData(FALSE); }
void CFilterDialog::OnModify() { // TODO: Add your control notification handler code here UpdateData(); SettingToCFG(); m_setting.SaveParm(m_cfg); m_setting.StoreToFile(DEFINFO); MyWriteProfileString(_T("cfg"),_T("cur_filter"),m_name); ::AfxMessageBox(_T("Ð޸ijɹ¦")); }
int RCSAPI RCSSetSystem( rcsdata data, int rcs_type ) { userData *d = (userData*)data; if( d==NULL ) return( 0 ); if( !d->setSystem( rcs_type ) ) return( FALSE ); if( rcs_type > MAX_RCS_TYPE ) return( FALSE ); MyWriteProfileString( d->getCfgDir(), RCS_CFG, RCS_SECTION, RCS_KEY, rcs_type_strings[rcs_type] ); return( TRUE ); }
void CFilterDialog::OnAddScheme() { // TODO: Add your control notification handler code here CString newname; CListBox *list = ((CListBox*)GetDlgItem(IDC_CTRL)); UpdateData(); newname.Format(_T("Â˲¨Æ÷%d"),list->GetCount()+1); SettingToCFG(); swscanf(newname,_T("%s"),m_cfg.sTitle); m_setting.SaveParm(m_cfg); m_setting.StoreToFile(DEFINFO); MyWriteProfileString(_T("cfg"),_T("cur_filter"),newname); list->AddString(newname); UpdateData(FALSE); }
BOOL CWinHTTrackApp::InitInstance() { /* See <https://msdn.microsoft.com/library/ff919712> */ #if (defined(_WIN32) && (!defined(_DEBUG))) { /* See KB 2389418 "If this parameter is an empty string (""), the call removes the current directory from the default DLL search order" */ BOOL (WINAPI*const k32_SetDllDirectoryA)(LPCSTR) = (BOOL (WINAPI *)(LPCSTR)) GetProcAddress(GetModuleHandle("kernel32.dll"), "SetDllDirectoryA"); if (k32_SetDllDirectoryA != NULL && !k32_SetDllDirectoryA("")) { /* Do no choke on NT or 98SE with KernelEx NT API (James Blough) */ const DWORD dwVersion = GetVersion(); const DWORD dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); const DWORD dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); if (dwMajorVersion >= 5) { assertf(!"SetDllDirectory failed"); } } } #endif /* No error messageboxes */ SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX); /* Inits */ CrashReportInit(); hts_set_error_callback(httrackErrorCallback); hts_init(); WhttMutex = CreateMutex(NULL,FALSE,NULL); // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey("WinHTTrack Website Copier"); LANG_INIT(); // petite init langue /* INDISPENSABLE pour le drag&drop! */ InitCommonControls(); if (!AfxOleInit()) { AfxMessageBox(LANG(LANG_F1)); return FALSE; } AfxEnableControlContainer(); // Pointeur sur CShellApp CShellApp_app=&app; this_app=this; _Cinprogress_inst=NULL; LibRasUse=0; // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. httrack_icon=AfxGetApp()->LoadIcon(IDR_MAINFRAME); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. // DOC // CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CWinHTTrackDoc), RUNTIME_CLASS(CSplitterFrame), // main SDI frame window RUNTIME_CLASS(CView)); AddDocTemplate(pDocTemplate); /* CMDIFrameWnd* pMainFrame = new CMDIFrameWnd; if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; */ // create main window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; int nCmdShow = m_nCmdShow; // Also in this example, there is only one menubar shared between // all the views. The automatic menu enabling support of MFC // will disable the menu items that don't apply based on the // currently active view. The one MenuBar is used for all // document types, including when there are no open documents. // enable file manager drag/drop and DDE Execute open pMainFrame->DragAcceptFiles(); // Now finally show the main menu //pMainFrame->ShowWindow(m_nCmdShow); //pMainFrame->UpdateWindow(); m_pMainWnd = pMainFrame; // command line arguments are ignored, create a new (empty) document //OnFileNew(); // DOC // // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); TCHAR ModulePath[MAX_PATH + 1]; ModulePath[0] = '\0'; ::GetModuleFileName(NULL, ModulePath, sizeof(ModulePath)/sizeof(TCHAR) - 1); hts_rootdir(ModulePath); // Restore position ((CMainFrame*)m_pMainWnd)->InitialShowWindow(nCmdShow); pMainFrame->UpdateWindow(); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // Init Winsock WSockInit(); // The one and only window has been initialized, so show and update it. //m_pMainWnd->ShowWindow(SW_SHOW); //m_pMainWnd->UpdateWindow(); /*CWinApp* app=AfxGetApp(); POSITION pos; pos=app->GetFirstDocTemplatePosition(); CDocTemplate* templ = app->GetNextDocTemplate(pos); pos=templ->GetFirstDocPosition(); CDocument* doc = templ->GetNextDoc(pos); CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CTest ); CObject* pObject = pRuntimeClass->CreateObject(); ASSERT( pObject->IsKindOf( RUNTIME_CLASS( CTest ) ) ); doc->AddView((CView*) pObject); */ { // enable file manager drag/drop and DDE Execute open EnableShellOpen(); RegisterShellFileTypes(); CWinApp* pApp = AfxGetApp(); // register "New File" handler if (pApp->GetProfileInt("Interface","SetupRun",0) != 1 || pApp->GetProfileInt("Interface","SetupHasRegistered",0) == 1) { HKEY phkResult; DWORD creResult; if (RegCreateKeyEx(HKEY_CLASSES_ROOT,".whtt",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&phkResult,&creResult)==ERROR_SUCCESS) { RegCloseKey(phkResult); if (RegCreateKeyEx(HKEY_CLASSES_ROOT,".whtt\\ShellNew",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&phkResult,&creResult)==ERROR_SUCCESS) { char voidbuff='\0'; RegSetValueEx(phkResult,"NullFile",0,REG_SZ,(LPBYTE)&voidbuff,1); RegCloseKey(phkResult); } } } // Infos la 1ere fois! if (pApp->GetProfileInt("Interface","FirstRun",0) != 3) { pApp->WriteProfileInt("Interface","FirstRun",3); Cabout about; about.DoModal(); // Default proxy? Check is the current IP looks local or not. BOOL isPublic = FALSE; char hostname[256]; if (gethostname(hostname, sizeof(hostname) - 1) == 0) { struct addrinfo* res = NULL; struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; if (getaddrinfo(hostname, NULL, &hints, &res) == 0) { if (res->ai_addr != NULL && res->ai_addrlen > 0) { if (res->ai_family == AF_INET) { sockaddr_in *const si = (sockaddr_in*) res->ai_addr; const unsigned char *const ipv4 = (unsigned char*) &si->sin_addr; isPublic = ! ( ipv4[0] == 10 /* 10/8 */ || (ipv4[0] == 192 && ipv4[1] == 168) /* 192.168/16 */ || (ipv4[0] == 172 && ipv4[1] >= 16 && ipv4[1] <= 31) /* 172.16/12 */ ); } else if (res->ai_family == AF_INET6) { /* assume no more proxy */ isPublic = TRUE; } } } if (res) { freeaddrinfo(res); } } if (!isPublic && maintab) { maintab->DefineDefaultProxy(); if (maintab->DoModal()!=IDCANCEL) { // Default proxy values CString strSection = "OptionsValues"; MyWriteProfileString("",strSection, "Proxy",maintab->m_option10.m_proxy); MyWriteProfileString("",strSection, "Port",maintab->m_option10.m_port); } maintab->UnDefineDefaultProxy(); } } } #ifdef HTTRACK_AFF_WARNING #ifndef _DEBUG AfxMessageBox("--WARNING--\r\n"HTTRACK_AFF_WARNING); #endif #endif return TRUE; }
void CDlgPluginSetup::OnOK() { // TODO: この位置にその他の検証用のコードを追加してください CSuperTagEditorApp *pApp = (CSuperTagEditorApp *)AfxGetApp(); CString strINI; wchar_t drive[_MAX_DRIVE]; wchar_t dir[_MAX_DIR]; wchar_t buff[_MAX_PATH] = {'\0'}; { wchar_t* szName = pApp->MakeFileName(L"ini"); _tsplitpath(szName, drive, dir, NULL, NULL); _tmakepath(buff, drive, dir, L"Plugin", L"ini"); strINI = buff; delete szName; //DeleteFile(strINI); } Profile_Initialize(strINI, FALSE); CString strSection; for (int nIndex=0;nIndex<m_listPlugin.GetItemCount();nIndex++) { PSTEPlugin pPlugin = (PSTEPlugin)m_listPlugin.GetItemData(nIndex); pPlugin->bUse = ListView_GetCheckState(m_listPlugin.GetSafeHwnd(), nIndex) ? true : false; strSection.Format(L"Load%03d", nIndex); // 相対パスに変換 wchar_t pDrive[_MAX_DRIVE]; wchar_t pDir[_MAX_DIR]; wchar_t pFname[_MAX_FNAME]; wchar_t pExt[_MAX_EXT]; wchar_t pBuff[_MAX_PATH] = {'\0'}; _tsplitpath(pPlugin->sFileName, pDrive, pDir, pFname, pExt); if (wcscmp(pDrive, drive) == 0) { //wchar_t pWDir[_MAX_DIR]; //wchar_t pWFname[_MAX_FNAME]; //wchar_t pRDir[_MAX_DIR] = {'\0'}; //wchar_t pRFname[_MAX_FNAME]; CString strRelDir = L""; ULONG nPathSeparatorIndex; BOOL bAnyParent; ULONG i; nPathSeparatorIndex = 0; i = 0; #ifndef iskanji #define iskanji(c) ((c) >= 0x81 && (c) <= 0x9f || (c) >= 0xe0 && (c) <= 0xfc) #endif while ((dir[i] == pDir[i] ) && (dir[i] != 0)) { if (!iskanji(dir[i])) { if (dir[i] == '\\' ) { nPathSeparatorIndex = i; } } else { i++; } i++; } if (dir[nPathSeparatorIndex] != '\\') { strRelDir = pDir; } else { i = nPathSeparatorIndex + 1; bAnyParent = FALSE; while (dir[i] != 0) { if (dir[i] == '\\') { bAnyParent = TRUE; strRelDir += L"..\\"; } i++; } if (!bAnyParent) { strRelDir += L".\\"; } } strRelDir += pDir+nPathSeparatorIndex+1; _tmakepath(pBuff, NULL, strRelDir, pFname, pExt); } else { // 変換なし _tmakepath(pBuff, pDrive, pDir, pFname, pExt); } MyWriteProfileString(strSection, L"Path", pBuff/*pPlugin->sFileName*/); //WritePrivateProfileString(strSection, L"Path", pPlugin->sFileName, strINI); MyWriteProfileString(strSection, L"Use", pPlugin->bUse ? L"1" : L"0"); //WritePrivateProfileString(strSection, L"Use", pPlugin->bUse ? L"1" : L"0", strINI); } Profile_Flush(strINI); Profile_Free(); CDialog::OnOK(); }