BOOL WINAPI ScreenSaverConfigureDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: ReadRegistry(); CheckDlgButton(hDlg, ROTATE, dRotate); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: dRotate = (IsDlgButtonChecked(hDlg, ROTATE) == BST_CHECKED); WriteRegistry(); EndDialog(hDlg, TRUE); return TRUE; case IDCANCEL: EndDialog(hDlg, TRUE); break; case IDABOUT: DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLG_ABOUT), hDlg, (DLGPROC)AboutProc); break; } } return FALSE; }
//--------------------------------------------------------------- // Purpose: //--------------------------------------------------------------- void CstarterDlg::SaveToReg() { regvals_t regVals; m_cbResolution.GetWindowText(regVals.resolution); regVals.fullscreenChoice = m_bFullscreen.GetCheck(); regVals.connectChoice = m_iConnectChoice; m_eIP.GetWindowText(regVals.ip); m_cbMap.GetWindowText(regVals.map); m_eNickname.GetWindowText(regVals.nickname); WriteRegistry(regVals); }
bool FileManager::AddSource(string source) { if (IsSourceRegistered(source)) { cout << "Feed is already being tracked.\n"; return false; } vector< pair<string,string> > regs = GetRegisteredSources(); regs.push_back( pair<string,string>(FilenameFromSource(source), source) ); WriteRegistry(regs); return true; }
bool rab::RollABall::ProcessData( Options const& options, Config& config, DiffEncoders const& diffEncoders, LogOutput_t& out ) { bool result = true; if( diffEncoders.Empty() ) { out << "No encoders added!" << std::endl; return false; } out << "Building optimized regular expressions..." << std::endl; config.BuildRegexps(); FolderInfo rootFolder; BuildFileTree( options, config, rootFolder, out ); zip::ZipArchiveOutput zipOut; if( !zipOut.Open( options.packageFile, true, config.zipCompressionLevel ) ) { out << "Can't open zip archive " << options.packageFile << " zip error: " << zipOut.ErrorMessage() << std::endl; return false; } result &= BuildTempCopies( options, config, rootFolder, zipOut, out ); result &= BuildDiffs( options, config, diffEncoders, rootFolder, zipOut, out ); result &= GatherSha1( options, config, rootFolder, out ); result &= WriteRegistry( options, config, rootFolder, zipOut, out ); if( !zipOut.Close() ) { out << "Can't close zip archive " << options.packageFile << " zip error: " << zipOut.ErrorMessage() << std::endl; result = false; } if( result ) out << "Successfully done!" << std::endl; else out << "FAILED." << std::endl; return result; }
bool FileManager::RemoveSource(string source) { vector< pair<string,string> > regs = GetRegisteredSources(); int bestIdx = -1; int partialMatches = 0; for (int i=0; i<regs.size(); i++) { if (regs[i].second == source) { partialMatches = -1; bestIdx = i; } else if (partialMatches >= 0) { if (regs[i].second.find(source) != string::npos) { partialMatches++; bestIdx = i; } } } if (bestIdx >= 0) { if (partialMatches > 1) { cout << partialMatches << " matches found, none has been removed.\n"; cout << "Be more specific, please.\n"; return false; } else { cout << "Removed source:\n\t" << regs[bestIdx].second << "\n"; remove(regs[bestIdx].first.c_str()); // Delete the cache-file regs.erase(regs.begin() + bestIdx); WriteRegistry(regs); } } else { cout << "No feed containing '" << source << "' found.\n"; return false; } return true; }
/*------------------------------------------------------------------------ Procedure: GetOcamlPath ID:1 Purpose: Read the registry key HKEY_LOCAL_MACHINE\Software\Objective Caml or HKEY_CURRENT_USER\Software\Objective Caml, and creates it if it doesn't exists. If any error occurs, i.e. the given path doesn't exist, or the key didn't exist, it will put up a browse dialog box to allow the user to enter the path. The path will be verified that it points to a file that exists. If that file is in a directory called 'bin', it will look for another directory in the same level called lib' and set the Lib path to that. Input: None explicit Output: 1 means sucess, zero failure Errors: Almost all system calls will be verified ------------------------------------------------------------------------*/ int GetOcamlPath(void) { char path[1024], *p; while (( !ReadRegistry(HKEY_CURRENT_USER, "Software", "Objective Caml", "InterpreterPath", path) && !ReadRegistry(HKEY_LOCAL_MACHINE, "Software", "Objective Caml", "InterpreterPath", path)) || _access(path, 0) != 0) { /* Registry key doesn't exist or contains invalid path */ /* Ask user */ if (!BrowseForFile("Ocaml interpreter|ocaml.exe", path)) { ShowDbgMsg("Impossible to find ocaml.exe. I quit"); exit(0); } WriteRegistry(HKEY_CURRENT_USER, "Software", "Objective Caml", "InterpreterPath", path); /* Iterate to validate again */ } strcpy(OcamlPath, path); p = strrchr(OcamlPath,'\\'); if (p) { *p = 0; strcpy(LibDir,OcamlPath); *p = '\\'; p = strrchr(LibDir,'\\'); if (p && !stricmp(p,"\\bin")) { *p = 0; strcat(LibDir,"\\lib"); } } return 1; }
BOOL Cfg::ReadRegistry(void) { char buf[MAX_BUF], val[MAX_BUF]; int i; GetRegName(buf, nicAddr, portNo); TRegistry reg(HS_TOOLS, buf); if (!reg.GetInt(NOPOPUPCHECK_STR, &NoPopupCheck)) { GetRegName(buf, 0, portNo); reg.ChangeApp(HS_TOOLS, buf); if (!reg.GetInt(NOPOPUPCHECK_STR, &NoPopupCheck)) reg.ChangeApp(HS_TOOLS, GetLoadStr(IDS_IPMSG)); } lcid = -1; NoBeep = FALSE; NoTcp = FALSE; ListGet = FALSE; HotKeyCheck = TRUE; HotKeyModify = MOD_ALT|MOD_CONTROL; HotKeySend = 'S'; HotKeyRecv = 'R'; HotKeyMisc = 'D'; ListGetMSec = IPMSG_DEFAULT_LISTGETMSEC; RetryMSec = IPMSG_DEFAULT_RETRYMSEC; RetryMax = IPMSG_DEFAULT_RETRYMAX; RecvMax = IsWinNT() ? IPMSG_DEFAULT_RECVMAX_NT : IPMSG_DEFAULT_RECVMAX_95; NoErase = FALSE; Debug = FALSE; NoPopupCheck = TRUE; OpenCheck = 1; AbsenceSave = FALSE; AbsenceCheck = FALSE; AbsenceMax = IPMSG_DEFAULT_ABSENCEMAX; AbsenceChoice = 0; FindMax = IPMSG_DEFAULT_FINDMAX; FindAll = TRUE; DelayTime = IPMSG_DEFAULT_DELAY; QuoteCheck = TRUE; SecretCheck = TRUE; LogonLog = TRUE; RecvLogonDisp = FALSE; IPAddrCheck = TRUE; RecvIPAddr = TRUE; OneClickPopup = FALSE; BalloonNotify = TRUE; TrayIcon = TRUE; AbnormalButton = FALSE; DialUpCheck = FALSE; *NickNameStr = 0; *GroupNameStr = 0; AbsenceNonPopup = TRUE; Sort = IPMSG_NAMESORT; UpdateTime = IPMSG_DEFAULT_UPDATETIME; KeepHostTime = IPMSG_DEFAULT_KEEPHOSTTIME; DefaultUrl = TRUE; ShellExec = FALSE; ExtendEntry = TRUE; ExtendBroadcast = 1; MulticastMode = 0; ControlIME = 1; GridLineCheck = TRUE; PriorityMax = DEFAULT_PRIORITYMAX; PriorityReject = 0; AllowSendList = TRUE; fileTransOpt = 0; ResolveOpt = 0; LetterKey = IsLang(LANG_JAPANESE) ? FALSE : TRUE; RemoteGraceSec = IPMSG_DEFAULT_REMOTEGRACE; RemoteRebootMode = 0; *RemoteReboot = 0; RemoteExitMode = 0; *RemoteExit = 0; ClipMode = IPMSG_DEFAULT_CLIPMODE; ClipMax = IPMSG_DEFAULT_CLIPMAX; CaptureDelay = 300; CaptureDelayEx = 500; CaptureMinimize = TRUE; CaptureClip = TRUE; CaptureSave = FALSE; OpenMsgTime = IPMSG_DEFAULT_OPENMSGTIME; RecvMsgTime = IPMSG_DEFAULT_RECVMSGTIME; BalloonNoInfo = FALSE; TaskbarUI = /*IsWin7() ? TRUE :*/ FALSE; MarkerThick = IPMSG_DEFAULT_MARKER_THICK; IPv6Mode = IPv6ModeNext = 0; strcpy(IPv6Multicast, IPMSG_DEFAULT_MULTICAST_ADDR6); // in ipmsg.h ViewMax = IPMSG_DEFAULT_VIEWMAX; TransMax = IPMSG_DEFAULT_TRANSMAX; TcpbufMax = IPMSG_DEFAULT_TCPBUFMAX; IoBufMax = IPMSG_DEFAULT_IOBUFMAX; LumpCheck = FALSE; EncTransCheck = TRUE; lruUserMax = IPMSG_DEFAULT_LRUUSERMAX; // CryptProtectData is available only Win2K/XP for (i=0; i < MAX_KEY; i++) { priv[i].encryptType = IsWin2K() ? PRIV_BLOB_DPAPI : PRIV_BLOB_RAW; } strncpyz(QuoteStr, IPMSG_DEFAULT_QUOTE, sizeof(QuoteStr)); SendWidth[SW_NICKNAME] = IPMSG_DEFAULT_NICKNAMEWIDTH; SendWidth[SW_ABSENCE] = IPMSG_DEFAULT_ABSENCEWIDTH; SendWidth[SW_GROUP] = IPMSG_DEFAULT_GROUPWIDTH; SendWidth[SW_HOST] = IPMSG_DEFAULT_HOSTWIDTH; SendWidth[SW_IPADDR] = IPMSG_DEFAULT_IPADDRWIDTH; SendWidth[SW_USER] = IPMSG_DEFAULT_USERWIDTH; SendWidth[SW_PRIORITY] = IPMSG_DEFAULT_PRIORITYWIDTH; ColumnItems = 0; SetItem(&ColumnItems, SW_NICKNAME, TRUE); SetItem(&ColumnItems, SW_GROUP, TRUE); SetItem(&ColumnItems, SW_HOST, TRUE); for (i=0; i < MAX_SENDWIDTH; i++) SendOrder[i] = i; SendXdiff = 0; SendYdiff = 0; SendMidYdiff = 0; SendSavePos = 0; SendXpos = 0; SendYpos = 0; RecvXdiff = 0; RecvYdiff = 0; RecvSavePos = 0; RecvXpos = 0; RecvYpos = 0; HistWidth[HW_USER] = IPMSG_DEFAULT_HWUSER_WIDTH; HistWidth[HW_ODATE] = IPMSG_DEFAULT_HWODATE_WIDTH; HistWidth[HW_SDATE] = IPMSG_DEFAULT_HWSDATE_WIDTH; HistWidth[HW_ID] = IPMSG_DEFAULT_HWID_WIDTH; HistXdiff = 0; HistYdiff = 0; LogCheck = TRUE; LogUTF8 = TRUE; PasswdLogCheck = FALSE; *SoundFile = 0; *IconFile = 0; *RevIconFile = 0; *lastSaveDir = *lastOpenDir = 0; *autoSaveDir = 0; autoSaveTout = IPMSG_DEFAULT_AUTOSAVE_TOUT; autoSaveLevel = 0; autoSaveFlags = 0; autoSaveMax = IPMSG_DEFAULT_AUTOSAVE_MAX; memset(&SendEditFont, 0, sizeof(SendEditFont)); memset(&SendListFont, 0, sizeof(SendListFont)); memset(&RecvHeadFont, 0, sizeof(RecvHeadFont)); memset(&RecvEditFont, 0, sizeof(RecvEditFont)); memset(&LogViewFont, 0, sizeof(LogViewFont)); reg.GetInt(LCID_KEY, &lcid); reg.GetInt(NOBEEP_STR, &NoBeep); reg.GetInt(NOTCP_STR, &NoTcp); reg.GetInt(LISTGET_STR, &ListGet); reg.GetInt(LISTGETMSEC_STR, (int *)&ListGetMSec); reg.GetInt(RETRYMSEC_STR, (int *)&RetryMSec); reg.GetInt(RETRYMAX_STR, (int *)&RetryMax); reg.GetInt(IsWinNT() ? RECVMAXNT_STR : RECVMAX95_STR, (int *)&RecvMax); reg.GetInt(NOERASE_STR, &NoErase); reg.GetInt(DEBUG_STR, &Debug); reg.GetInt(NOPOPUPCHECK_STR, &NoPopupCheck); reg.GetInt(OPENCHECK_STR, &OpenCheck); reg.GetInt(ABSENCESAVE_STR, &AbsenceSave); if (AbsenceSave) reg.GetInt(ABSENCECHECK_STR, &AbsenceCheck); reg.GetInt(ABSENCEMAX_STR, &AbsenceMax); reg.GetInt(ALLOWSENDLIST_STR, &AllowSendList); reg.GetInt(FILETRANSOPT_STR, &fileTransOpt); reg.GetInt(RESOLVEOPT_STR, &ResolveOpt); reg.GetInt(LETTERKEY_STR, &LetterKey); reg.GetInt(REMOTEGRACE_STR, &RemoteGraceSec); reg.GetStr(REBOOT_STR, RemoteReboot, sizeof(RemoteReboot)); reg.GetInt(REBOOTMODE_STR, &RemoteRebootMode); reg.GetStr(EXIT_STR, RemoteExit, sizeof(RemoteExit)); reg.GetInt(EXITMODE_STR, &RemoteExitMode); reg.GetInt(CLIPMODE_STR, &ClipMode); ClipMode |= CLIP_ENABLE; reg.GetInt(CLIPMAX_STR, &ClipMax); reg.GetInt(CAPTUREDELAY_STR, &CaptureDelay); reg.GetInt(CAPTUREDELAYEX_STR, &CaptureDelayEx); reg.GetInt(CAPTUREMINIMIZE_STR, &CaptureMinimize); reg.GetInt(CAPTURECLIP_STR, &CaptureClip); reg.GetInt(CAPTURESAVE_STR, &CaptureSave); reg.GetInt(OPENMSGTIME_STR, &OpenMsgTime); reg.GetInt(RECVMSGTIME_STR, &RecvMsgTime); reg.GetInt(BALLOONNOINFO_STR, &BalloonNoInfo); reg.GetInt(TASKBARUI_STR, &TaskbarUI); reg.GetInt(MARKERTHICK_STR, &MarkerThick); reg.GetStr(IPV6MULITCAST, IPv6Multicast, sizeof(IPv6Multicast)); if (IsWinVista()) { reg.GetInt(IPV6MODE_STR, &IPv6Mode); if (nicAddr.size == 16 && !IPv6Mode) IPv6Mode = 2; reg.GetStr(IPV6MULITCAST, IPv6Multicast, sizeof(IPv6Multicast)); if (!*IPv6Multicast) { strcpy(IPv6Multicast, IPMSG_DEFAULT_MULTICAST_ADDR6); // in ipmsg.h } } IPv6ModeNext = IPv6Mode; // for File Transfer reg.GetInt(VIEWMAX_STR, &ViewMax); if (ViewMax < 1024 * 1024) // 1MB 以下の MapFileOfView は認めない ViewMax = IPMSG_DEFAULT_VIEWMAX; reg.GetInt(TRANSMAX_STR, &TransMax); if (TransMax < 8 * 1024) // 8KB 以下の file transfer buf は認めない TransMax = IPMSG_DEFAULT_TRANSMAX; reg.GetInt(TCPBUFMAX_STR, &TcpbufMax); if (TcpbufMax < 8 * 1024) // 8KB 以下の sockbuf は認めない TcpbufMax = IPMSG_DEFAULT_TCPBUFMAX; reg.GetInt(IOBUFMAX_STR, &IoBufMax); if (IoBufMax < TransMax) // transmax 以下の IO/Buf は認めない IoBufMax = TransMax; reg.GetInt(LUMPCHECK_STR, &LumpCheck); reg.GetInt(ENCTRANSCHECK_STR, &EncTransCheck); // for Absence Message typedef char MaxBuf[MAX_PATH_U8]; AbsenceStr = new MaxBuf[AbsenceMax]; memset(AbsenceStr, 0, MAX_PATH_U8 * AbsenceMax); reg.GetStr(ABSENCESTR_STR, AbsenceStr[0], sizeof(AbsenceStr[0])); typedef char MaxHead[MAX_NAMEBUF]; AbsenceHead = new MaxHead[AbsenceMax]; memset(AbsenceHead, 0, MAX_NAMEBUF * AbsenceMax); if (reg.CreateKey(ABSENCESTR_STR)) { for (i=0; i < AbsenceMax; i++) { char key[MAX_PATH_U8]; sprintf(key, "%s%d", ABSENCESTR_STR, i); if (!reg.GetStr(key, AbsenceStr[i], sizeof(AbsenceStr[i]))) strncpyz(AbsenceStr[i], DefaultAbsence[i < IPMSG_DEFAULT_ABSENCEMAX ? i : 0], MAX_PATH_U8); sprintf(key, "%s%d", ABSENCEHEAD_STR, i); if (!reg.GetStr(key, AbsenceHead[i], sizeof(AbsenceHead[i]))) strcpy(AbsenceHead[i], DefaultAbsenceHead[i < IPMSG_DEFAULT_ABSENCEMAX ? i : 0]); } reg.CloseKey(); } // Find User typedef char MaxFind[MAX_NAMEBUF]; if (reg.CreateKey(FINDSTR_STR)) { reg.GetInt(FINDMAX_STR, &FindMax); reg.GetInt(FINDALL_STR, &FindAll); FindStr = new MaxFind[FindMax]; for (i=0; i < FindMax; i++) { char key[MAX_PATH_U8]; sprintf(key, "%d", i); if (!reg.GetStr(key, FindStr[i], sizeof(FindStr[i]))) FindStr[i][0] = '\0'; } reg.CloseKey(); } else { FindStr = new MaxFind[FindMax]; memset(FindStr, 0, MAX_NAMEBUF * FindMax); } reg.GetInt(LRUUSERMAX_STR, &lruUserMax); if (reg.OpenKey(LRUUSERKEY_STR)) { for (i=0; ; i++) { sprintf(buf, "%d", i); if (!reg.OpenKey(buf)) break; UsersObj *obj = new UsersObj; for (int j=0; ; j++) { sprintf(buf, "%d", j); if (!reg.OpenKey(buf)) break; UserObj *u = new UserObj; if (reg.GetStr(USERNAME_STR, u->hostSub.userName, sizeof(u->hostSub.userName)) && reg.GetStr(HOSTNAME_STR, u->hostSub.hostName, sizeof(u->hostSub.userName))) { obj->users.AddObj(u); } reg.CloseKey(); } reg.CloseKey(); lruUserList.AddObj(obj); } reg.CloseKey(); } *PasswordStr = 0; reg.GetStr(PASSWORD_STR, PasswordStr, sizeof(PasswordStr)); reg.GetInt(PASSWDLOGCHECK_STR, &PasswdLogCheck); reg.GetInt(DELAYTIME_STR, &DelayTime); reg.GetInt(QUOTECHECK_STR, &QuoteCheck); reg.GetInt(SECRETCHECK_STR, &SecretCheck); reg.GetInt(LOGONLOG_STR, &LogonLog); reg.GetInt(RECVLOGONDISP_STR, &RecvLogonDisp); reg.GetInt(IPADDRCHECK_STR, &IPAddrCheck); reg.GetInt(RECVIPADDRCHECK_STR, &RecvIPAddr); reg.GetInt(ONECLICKPOPUP_STR, &OneClickPopup); reg.GetInt(BALLOONNOTIFY_STR, &BalloonNotify); reg.GetInt(TRAYICON_STR, &TrayIcon); reg.GetInt(ABNORMALBTN_STR, &AbnormalButton); reg.GetInt(DIALUPCHECK_STR, &DialUpCheck); reg.GetInt(ABSENCENONPOPUP_STR, &AbsenceNonPopup); reg.GetStr(NICKNAMESTR_STR, NickNameStr, sizeof(NickNameStr)); StrictUTF8(NickNameStr); reg.GetStr(GROUPNAMESTR_STR, GroupNameStr, sizeof(GroupNameStr)); StrictUTF8(GroupNameStr); reg.GetLong(SORT_STR, (long *)&Sort); // reg.GetInt(UPDATETIME_STR, &UpdateTime); reg.GetInt(KEEPHOSTTIME_STR, &KeepHostTime); reg.GetInt(DEFAULTURL_STR, &DefaultUrl); reg.GetInt(SHELLEXEC_STR, &ShellExec); reg.GetInt(EXTENDENTRY_STR, &ExtendEntry); reg.GetInt(EXTENDBROADCAST_STR, &ExtendBroadcast); reg.GetInt(MULTICASTMODE_STR, &MulticastMode); reg.GetInt(CONTROLIME_STR, &ControlIME); reg.GetInt(GRIDLINE_STR, &GridLineCheck); reg.GetInt(COLUMNITEMS_STR, (int *)&ColumnItems); reg.GetStr(QUOTESTR_STR, QuoteStr, sizeof(QuoteStr)); if (reg.CreateKey(HOTKEY_STR)) { reg.GetInt(HOTKEYCHECK_STR, &HotKeyCheck); reg.GetInt(HOTKEYMODIFY_STR, &HotKeyModify); reg.GetInt(HOTKEYSEND_STR, &HotKeySend); reg.GetInt(HOTKEYRECV_STR, &HotKeyRecv); reg.GetInt(HOTKEYMISC_STR, &HotKeyMisc); reg.CloseKey(); } reg.GetInt(LOGCHECK_STR, &LogCheck); reg.GetInt(LOGUTF8_STR, &LogUTF8); if (!reg.GetStr(LOGFILE_STR, LogFile, sizeof(LogFile)) || !*LogFile) strncpyz(LogFile, "ipmsg.log", sizeof(LogFile)); LogMng::StrictLogFile(LogFile); reg.GetStr(SOUNDFILE_STR, SoundFile, sizeof(SoundFile)); reg.GetStr(ICON_STR, IconFile, sizeof(IconFile)); reg.GetStr(REVICON_STR, RevIconFile, sizeof(RevIconFile)); reg.GetStr(LASTOPEN_STR, lastOpenDir, sizeof(lastOpenDir)); reg.GetStr(LASTSAVE_STR, lastSaveDir, sizeof(lastSaveDir)); reg.GetStr(AUTOSAVEDIR_STR, autoSaveDir, sizeof(autoSaveDir)); reg.GetInt(AUTOSAVETOUT_STR, &autoSaveTout); reg.GetInt(AUTOSAVEMAX_STR, &autoSaveMax); reg.GetInt(AUTOSAVEFLAGS_STR, &autoSaveFlags); reg.GetInt(AUTOSAVELEVEL_STR, &autoSaveLevel); // Send/Recv Window Location if (reg.CreateKey(WINSIZE_STR)) { reg.GetInt(SENDNICKNAME_STR, &SendWidth[SW_NICKNAME]); reg.GetInt(SENDUSERNAME_STR, &SendWidth[SW_USER]); reg.GetInt(SENDABSENCE_STR, &SendWidth[SW_ABSENCE]); reg.GetInt(SENDPRIORITY_STR, &SendWidth[SW_PRIORITY]); reg.GetInt(SENDGROUPNAME_STR, &SendWidth[SW_GROUP]); reg.GetInt(SENDHOSTNAME_STR, &SendWidth[SW_HOST]); reg.GetInt(SENDIPADDR_STR, &SendWidth[SW_IPADDR]); if (reg.CreateKey(SENDORDER_STR)) { for (i=0; i < MAX_SENDWIDTH; i++) { sprintf(buf, "%d", i); reg.GetInt(buf, &SendOrder[i]); } reg.CloseKey(); } for (i=0; i < MAX_SENDWIDTH; i++) { if (SendOrder[i] >= MAX_SENDWIDTH || SendOrder[i] < 0) break; int i2; for (i2=i+1; i2 < MAX_SENDWIDTH; i2++) if (SendOrder[i] == SendOrder[i2]) break; if (i2 != MAX_SENDWIDTH) break; } if (i != MAX_SENDWIDTH) for (i=0; i < MAX_SENDWIDTH; i++) SendOrder[i] = i; reg.GetInt(SENDXDIFF_STR, &SendXdiff); reg.GetInt(SENDYDIFF_STR, &SendYdiff); reg.GetInt(SENDMIDYDIFF_STR, &SendMidYdiff); reg.GetInt(SENDSAVEPOS_STR, &SendSavePos); reg.GetInt(SENDXPOS_STR, &SendXpos); reg.GetInt(SENDYPOS_STR, &SendYpos); reg.GetInt(RECVXDIFF_STR, &RecvXdiff); reg.GetInt(RECVYDIFF_STR, &RecvYdiff); reg.GetInt(RECVSAVEPOS_STR, &RecvSavePos); reg.GetInt(RECVXPOS_STR, &RecvXpos); reg.GetInt(RECVYPOS_STR, &RecvYpos); reg.GetInt(HISTXDIFF_STR, &HistXdiff); reg.GetInt(HISTYDIFF_STR, &HistYdiff); reg.GetInt(HISTUSER_STR, &HistWidth[HW_USER]); reg.GetInt(HISTODATE_STR, &HistWidth[HW_ODATE]); reg.GetInt(HISTSDATE_STR, &HistWidth[HW_SDATE]); reg.GetInt(HISTID_STR, &HistWidth[HW_ID]); reg.CloseKey(); } // Send/Recv Window Font if (reg.CreateKey(FONT_STR)) { ReadFontRegistry(®, SENDEDITFONT_STR, &SendEditFont); ReadFontRegistry(®, SENDLISTFONT_STR, &SendListFont); ReadFontRegistry(®, RECVHEADFONT_STR, &RecvHeadFont); ReadFontRegistry(®, RECVEDITFONT_STR, &RecvEditFont); ReadFontRegistry(®, LOGVIEWFONT_STR, &LogViewFont); reg.CloseKey(); } // Broadcast Data if (reg.CreateKey(BROADCAST_STR)) { i = 0; while (1) { sprintf(buf, "%d", i++); if (!reg.GetStr(buf, val, sizeof(val))) break; brList.SetHostRaw(val, (ResolveOpt & RS_REALTIME) ? 0 : ResolveAddr(val)); } reg.CloseKey(); } // Clickable URL for (i=0; DefaultUrlProtocol[i]; i++) { UrlObj *obj = new UrlObj; strncpyz(obj->protocol, DefaultUrlProtocol[i], sizeof(obj->protocol)); *obj->program = 0; urlList.AddObj(obj); } if (reg.CreateKey(CLICKABLEURL_STR)) { for (i = 0; reg.EnumValue(i, buf, sizeof(buf)) || reg.EnumKey(i, buf, sizeof(buf)); i++) { UrlObj *obj; for (obj = urlList.TopObj(); obj; obj = urlList.NextObj(obj)) if (stricmp(obj->protocol, buf) == 0) break; if (obj == NULL) { obj = new UrlObj; urlList.AddObj(obj); } strncpyz(obj->protocol, buf, sizeof(obj->protocol)); reg.GetStr(buf, obj->program, sizeof(obj->program)); } reg.CloseKey(); } // User Sort Priority if (reg.CreateKey(PRIORITY_STR)) { reg.GetInt(PRIORITYMAX_STR, &PriorityMax); reg.GetInt(PRIORITYREJECT_STR, &PriorityReject); #if 0 PrioritySound = new char *[PriorityMax]; for (int i=0; i < PriorityMax; i++) { sprintf(buf, "%d", i); if (reg.CreateKey(buf)) { if (reg.GetStr(PRIORITYSOUND_STR, buf, sizeof(buf)) && *buf != '\0') PrioritySound[i] = strdup(buf); reg.CloseKey(); } } #endif reg.CloseKey(); } if (reg.CreateKey(HOSTINFO_STR)) { int i = 0, priority = DEFAULT_PRIORITY; Host *host; Time_t default_time = Time() - KeepHostTime / 2; // 90 日 BOOL rewriteFlg = FALSE; priorityHosts.Enable(THosts::NAME, TRUE); fileHosts.Enable(THosts::NAME_ADDR, TRUE); for (i = 0; reg.EnumValue(i, buf, sizeof(buf)) || reg.EnumKey(i, buf, sizeof(buf)); i++) { if (!reg.OpenKey(buf)) break; BYTE pubkey[512]; int pubkeySize = sizeof(pubkey); if (!reg.GetByte(PUBLICKEY_STR, pubkey, &pubkeySize)) pubkeySize = 0; if ((!reg.GetInt(PRIORITY_STR, &priority) || priority == DEFAULT_PRIORITY) && pubkeySize == 0) { rewriteFlg = TRUE; } else { host = new Host; host->priority = priority; reg.GetStr(USERNAME_STR, host->hostSub.userName, MAX_NAMEBUF); reg.GetStr(HOSTNAME_STR, host->hostSub.hostName, MAX_NAMEBUF); reg.GetLong(IPADDR_STR, (long *)&host->hostSub.addr); reg.GetInt(PORTNO_STR, &host->hostSub.portNo); reg.GetStr(NICKNAME_STR, host->nickName, MAX_NAMEBUF); reg.GetStr(GROUPNAME_STR, host->groupName, MAX_NAMEBUF); reg.GetStr(ALTERNAME_STR, host->alterName, MAX_NAMEBUF); if (!reg.GetLong(UPDATETIME_STR, (long *)&host->updateTime)) { host->updateTime = default_time; } if (pubkeySize) { host->pubKey.UnSerialize(pubkey, pubkeySize); // 古いエントリを削除にする処理は、一旦、様子見 // char *p = (char *)GetUserNameDigestField(host->hostSub.userName); // if (p) { // *p = 0; // Host *tmpHost = priorityHosts.GetHostByName(&host->hostSub); // if (tmpHost) { // priorityHosts.DelHost(tmpHost); // if (tmpHost->RefCnt() == 0) delete tmpHost; // } // *p = '-'; // } } priorityHosts.AddHost(host); } reg.CloseKey(); } reg.CloseKey(); if (rewriteFlg) WriteRegistry(CFG_HOSTINFO|CFG_DELHOST); } // Self private/public key (1024/2048) for (i=KEY_1024; i <= KEY_2048; i++) { const char *key = (i == KEY_1024) ? CRYPT_STR : CRYPT2_STR; int need_blob_size = ((i == KEY_1024) ? 1024 : 2048) / 8 * 4; if (reg.CreateKey(key)) { BYTE key[MAX_BUF_EX]; int blen = sizeof(key); int slen = sizeof(key); if (reg.GetByte(PRIVBLOB_STR, key, &blen) && blen > need_blob_size) { priv[i].SetBlob(key, blen); } if (reg.GetByte(PRIVSEED_STR, key, &slen)) { priv[i].SetSeed(key, slen); } reg.GetInt(PRIVTYPE_STR, &priv[i].encryptType); reg.CloseKey(); } } if (reg.OpenKey(DEBUG_STR)) // 旧バージョンレジストリ削除 { reg.CloseKey(); reg.DeleteChildTree(); } if (!reg.GetStr(NULL, buf, sizeof(buf)) || strcmp(buf, GetVersionStr())) { reg.CloseKey(); // close top appreg WriteRegistry(); } return TRUE; }
INT_PTR CALLBACK MsgBoxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { CDlgBoxEntry* pDlgBox = (CDlgBoxEntry*) ::GetWindowLong(hWnd, GWL_USERDATA); HWND hwndChild = 0; switch (message) { //case WM_THEMECHANGED: case WM_STYLECHANGED: case WM_STYLECHANGING: case WM_SYSCOLORCHANGE: case WM_SETTINGCHANGE: return FALSE; // SKIP it. case WM_CTLCOLORSTATIC: { if (pDlgBox && pDlgBox->m_hBackgroundBrush) { HWND hStatic = ::GetDlgItem(hWnd, pDlgBox->m_nMessageId); if (pDlgBox->m_crBackground == MESSAGE_BOX_VALUE_INVALID) ::SetBkColor((HDC)wParam, ::GetSysColor(COLOR_WINDOW)); else ::SetBkColor((HDC)wParam, pDlgBox->m_crBackground); if (pDlgBox->m_crText == MESSAGE_BOX_VALUE_INVALID) ::SetTextColor((HDC)wParam, ::GetSysColor(COLOR_WINDOWTEXT)); else ::SetTextColor((HDC)wParam, pDlgBox->m_crText); if (hStatic && (hStatic == (HWND)lParam)) return (LRESULT)pDlgBox->m_hBackgroundBrush; } return FALSE; } case WM_ERASEBKGND: { if (pDlgBox && pDlgBox->m_hBackgroundBrush) { HDC hdc = (HDC) wParam; CRectX rect; ::GetClientRect(hWnd, &rect); // first fill entire client area HBRUSH hBrush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE)); ::FillRect(hdc, &rect, hBrush); ::DeleteObject(hBrush); // next fill message background rect.bottom = pDlgBox->m_msgrect.bottom; if (pDlgBox->m_hBackgroundBrush) ::FillRect(hdc, &rect, pDlgBox->m_hBackgroundBrush); return TRUE; } return FALSE; } case WM_INITDIALOG: { ::SetWindowLong(hWnd, GWL_USERDATA, lParam); // save it for the others pDlgBox = (CDlgBoxEntry*) lParam; if(pDlgBox == NULL) return FALSE; HDC hdc = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL); if(hdc == NULL) return FALSE; ::SelectObject(hdc, pDlgBox->m_hFont); ::DeleteDC(hdc); UINT nID; hwndChild = ::GetDlgItem(hWnd, pDlgBox->m_nMessageId); if (::IsWindow(hwndChild)) ::SendMessage(hwndChild, WM_SETFONT, (WPARAM)pDlgBox->m_hFont, 0); for (nID = IDCUSTOM1; nID < IDCUSTOM4; nID++) { hwndChild = ::GetDlgItem(hWnd, nID); if (hwndChild && ::IsWindow(hwndChild)) { ::SendMessage(hwndChild, WM_SETFONT, (WPARAM)pDlgBox->m_hFont, 0); } } hwndChild = ::GetDlgItem(hWnd, IDCHECKBOX); if (hwndChild && ::IsWindow(hwndChild)) { ::SendMessage(hwndChild, WM_SETFONT, (WPARAM)pDlgBox->m_hFont, 0); CheckDlgButton(hWnd, IDCHECKBOX, pDlgBox->m_bNeedCheck); } hwndChild = ::GetDlgItem(hWnd, pDlgBox->m_nDefaultButtonId); if (hwndChild && ::IsWindow(hwndChild)) ::SetFocus(hwndChild); if (pDlgBox->m_hIcon) { HWND hwndIcon; hwndIcon = ::GetDlgItem(hWnd, 1000); ::SetWindowLong(hwndIcon, GWL_WNDPROC, (LONG) IconProc); ::SetWindowLong(hwndIcon, GWL_USERDATA, (LONG) pDlgBox->m_hIcon); } if (pDlgBox->m_nStyle & MB_TOPMOST) ::SetWindowPos(hWnd, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE); if (pDlgBox->m_nStyle & MB_SETFOREGROUND) ::SetForegroundWindow(hWnd); HWND hParent = ::GetParent(hWnd); if (pDlgBox->m_X || pDlgBox->m_Y) { // caller has specified screen coordinates CRectX dlgRect; ::GetWindowRect(hWnd, &dlgRect); ::MoveWindow(hWnd, pDlgBox->m_X, pDlgBox->m_Y, dlgRect.Width(), dlgRect.Height(), TRUE); } else if (hParent != NULL) { // code to center dialog CRectX mainRect, dlgRect, desktopRect; ::GetWindowRect(hWnd, &dlgRect); if (IsIconic(hParent)) { HWND hDesktop = ::GetDesktopWindow(); ::GetWindowRect(hDesktop, &mainRect); } else { ::GetWindowRect(hParent, &mainRect); } int x = (mainRect.right + mainRect.left)/2 - dlgRect.Width()/2; int y = (mainRect.bottom + mainRect.top) /2 - dlgRect.Height()/2; if(x < 0 || y < 0) { ::MoveWindow(hWnd, pDlgBox->m_X, pDlgBox->m_Y, dlgRect.Width(), dlgRect.Height(), TRUE); } else { ::MoveWindow(hWnd, x, y, dlgRect.Width(), dlgRect.Height(), TRUE); } } // display seconds countdown if timeout specified if (pDlgBox->m_nTimeoutSeconds > 0) ::SetTimer(hWnd, 1, 1000, NULL); ::SetForegroundWindow(hWnd); return FALSE; } // case WM_INITDIALOG case WM_COMMAND: { // user clicked on something - stop the timer ::KillTimer(hWnd, 1); if(pDlgBox == NULL) return FALSE; if (pDlgBox->m_nDefaultButtonId) { HWND hwndDefButton = ::GetDlgItem(hWnd, pDlgBox->m_nDefaultButtonId); if (hwndDefButton && ::IsWindow(hwndDefButton)) { if (pDlgBox->m_szDefaultButton[0] != _T('\0')) { ::SetWindowText(hwndDefButton, pDlgBox->m_szDefaultButton); } } } if( wParam == (pDlgBox->m_nDefaultButtonId | MB_TIMEOUT)) { pDlgBox->m_bShutdown = TRUE; pDlgBox->m_nReturnValue = wParam; hwndChild = ::GetDlgItem(hWnd, IDCHECKBOX); if (hwndChild && ::IsWindow(hwndChild)) { pDlgBox->m_nReturnValueCheckBox = IsDlgButtonChecked(hWnd, IDCHECKBOX); } return TRUE; } switch (wParam) { case IDCLOSE: { hwndChild = ::GetDlgItem(hWnd, IDCHECKBOX); if (hwndChild && ::IsWindow(hwndChild)) { pDlgBox->m_nReturnValueCheckBox = IsDlgButtonChecked(hWnd, IDCHECKBOX); } return TRUE; } case IDOK: { hwndChild = ::GetDlgItem(hWnd, IDCHECKBOX); if (hwndChild && ::IsWindow(hwndChild)) { pDlgBox->m_nReturnValueCheckBox = IsDlgButtonChecked(hWnd, IDCHECKBOX); } pDlgBox->m_bShutdown = TRUE; pDlgBox->m_nReturnValue = IDOK; } return FALSE; case IDCANCEL: { hwndChild = ::GetDlgItem(hWnd, IDCHECKBOX); if (hwndChild && ::IsWindow(hwndChild)) { pDlgBox->m_nReturnValueCheckBox = IsDlgButtonChecked(hWnd, IDCHECKBOX); } pDlgBox->m_bShutdown = TRUE; pDlgBox->m_nReturnValue = IDCANCEL; } return FALSE; case IDCUSTOM1: { hwndChild = ::GetDlgItem(hWnd, IDCHECKBOX); if (hwndChild && ::IsWindow(hwndChild)) { pDlgBox->m_nReturnValueCheckBox = ::IsDlgButtonChecked(hWnd, IDCHECKBOX); } pDlgBox->m_bShutdown = TRUE; pDlgBox->m_nReturnValue = IDCUSTOM1; } break; case IDCUSTOM2: { hwndChild = ::GetDlgItem(hWnd, IDCHECKBOX); if (hwndChild && ::IsWindow(hwndChild)) { pDlgBox->m_nReturnValueCheckBox = IsDlgButtonChecked(hWnd, IDCHECKBOX); } pDlgBox->m_bShutdown = TRUE; pDlgBox->m_nReturnValue = IDCUSTOM2; } break; case IDCUSTOM3: { hwndChild = ::GetDlgItem(hWnd, IDCHECKBOX); if (hwndChild && ::IsWindow(hwndChild)) { pDlgBox->m_nReturnValueCheckBox = IsDlgButtonChecked(hWnd, IDCHECKBOX); } pDlgBox->m_bShutdown = TRUE; pDlgBox->m_nReturnValue = IDCUSTOM3; } break; case IDCHECKBOX: if(pDlgBox->m_bCheckBox) { hwndChild = ::GetDlgItem(hWnd, IDCHECKBOX); BOOL bCheckBox = FALSE; if (hwndChild && ::IsWindow(hwndChild)) { bCheckBox = (BOOL)::SendMessage(hwndChild, BM_GETCHECK, 0, 0); } WriteRegistry(pDlgBox->m_szIdentifier,MAKELONG(IDCHECKBOX, bCheckBox)); pDlgBox->m_nReturnValueCheckBox = bCheckBox; } else { pDlgBox->m_nReturnValueCheckBox = FALSE; pDlgBox->m_bShutdown = TRUE; pDlgBox->m_nReturnValue = IDCUSTOM4; } break; default: break; } // switch (wParam) return FALSE; } // case WM_COMMAND case WM_LBUTTONDOWN: case WM_NCLBUTTONDOWN: { // user clicked on dialog or titlebar - stop the timer ::KillTimer(hWnd, 1); if (pDlgBox->m_nDefaultButtonId) { HWND hwndDefButton = ::GetDlgItem(hWnd, pDlgBox->m_nDefaultButtonId); if (hwndDefButton && ::IsWindow(hwndDefButton)) { if (pDlgBox->m_szDefaultButton[0] != _T('\0')) { ::SetWindowText(hwndDefButton, pDlgBox->m_szDefaultButton); } } } return FALSE; } case WM_TIMER: // used for timeout { if (wParam == 1) { // Timeout occur if (pDlgBox->m_nTimeoutSeconds <= 0) { ::KillTimer(hWnd, wParam); // time is up, select default button ::SendMessage(hWnd, WM_COMMAND, pDlgBox->m_nDefaultButtonId | MB_TIMEOUT, 0); return FALSE; } if (pDlgBox->m_nDefaultButtonId == 0) return FALSE; HWND hwndDefButton = ::GetDlgItem(hWnd, pDlgBox->m_nDefaultButtonId); if (hwndDefButton == NULL || !::IsWindow(hwndDefButton)) return FALSE; if (pDlgBox->m_szDefaultButton[0] == _T('\0')) { // first time - get text of default button ::GetWindowText(hwndDefButton, pDlgBox->m_szDefaultButton, DEFAULT_BUTTON_TXT_LEN); } TCHAR szButtonText[DEFAULT_BUTTON_TXT_LEN*2]; wsprintf(szButtonText, _T("%s = %d"), pDlgBox->m_szDefaultButton, pDlgBox->m_nTimeoutSeconds); ::SetWindowText(hwndDefButton, szButtonText); pDlgBox->m_nTimeoutSeconds--; } return FALSE; } } // switch (message) return FALSE; }
LRESULT CALLBACK SpyWndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch (msg) { case WM_CREATE: MyCreatePrintfWin(hwnd); return 0; case WM_INITMENU: if (GetMenu(ghwndSpyApp) == (HMENU)wParam) InitMenu((HMENU)wParam); break; case WM_COMMAND: return SpyCommand(hwnd, LOWORD(wParam), HIWORD(wParam)); case WM_ACTIVATE: /* * Set the focus to the printf window if we are being activated. */ if (LOWORD(wParam)) SetFocus(ghwndPrintf); break; case WM_SIZE: /* * Size the printf window to fit into the new client area size. */ MoveWindow(ghwndPrintf, -gcxBorder, -gcyBorder, LOWORD(lParam) + (2 * gcxBorder), HIWORD(lParam) + (2 * gcyBorder), TRUE); break; case WM_CLOSE: SetSpyHook(FALSE); #ifdef JAPAN // DBCS_FIX if (gfhCom1 != INVALID_HANDLE_VALUE) CloseHandle(gfhCom1); #endif if (gfhFile) _lclose(gfhFile); SendMessage(ghwndSpyHook, WM_CLOSE, 0, 0); WriteRegistry(); WaitForSingleObject(ghHookThread, INFINITE); DestroyWindow(ghwndSpyApp); break; case WM_DESTROY: PostQuitMessage(0); /* Kill the main window */ ghwndSpyApp = NULL; ghwndPrintf = NULL; break; case WM_EXECINSTANCE: /* * another instance of spy has been started. */ if (IsIconic(hwnd)) ShowWindow(hwnd,SW_SHOWNORMAL); SetForegroundWindow(hwnd); BringWindowToTop(hwnd); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
static void console_copyspaces_cb(Fl_Widget *widget, void* v) { ((console_window_t*)(((Fl_Menu_Item*)v)->user_data_))->get_widget()->toggle_copy_spaces(); WriteRegistry(REGISTRY_COPYSPACES, ((console_window_t*)(((Fl_Menu_Item*)v)->user_data_))->get_widget()->get_copy_spaces()); }
static void console_exitdetach_cb(Fl_Widget *widget, void* v) { console_window_t* cw_inst = (console_window_t*)(((Fl_Menu_Item*)v)->user_data_); cw_inst->toggle_exitdetach(); WriteRegistry(REGISTRY_EXITDETACH, cw_inst->get_exitdetach()); }