Ejemplo n.º 1
0
/*
	BrowseDlg用サブクラス生成
*/
BOOL TBrowseDirDlg::AttachWnd(HWND _hWnd)
{
	BOOL	ret = TSubClass::AttachWnd(_hWnd);
	dirtyFlg = FALSE;

// ディレクトリ設定
	DWORD	attr = GetFileAttributes(fileBuf);
	if (attr == 0xffffffff || (attr & FILE_ATTRIBUTE_DIRECTORY) == 0)
		GetParentDir(fileBuf, fileBuf);
	SendMessage(BFFM_SETSELECTION, TRUE, (LPARAM)fileBuf);
	SetWindowText(FASTCOPY);

// ボタン作成
	RECT	tmp_rect;
	::GetWindowRect(GetDlgItem(IDOK), &tmp_rect);
	POINT	pt = { tmp_rect.left, tmp_rect.top };
	::ScreenToClient(hWnd, &pt);
	int		cx = (pt.x - 30) / 2, cy = tmp_rect.bottom - tmp_rect.top;

	::CreateWindow(BUTTON_CLASS, GetLoadStr(IDS_MKDIR), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 10,
		pt.y, cx, cy, hWnd, (HMENU)MKDIR_BUTTON, TApp::GetInstance(), NULL);
	::CreateWindow(BUTTON_CLASS, GetLoadStr(IDS_RMDIR), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
		18 + cx, pt.y, cx, cy, hWnd, (HMENU)RMDIR_BUTTON, TApp::GetInstance(), NULL);

	HFONT	hDlgFont = (HFONT)SendDlgItemMessage(IDOK, WM_GETFONT, 0, 0L);
	if (hDlgFont) {
		SendDlgItemMessage(MKDIR_BUTTON, WM_SETFONT, (UINT)hDlgFont, 0L);
		SendDlgItemMessage(RMDIR_BUTTON, WM_SETFONT, (UINT)hDlgFont, 0L);
	}

	return	ret;
}
Ejemplo n.º 2
0
/*
	Window 生成時の CallBack
*/
BOOL TSetupDlg::EvCreate(LPARAM lParam)
{
	setup_list.AttachWnd(GetDlgItem(SETUP_LIST));

	for (int i=0; i < MAX_SETUP_SHEET; i++) {
		sheet[i].Create(SETUP_SHEET1 + i, cfg, this);
		setup_list.SendMessage(LB_ADDSTRING, 0, (LPARAM)GetLoadStr(IDS_SETUP_SHEET1 + i));
	}
	SetSheet();

	if (rect.left == CW_USEDEFAULT)
	{
		GetWindowRect(&rect);
		int xsize = rect.right - rect.left, ysize = rect.bottom - rect.top;
		int	cx = ::GetSystemMetrics(SM_CXFULLSCREEN), cy = ::GetSystemMetrics(SM_CYFULLSCREEN);
		int	x = (cx - xsize)/2;
		int y = (cy - ysize)/2;

		MoveWindow((x < 0) ? 0 : x % (cx - xsize), (y < 0) ? 0 : y % (cy - ysize),
			xsize, ysize, FALSE);
	}
	else
		MoveWindow(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, FALSE);

	return	TRUE;
}
Ejemplo n.º 3
0
void Cfg::GetRegName(char *buf, ULONG nic_addr, int port_no)
{
	buf += wsprintf(buf, "%s", GetLoadStr(IDS_IPMSG));
	if (port_no != IPMSG_DEFAULT_PORT)
		buf += wsprintf(buf, "%d", port_no);
	if (nic_addr)
		buf += wsprintf(buf, "_%s", inet_ntoa(*(in_addr *)&nic_addr));
}
Ejemplo n.º 4
0
BOOL TShellExtDlg::ReflectStatus(void)
{
	BOOL	isRegister = shellExt.IsRegisterDllProc();
	int		flags;

	SetDlgItemText(IDSHELLEXT_OK, isRegister ?
		GetLoadStr(IDS_SHELLEXT_MODIFY) : GetLoadStr(IDS_SHELLEXT_EXEC));
	::EnableWindow(GetDlgItem(IDSHELLEXT_CANCEL), isRegister);

	if ((flags = shellExt.GetMenuFlagsProc()) == -1) {
		flags = (SHEXT_RIGHT_COPY|SHEXT_RIGHT_DELETE|SHEXT_DD_COPY|SHEXT_DD_MOVE);
		// for old shellext
	}
	if ((flags & SHEXT_MENUFLG_EX) == 0) {	// old shellext
		::EnableWindow(GetDlgItem(RIGHT_PASTE_CHECK), FALSE);
	}

	if (flags & SHEXT_ISSTOREOPT) {
		cfg->shextNoConfirm		= (flags & SHEXT_NOCONFIRM) ? TRUE : FALSE;
		cfg->shextNoConfirmDel	= (flags & SHEXT_NOCONFIRMDEL) ? TRUE : FALSE;
		cfg->shextTaskTray		= (flags & SHEXT_TASKTRAY) ? TRUE : FALSE;
		cfg->shextAutoClose		= (flags & SHEXT_AUTOCLOSE) ? TRUE : FALSE;
	}

	CheckDlgButton(RIGHT_COPY_CHECK, flags & SHEXT_RIGHT_COPY);
	CheckDlgButton(RIGHT_DELETE_CHECK, flags & SHEXT_RIGHT_DELETE);
	CheckDlgButton(RIGHT_PASTE_CHECK, flags & SHEXT_RIGHT_PASTE);
	CheckDlgButton(RIGHT_SUBMENU_CHECK, flags & SHEXT_SUBMENU_RIGHT);
	CheckDlgButton(DD_COPY_CHECK, flags & SHEXT_DD_COPY);
	CheckDlgButton(DD_MOVE_CHECK, flags & SHEXT_DD_MOVE);
	CheckDlgButton(DD_SUBMENU_CHECK, flags & SHEXT_SUBMENU_DD);

	CheckDlgButton(NOCONFIRM_CHECK, cfg->shextNoConfirm);
	CheckDlgButton(NOCONFIRMDEL_CHECK, cfg->shextNoConfirmDel);
	CheckDlgButton(TASKTRAY_CHECK, cfg->shextTaskTray);
	CheckDlgButton(AUTOCLOSE_CHECK, cfg->shextAutoClose);

	if (!::IsUserAnAdmin()) {
		SetDlgItemText(SHELL_STATIC, GetLoadStr(IDS_SHELLEXT_NEEDADMIN));
		::EnableWindow(GetDlgItem(IDSHELLEXT_OK), FALSE);
		::EnableWindow(GetDlgItem(IDSHELLEXT_CANCEL), FALSE);
	}

	return	TRUE;
}
Ejemplo n.º 5
0
BOOL TSetupSheet::CheckData()
{
	char	buf[MAX_PATH_U8];
	int		val;

	if (resId == SETUP_SHEET3) {
		GetDlgItemTextU8(LRUUSER_EDIT, buf, sizeof(buf));
		if ((val = atoi(buf)) > MAX_LRUUSER || val < 0) {
			MessageBox(FmtStr(GetLoadStr(IDS_TOOMANYLRU), MAX_LRUUSER));
			return	FALSE;
		}
	}
	else if (resId == SETUP_SHEET4) {
		GetDlgItemTextU8(LOG_EDIT, buf, sizeof(buf));
		if (GetDriveType(NULL) == DRIVE_REMOTE
				&& !SendDlgItemMessage(LOG_CHECK, BM_GETCHECK, 0, 0) && strchr(buf, '\\')) {
			MessageBox(GetLoadStr(IDS_LOGALERT));
			return	FALSE;
		}
	}
	else if (resId == SETUP_SHEET5) {
		char	buf1[MAX_NAMEBUF], buf2[MAX_NAMEBUF], buf3[MAX_NAMEBUF];
		GetDlgItemTextU8(OLDPASSWORD_EDIT,  buf1, sizeof(buf1));
		GetDlgItemTextU8(NEWPASSWORD_EDIT,  buf2, sizeof(buf2));
		GetDlgItemTextU8(NEWPASSWORD_EDIT2, buf3, sizeof(buf3));

		if (strcmp(buf2, buf3) != 0) {
			MessageBoxU8(GetLoadStrU8(IDS_NOTSAMEPASS));
			return	FALSE;
		}

		if (!CheckPassword(cfg->PasswordStr, buf1)) {
			if (*buf1 || *buf2 || *buf3) {
				SetDlgItemTextU8(PASSWORD_EDIT, "");
				MessageBoxU8(GetLoadStrU8(IDS_CANTAUTH));
				return	FALSE;
			}
		}
	}

	return	TRUE;
}
Ejemplo n.º 6
0
Archivo: cfg.cpp Proyecto: glukki/ipmsg
void Cfg::GetRegName(char *buf, Addr nic_addr, int port_no)
{
	buf += sprintf(buf, "%s", GetLoadStr(IDS_IPMSG));
	if (port_no != IPMSG_DEFAULT_PORT) {
		buf += sprintf(buf, "%d", port_no);
	}
	if (nic_addr.IsEnabled()) {
		*buf++ = '_';
		nic_addr.ToStr(buf);
	}
}
Ejemplo n.º 7
0
TRecvDlg::TRecvDlg(MsgMng *_msgMng, MsgBuf *_msg, THosts *_hosts, Cfg *_cfg, LogMng *_logmng) : TListDlg(RECEIVE_DIALOG), editSub(_cfg, this)
{
	msgMng		= _msgMng;
	cfg			= _cfg;
	openFlg		= FALSE;
	logmng		= _logmng;
	hosts		= _hosts;
	hEditFont	= NULL;
	hHeadFont	= NULL;
	fileObj		= NULL;
	shareInfo	= NULL;
	timerID		= 0;
	retryCnt	= 0;
	cryptCapa	= 0;
	createCnt++;
	::GetLocalTime(&recvTime);

	memset(&orgFont, 0, sizeof(orgFont));
	msg.Init(_msg);

	MakeListString(cfg, &msg.hostSub, hosts, head);

	if (msg.command & IPMSG_FILEATTACHOPT)
	{
		char	*shareStr = msg.msgBuf + msg.exOffset;
		if ((shareInfo = DecodeShareMsg(shareStr)) != NULL)
		{
			fileObj = new RecvFileObj;
			memset(fileObj, 0, sizeof(RecvFileObj));
		}
	}

	status = TRUE;
	if (msg.command & IPMSG_ENCRYPTOPT) {
		if ((status = DecryptMsg()) == FALSE)
			msgMng->Send(&msg.hostSub, IPMSG_SENDMSG|IPMSG_NOLOGOPT, GetLoadStr(IDS_DECRYPTERR));
	}
/* msgmng.cpp で変換済み
	else if ((msg.command & IPMSG_UTF8OPT) == 0) {
		strncpyz(msg.msgBuf, AtoU8(msg.msgBuf), sizeof(msg.msgBuf));
	}
*/
	if (status) {
		if ((msg.command & IPMSG_PASSWORDOPT) == 0 || cfg->PasswdLogCheck == FALSE)
			logmng->WriteRecvMsg(&msg, hosts, shareInfo);

		hAccel = ::LoadAccelerators(TApp::GetInstance(), (LPCSTR)IPMSG_ACCEL);
	}
}
Ejemplo n.º 8
0
/*
	立ち上がっている IPMSG を終了
*/
int TUninstDlg::TerminateIPMsg()
{
	BOOL	existFlg = FALSE;

	::EnumWindows(TerminateIPMsgProc, (LPARAM)&existFlg);
	if (existFlg) {
		if (MessageBox(GetLoadStr(IDS_TERMINATE), "", MB_OKCANCEL) == IDCANCEL)
			return	1;
		::EnumWindows(TerminateIPMsgProc, NULL);
	}
	existFlg = FALSE;
	::EnumWindows(TerminateIPMsgProc, (LPARAM)&existFlg);

	return	!existFlg ? 0 : 2;
}
Ejemplo n.º 9
0
BOOL TShellExtDlg::EvCommand(WORD wNotifyCode, WORD wID, LPARAM hWndCtl)
{
	switch (wID)
	{
	case IDSHELLEXT_OK: case IDSHELLEXT_CANCEL:
		if (IsWinXP() && !::IsUserAnAdmin()) {
			TMsgBox(this).Exec(GetLoadStr(IDS_REQUIRE_ADMIN));
			return	TRUE;
		}
		if (RegisterShellExt(wID == IDSHELLEXT_OK ? TRUE : FALSE) == FALSE) {
			TMsgBox(this).Exec("ShellExt Error");
		}
		ReflectStatus();
		if (wID == IDSHELLEXT_OK)
			EndDialog(wID);
		return	TRUE;

	case IDOK: case IDCANCEL:
		EndDialog(wID);
		return	TRUE;
	}
	return	FALSE;
}
Ejemplo n.º 10
0
BOOL TUninstDlg::UnInstall(void)
{
// 現在、起動中の ipmsg を終了
	int		st = TerminateIPMsg();

	if (st == 1) return FALSE;
	if (st == 2) {
		if (!IsWinVista() || TIsUserAnAdmin() || !TIsEnableUAC()) {
			MessageBox(GetLoadStr(IDS_CANTTERMINATE), UNINSTALL_STR);
			return FALSE;
		}
		if (MessageBox(GetLoadStr(IDS_REQUIREADMIN_TERM), "",
						MB_OKCANCEL|MB_ICONINFORMATION) != IDOK) return FALSE;
		return	RunAsAdmin(hWnd);
	}

	if (!runasWnd && MessageBox(GetLoadStr(IDS_START), UNINSTALL_STR,
						MB_OKCANCEL|MB_ICONINFORMATION) != IDOK) return	FALSE;

// 公開鍵削除
	if (IsDlgButtonChecked(DELPUBKEY_CHECK)) {
		BOOL	need_admin = FALSE;
		char	contName[MAX_PATH_U8], userName[MAX_PATH_U8];
		DWORD	size = sizeof(userName);
		::GetUserName(userName, &size);

		::wsprintf(contName, "ipmsg.rsa2048.%s", userName);
		if (!DeleteKeySet(MS_ENHANCED_PROV, contName, CRYPT_MACHINE_KEYSET) ||
			!DeleteKeySet(MS_ENHANCED_PROV, contName, 0)) need_admin = TRUE;

		::wsprintf(contName, "ipmsg.rsa1024.%s", userName);
		if (!DeleteKeySet(MS_ENHANCED_PROV, contName, CRYPT_MACHINE_KEYSET) ||
			!DeleteKeySet(MS_ENHANCED_PROV, contName, 0)) need_admin = TRUE;

		::wsprintf(contName, "ipmsg.rsa512.%s", userName);
		if (!DeleteKeySet(MS_DEF_PROV, contName, CRYPT_MACHINE_KEYSET) ||
			!DeleteKeySet(MS_DEF_PROV, contName, 0)) need_admin = TRUE;

		if (need_admin) {
			if (IsWinVista() && !TIsUserAnAdmin() && TIsEnableUAC()) {
				if (MessageBox(GetLoadStr(IDS_REQUIREADMIN_PUBKEY), "",
					MB_OKCANCEL|MB_ICONINFORMATION) != IDOK) return FALSE;
				return	RunAsAdmin(hWnd);
			}
		}
	}

// スタートアップ&デスクトップから削除
	TRegistry	reg(HKEY_CURRENT_USER);
	if (reg.OpenKey(REGSTR_SHELLFOLDERS)) {
		char	buf[MAX_PATH_U8];
		char	*regStr[]	= { REGSTR_STARTUP, REGSTR_PROGRAMS, REGSTR_DESKTOP, NULL };

		for (int i=0; regStr[i]; i++) {
			if (reg.GetStr(regStr[i], buf, sizeof(buf))) {
				if (i == 0) RemoveSameLink(buf);
				::wsprintf(buf + strlen(buf), "\\%s", IPMSG_SHORTCUT_NAME);
				DeleteLink(buf);
			}
		}
		reg.CloseKey();
	}

// レジストリからユーザー設定情報を削除
	if (reg.ChangeApp(HSTOOLS_STR))
		reg.DeleteChildTree(GetLoadStr(IDS_REGIPMSG));

// レジストリからアプリケーション情報を削除
	char	setupDir[MAX_PATH_U8];		// セットアップディレクトリ情報を保存
	GetDlgItemTextU8(RESETUP_EDIT, setupDir, sizeof(setupDir));

	reg.ChangeTopKey(HKEY_LOCAL_MACHINE);
	if (reg.OpenKey(REGSTR_PATH_APPPATHS)) {
		if (reg.OpenKey(IPMSG_EXENAME)) {
			reg.GetStr(REGSTR_PATH, setupDir, sizeof(setupDir));
			reg.CloseKey();
		}
		reg.DeleteKey(IPMSG_EXENAME);
		reg.CloseKey();
	}

// レジストリからアンインストール情報を削除
	if (reg.OpenKey(REGSTR_PATH_UNINSTALL)) {
		reg.DeleteKey(IPMSG_NAME);
		reg.CloseKey();
	}

// 終了メッセージ
	MessageBox(GetLoadStr(IDS_UNINSTCOMPLETE));

// インストールディレクトリを開く
	if (GetDriveTypeEx(setupDir) != DRIVE_REMOTE)
		ShellExecuteU8(NULL, NULL, setupDir, 0, 0, SW_SHOW);

	::PostQuitMessage(0);
	return	TRUE;
}
Ejemplo n.º 11
0
BOOL TSetupSheet::EvCommand(WORD wNotifyCode, WORD wID, LPARAM hWndCtl)
{
	char	buf[MAX_PATH_U8] = "", buf2[MAX_PATH_U8] = "", protocol[MAX_LISTBUF] = "";
	int		i;
	UrlObj	*obj;

	if (resId == SETUP_SHEET1) {
		switch (wID) {
		case ADD_BUTTON:
			if (GetDlgItemText(BROADCAST_EDIT, buf, sizeof(buf)) <= 0) return TRUE;
			if (ResolveAddr(buf) == 0) return MessageBox(GetLoadStr(IDS_CANTRESOLVE)), TRUE;
			for (i=0;
				SendDlgItemMessage(BROADCAST_LIST, LB_GETTEXT, i, (LPARAM)buf2) != LB_ERR; i++) {
				if (stricmp(buf, buf2) == 0) return	TRUE;
			}
			SendDlgItemMessage(BROADCAST_LIST, LB_ADDSTRING, 0, (LPARAM)buf);
			SetDlgItemText(BROADCAST_EDIT, "");
			return	TRUE;

		case DEL_BUTTON:
			while ((int)SendDlgItemMessage(BROADCAST_LIST, LB_GETSELCOUNT, 0, 0) > 0)
			{
				if (SendDlgItemMessage(BROADCAST_LIST, LB_GETSELITEMS, 1, (LPARAM)&i) != 1)
					break;
				SendDlgItemMessage(BROADCAST_LIST, LB_GETTEXT, (WPARAM)i, (LPARAM)buf);
				SetDlgItemText(BROADCAST_EDIT, buf);
				if (SendDlgItemMessage(BROADCAST_LIST, LB_DELETESTRING,
										(WPARAM)i, (LPARAM)buf) == LB_ERR) break;
			}
			return	TRUE;
		}
	}
	else if (resId == SETUP_SHEET2) {
		switch (wID) {
		case MAINICON_BUTTON: case REVICON_BUTTON:
			OpenFileDlg(this).Exec(wID == MAINICON_BUTTON ? MAINICON_EDIT : REVICON_EDIT,
					GetLoadStrU8(IDS_OPENFILEICON), GetLoadStrAsFilterU8(IDS_OPENFILEICONFLTR));
			return	TRUE;
		}
	}
	else if (resId == SETUP_SHEET3) {
		switch (wID) {
		case SENDDETAIL_BUTTON:
			{
				TSortDlg(cfg, this).Exec();
				return	TRUE;
			}

		case SOUNDFILE_BUTTON:
			GetWindowsDirectoryU8(buf, sizeof(buf));
			strcat(buf, "\\Media");
			GetCurrentDirectoryU8(sizeof(buf2), buf2);
			OpenFileDlg(this).Exec(SOUND_EDIT, GetLoadStrU8(IDS_OPENFILESND),
									GetLoadStrAsFilterU8(IDS_OPENFILESNDFLTR), buf);
			SetCurrentDirectoryU8(buf2);
			return	TRUE;

		case SOUNDPLAY_BUTTON:
			if (GetDlgItemTextU8(SOUND_EDIT, buf, sizeof(buf)) > 0) {
				PlaySoundU8(buf, 0, SND_FILENAME|SND_ASYNC);
			}
			return	TRUE;
		}
	}
	else if (resId == SETUP_SHEET4) {
		switch (wID) {
		case LOGFILE_BUTTON:
			OpenFileDlg(this, OpenFileDlg::SAVE).Exec(LOG_EDIT, GetLoadStrU8(IDS_OPENFILELOG),
													GetLoadStrAsFilterU8(IDS_OPENFILELOGFLTR));
			return	TRUE;
		}
	}
	else if (resId == SETUP_SHEET6) {
		switch (wID) {
		case ADD_BUTTON:
			if ((i = (int)SendDlgItemMessage(URL_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR &&
				SendDlgItemMessage(URL_LIST, LB_GETTEXT, (WPARAM)i, (LPARAM)protocol) != LB_ERR &&
				(obj = SearchUrlObj(&tmpUrlList, protocol))) {
				wsprintf(buf, GetLoadStrU8(IDS_EXECPROGRAM), protocol);
				OpenFileDlg(this).Exec(URL_EDIT, buf, GetLoadStrAsFilterU8(IDS_OPENFILEPRGFLTR));
			}
			return	TRUE;

		case URL_LIST:
			if ((i = (int)SendDlgItemMessage(URL_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR &&
				SendDlgItemMessage(URL_LIST, LB_GETTEXT, (WPARAM)i, (LPARAM)protocol) != LB_ERR &&
				(obj = SearchUrlObj(&tmpUrlList, protocol))) {
				SetDlgItemTextU8(URL_EDIT, obj->program);
			}
			return	TRUE;
		}
	}

	return	FALSE;
}
Ejemplo n.º 12
0
BOOL TInstDlg::UnInstall(void)
{
	char	buf[MAX_PATH];
	char	setupDir[MAX_PATH] = "";

	::GetModuleFileName(NULL, setupDir, sizeof(setupDir));
	GetParentDir(setupDir, setupDir);
	BOOL	is_shext = FALSE;

	is_shext = ShellExtFunc(setupDir, CHECK_SHELLEXT);

	if (is_shext && IsWinVista() && !TIsUserAnAdmin()) {
		RunAsAdmin(TRUE);
		return	TRUE;
	}

	if (MessageBox(GetLoadStr(IDS_START), UNINSTALL_STR, MB_OKCANCEL|MB_ICONINFORMATION) != IDOK)
		return	FALSE;

// スタートメニュー&デスクトップから削除
	TRegistry	reg(HKEY_CURRENT_USER, BY_MBCS);
	if (reg.OpenKey(REGSTR_SHELLFOLDERS)) {
		char	*regStr[]	= { REGSTR_PROGRAMS, REGSTR_DESKTOP, NULL };

		for (int cnt=0; regStr[cnt] != NULL; cnt++) {
			if (reg.GetStr(regStr[cnt], buf, sizeof(buf))) {
				if (cnt == 0)
					RemoveSameLink(buf);
				::wsprintf(buf + strlen(buf), "\\%s", FASTCOPY_SHORTCUT);
				if (IS_WINNT_V) {
					Wstr	w_buf(buf, BY_MBCS);
					DeleteLinkV(w_buf.Buf());
				}
				else {
					DeleteLinkV(buf);
				}
			}
		}
		reg.CloseKey();
	}

	ShellExtFunc(setupDir, UNREGISTER_SHELLEXT);

#ifdef _WIN64
	if (IS_WINNT_V) {
#else
	if (IS_WINNT_V && TIsWow64()) {
#endif
		SHELLEXECUTEINFO	sei = { sizeof(sei) };
		char	arg[1024];

		sprintf(arg, "\"%s\\%s\",%s", setupDir, CURRENT_SHEXTDLL_EX, "DllUnregisterServer");
		sei.lpFile = "rundll32.exe";
		sei.lpParameters = arg;
		ShellExecuteEx(&sei);
	}

// レジストリからアンインストール情報を削除
	if (reg.OpenKey(REGSTR_PATH_UNINSTALL)) {
		if (reg.OpenKey(FASTCOPY)) {
			if (reg.GetStr(REGSTR_VAL_UNINSTALLER_COMMANDLINE, setupDir, sizeof(setupDir)))
				GetParentDir(setupDir, setupDir);
			reg.CloseKey();
		}
		reg.DeleteKey(FASTCOPY);
		reg.CloseKey();
	}

// 終了メッセージ
	MessageBox(is_shext ? GetLoadStr(IDS_UNINSTSHEXTFIN) : GetLoadStr(IDS_UNINSTFIN));

// インストールディレクトリを開く
	if (GetFileAttributes(setupDir) != 0xffffffff) {
		::ShellExecute(NULL, NULL, setupDir, 0, 0, SW_SHOW);
	}

// AppDataディレクトリを開く
	if (IsWinVista()) {
		WCHAR	wbuf[MAX_PATH] = L"", upath[MAX_PATH] = L"";
		WCHAR	fastcopy_dir[MAX_PATH] = L"", *fastcopy_dirname = NULL;
		Wstr	w_setup(setupDir);

		if (TIsVirtualizedDirV(w_setup.Buf())) {
			if (TSHGetSpecialFolderPathV(NULL, wbuf, CSIDL_APPDATA, FALSE)) {
				GetFullPathNameW(w_setup.Buf(), MAX_PATH, fastcopy_dir, &fastcopy_dirname);
				MakePathV(upath, wbuf, fastcopy_dirname);

				if (GetFileAttributesV(upath) != 0xffffffff) {
					::ShellExecuteW(NULL, NULL, upath, 0, 0, SW_SHOW);
				}
			}
		}
	}

	::PostQuitMessage(0);
	return	TRUE;
}


BOOL ReadLink(char *src, char *dest, char *arg=NULL)
{
	IShellLink		*shellLink;		// 実際は IShellLinkA or IShellLinkW
	IPersistFile	*persistFile;
	WCHAR			wbuf[MAX_PATH];
	BOOL			ret = FALSE;

	if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink,
			(void **)&shellLink))) {
		if (SUCCEEDED(shellLink->QueryInterface(IID_IPersistFile, (void **)&persistFile))) {
			AtoW(src, wbuf, MAX_PATH);
			if (SUCCEEDED(persistFile->Load(wbuf, STGM_READ))) {
				if (SUCCEEDED(shellLink->GetPath(dest, MAX_PATH, NULL, 0))) {
					if (arg) {
						shellLink->GetArguments(arg, MAX_PATH);
					}
					ret = TRUE;
				}
			}
			persistFile->Release();
		}
		shellLink->Release();
	}
	return	ret;
}
Ejemplo n.º 13
0
BOOL TInstDlg::Install(void)
{
	char	buf[MAX_PATH], setupDir[MAX_PATH], setupPath[MAX_PATH];
	BOOL	is_delay_copy = FALSE;
	int		len;

// インストールパス設定
	len = GetDlgItemText(FILE_EDIT, setupDir, sizeof(setupDir));
	if (GetChar(setupDir, len-1) == '\\') SetChar(setupDir, len-1, 0);
	Wstr	w_setup(setupDir);

	if (IsWinVista() && TIsVirtualizedDirV(w_setup.Buf())) {
		if (!TIsUserAnAdmin()) {
			return	RunAsAdmin(TRUE);
		}
		else if (cfg.runImme && cfg.setupDir && lstrcmpiV(w_setup.Buf(), cfg.setupDir)) {
			return	MessageBox(GetLoadStr(IDS_ADMINCHANGE)), FALSE;
		}
	}

	CreateDirectory(setupDir, NULL);
	DWORD	attr = GetFileAttributes(setupDir);

	if (attr == 0xffffffff || (attr & FILE_ATTRIBUTE_DIRECTORY) == 0)
		return	MessageBox(GetLoadStr(IDS_NOTCREATEDIR)), FALSE;
	MakePath(setupPath, setupDir, FASTCOPY_EXE);

	if (MessageBox(GetLoadStr(IDS_START), INSTALL_STR, MB_OKCANCEL|MB_ICONINFORMATION) != IDOK)
		return	FALSE;

// ファイルコピー
	if (cfg.mode == SETUP_MODE) {
		char	installPath[MAX_PATH], orgDir[MAX_PATH];

		::GetModuleFileName(NULL, orgDir, sizeof(orgDir));
		GetParentDir(orgDir, orgDir);

		for (int cnt=0; SetupFiles[cnt] != NULL; cnt++) {
			MakePath(buf, orgDir, SetupFiles[cnt]);
			MakePath(installPath, setupDir, SetupFiles[cnt]);

			if (MiniCopy(buf, installPath) || IsSameFile(buf, installPath))
				continue;

			if ((strcmp(SetupFiles[cnt], CURRENT_SHEXTDLL_EX) == 0 ||
				 strcmp(SetupFiles[cnt], CURRENT_SHEXTDLL) == 0) && DelayCopy(buf, installPath)) {
				is_delay_copy = TRUE;
				continue;
			}
			return	MessageBox(installPath, GetLoadStr(IDS_NOTCREATEFILE)), FALSE;
		}
	}

// スタートメニュー&デスクトップに登録
	char	*linkPath[]	= { toA(cfg.startMenu, TRUE), toA(cfg.deskTop, TRUE), NULL };
	BOOL	execFlg[]	= { cfg.programLink,          cfg.desktopLink,        NULL };

	for (int cnt=0; linkPath[cnt]; cnt++) {
		strcpy(buf, linkPath[cnt]);
		if (cnt != 0 || RemoveSameLink(linkPath[cnt], buf) == FALSE) {
			::wsprintf(buf + strlen(buf), "\\%s", FASTCOPY_SHORTCUT);
		}
		if (execFlg[cnt]) {
			if (IS_WINNT_V) {
				Wstr	w_setup(setupPath, BY_MBCS);
				Wstr	w_buf(buf, BY_MBCS);
				SymLinkV(w_setup.Buf(), w_buf.Buf());
			}
			else {
				SymLinkV(setupPath, buf);
			}
		}
		else {
			if (IS_WINNT_V) {
				Wstr	w_buf(buf, BY_MBCS);
				DeleteLinkV(w_buf.Buf());
			}
			else {
				DeleteLinkV(buf);
			}
		}
	}

#if 0
// レジストリにアンインストール情報を登録
	if (reg.OpenKey(REGSTR_PATH_UNINSTALL)) {
		if (reg.CreateKey(FASTCOPY)) {
			MakePath(buf, setupDir, INSTALL_EXE);
			strcat(buf, " /r");
			reg.SetStr(REGSTR_VAL_UNINSTALLER_DISPLAYNAME, FASTCOPY);
			reg.SetStr(REGSTR_VAL_UNINSTALLER_COMMANDLINE, buf);
			reg.CloseKey();
		}
		reg.CloseKey();
	}
#endif

	if (IsWinVista() && TIsVirtualizedDirV(w_setup.Buf())) {
		WCHAR	wbuf[MAX_PATH] = L"", old_path[MAX_PATH] = L"", usr_path[MAX_PATH] = L"";
		WCHAR	fastcopy_dir[MAX_PATH], *fastcopy_dirname = NULL;

		GetFullPathNameW(w_setup.Buf(), MAX_PATH, fastcopy_dir, &fastcopy_dirname);

		if (cfg.appData) {
			strcpyV(usr_path, cfg.appData);
		}
		else {
			TSHGetSpecialFolderPathV(NULL, wbuf, CSIDL_APPDATA, FALSE);
			MakePathV(usr_path, wbuf, fastcopy_dirname);
		}

		ConvertVirtualStoreConf(w_setup.Buf(), usr_path, cfg.virtualDir);
	}

// コピーしたアプリケーションを起動
	const char *msg = GetLoadStr(is_delay_copy ? IDS_DELAYSETUPCOMPLETE : IDS_SETUPCOMPLETE);
	int			flg = MB_OKCANCEL|MB_ICONINFORMATION;

	if (IsWin7()) {
		msg = Fmt("%s%s", msg, GetLoadStr(IDS_COMPLETE_WIN7));
	}

	TLaunchDlg	dlg(msg, this);
	UINT		id;

	if ((id = dlg.Exec()) == IDOK || id == LAUNCH_BUTTON) {
		char	*arg = (id == LAUNCH_BUTTON) ? "/install" : "";
		ShellExecute(NULL, "open", setupPath, arg, setupDir, SW_SHOW);
	}

	::PostQuitMessage(0);
	return	TRUE;
}
Ejemplo n.º 14
0
BOOL TInstDlg::Install(void)
{
	char	buf[MAX_PATH_U8], setupDir[MAX_PATH_U8], setupPath[MAX_PATH_U8];
	char	installPath[MAX_PATH_U8];
	BOOL	extract_only = IsDlgButtonChecked(EXTRACT_CHECK);

// 現在、起動中の ipmsg を終了
	int		st = extract_only ? 0 : TerminateIPMsg();
	if (st == 1) return	FALSE;

// インストールパス設定
	GetDlgItemTextU8(FILE_EDIT, setupDir, sizeof(setupDir));

	if (IsWinVista() && !::IsUserAnAdmin() && TIsEnableUAC()
			&& TIsVirtualizedDirW(U8toWs(setupDir))) {
		if (MessageBox(GetLoadStr(IDS_REQUIREADMIN), INSTALL_STR,
				MB_OKCANCEL|MB_ICONINFORMATION) != IDOK) return	FALSE;
		return	RunAsAdmin(hWnd, TRUE);
	}

	CreateDirectoryU8(setupDir, NULL);
	DWORD	attr = GetFileAttributesU8(setupDir);
	if (attr == 0xffffffff || (attr & FILE_ATTRIBUTE_DIRECTORY) == 0)
		return	MessageBox(GetLoadStr(IDS_NOTCREATEDIR), INSTALL_STR), FALSE;
	MakePath(setupPath, setupDir, IPMSG_EXENAME);

	if (st == 2) {
		MessageBox(GetLoadStr(IDS_CANTTERMINATE), INSTALL_STR);
		return	FALSE;
	}
	if (!runasImm &&
		MessageBox(GetLoadStr(IDS_START), INSTALL_STR, MB_OKCANCEL|MB_ICONINFORMATION) != IDOK) {
		return	FALSE;
	}
	runasImm = FALSE;

// ファイル生成
	for (int i=0; SetupFiles[i]; i++) {
		MakePath(installPath, setupDir, SetupFiles[i]);
		CreateStatus cs = CreateFileBySelf(installPath, SetupFiles[i]);
		if (cs == CS_BROKEN) {
			MessageBox(GetLoadStr(IDS_BROKENARCHIVE), INSTALL_STR);
			return	FALSE;
		}
		else if (cs == CS_ACCESS) {
			const char *msg = Fmt("%s\r\n%s", GetLoadStrU8(IDS_NOTCREATEFILE), installPath);
			MessageBoxU8(msg, INSTALL_STR);
			return	FALSE;
		}
	}

// 展開のみ
	if (extract_only) {
		ShellExecuteW(NULL, NULL, U8toWs(setupDir), 0, 0, SW_SHOW);
		return TRUE;
	}

// スタートアップ&デスクトップに登録
	TRegistry	reg(HKEY_CURRENT_USER);
	if (reg.OpenKey(REGSTR_SHELLFOLDERS)) {
		char	*regStr[] = { REGSTR_STARTUP, REGSTR_PROGRAMS, REGSTR_DESKTOP, NULL };
		BOOL	resId[]   = { STARTUP_CHECK,  PROGRAM_CHECK,   DESKTOP_CHECK,  NULL };

		for (int i=0; regStr[i]; i++) {
			if (reg.GetStr(regStr[i], buf, sizeof(buf))) {
				if (i != 0 || !RemoveSameLink(buf, buf))
					::wsprintf(buf + strlen(buf), "\\%s", IPMSG_SHORTCUT_NAME);
				if (IsDlgButtonChecked(resId[i]))
					SymLink(setupPath, buf);
				else
					DeleteLink(buf);
			}
		}
		reg.CloseKey();
	}

// レジストリにアプリケーション情報を登録
	reg.ChangeTopKey(HKEY_LOCAL_MACHINE);
	if (reg.OpenKey(REGSTR_PATH_APPPATHS)) {
		if (reg.CreateKey(IPMSG_EXENAME)) {
			reg.SetStr(NULL, setupPath);
			reg.SetStr(REGSTR_PATH, setupDir);
			reg.CloseKey();
		}
		reg.CloseKey();
	}

// レジストリにアンインストール情報を登録
	if (reg.OpenKey(REGSTR_PATH_UNINSTALL)) {
		if (reg.CreateKey(IPMSG_NAME)) {
			MakePath(buf, setupDir, SETUP_EXENAME);
			strcat(buf, " /r");
			reg.SetStr(REGSTR_VAL_UNINSTALLER_DISPLAYNAME, IPMSG_FULLNAME);
			reg.SetStr(REGSTR_VAL_UNINSTALLER_COMMANDLINE, buf);
			reg.CloseKey();
		}
		reg.CloseKey();
	}

// コピーしたアプリケーションを起動
	const char *msg = GetLoadStr(IDS_SETUPCOMPLETE);
	int			flg = MB_OKCANCEL|MB_ICONINFORMATION;

//	if (IsWinVista() && ::IsUserAnAdmin() && TIsEnableUAC()) {
//		msg = Fmt("%s%s", msg, GetLoadStr(IDS_COMPLETE_UACADD));
//		flg |= MB_DEFBUTTON2;
//	}
	TLaunchDlg	dlg(msg, this);
	if (dlg.Exec() == IDOK) {
		if (runasWnd) {
			Wstr	wbuf(setupDir);
			if (::SendDlgItemMessageW(runasWnd, FILE_EDIT, WM_SETTEXT, 0, (LPARAM)wbuf.Buf())) {
				::PostMessage(runasWnd, WM_IPMSG_QUIT, 1, 0);
				runasWnd = NULL;
			}
		}
		else {
			AppKick();
		}
	}
	else {
		HWND	hHelp = ShowHelpU8(0, setupDir, GetLoadStrU8(IDS_IPMSGHELP), "#history");
		if (hHelp) {
			Show(SW_HIDE);
			while (::IsWindow(hHelp)) {
				this->Sleep(100);
			}
		}
	}

	if (runasWnd) {
		::PostMessage(runasWnd, WM_IPMSG_QUIT, 0, 0);
		runasWnd = NULL;
	}

//	ShellExecuteU8(NULL, NULL, setupDir, 0, 0, SW_SHOW);
	::PostQuitMessage(0);
	return	TRUE;
}
Ejemplo n.º 15
0
BOOL TSetupSheet::CheckData()
{
	if (resId == MAIN_SHEET) {
		if (GetDlgItemInt(BUFSIZE_EDIT) <
			setupDlg->GetSheet(IO_SHEET)->GetDlgItemInt(MAXTRANS_EDIT) * BUFIO_SIZERATIO) {
			MessageBox(GetLoadStr(IDS_SMALLBUF_SETERR));
			return	FALSE;
		}
		return	TRUE;
	}
	else if (resId == IO_SHEET) {
		if (GetDlgItemInt(MAXTRANS_EDIT) <= 0 || GetDlgItemInt(MAXOVL_EDIT) <= 0) {
			MessageBox(GetLoadStr(IDS_SMALLVAL_SETERR));
			return	FALSE;
		}
		if (GetDlgItemInt(MAXTRANS_EDIT) % GetDlgItemInt(MAXOVL_EDIT)) {
			MessageBox(GetLoadStr(IDS_MAXOVL_SETERR));
			return	FALSE;
		}
		if (GetDlgItemInt(MAXTRANS_EDIT) * BUFIO_SIZERATIO >
			setupDlg->GetSheet(MAIN_SHEET)->GetDlgItemInt(BUFSIZE_EDIT)) {
			MessageBox(GetLoadStr(IDS_BIGIO_SETERR));
			return	FALSE;
		}
		return	TRUE;
	}
	else if (resId == PHYSDRV_SHEET) {
		char	c, last_c = 0, buf[sizeof(cfg->driveMap)];
		GetDlgItemText(DRIVEMAP_EDIT, buf, sizeof(buf));
		for (int i=0; i < sizeof(buf) && (c = buf[i]); i++) {
			if (c >= 'a' && c <= 'z') buf[i] = c = toupper(c);
			if ((c < 'A' || c > 'Z' || strchr(buf+i+1, c)) && c != ',' || c == last_c) {
				MessageBox(GetLoadStr(IDS_DRVGROUP_SETERR));
				return	FALSE;
			}
			last_c = c;
		}
		return	TRUE;
	}
	else if (resId == PARALLEL_SHEET) {
		if (GetDlgItemInt(MAXRUN_EDIT) <= 0) {
			MessageBox(GetLoadStr(IDS_SMALLVAL_SETERR));
			return	FALSE;
		}
		return	TRUE;
	}
	else if (resId == COPYOPT_SHEET) {
		return	TRUE;
	}
	else if (resId == DEL_SHEET) {
		return	TRUE;
	}
	else if (resId == LOG_SHEET) {
		return	TRUE;
	}
	else if (resId == MISC_SHEET) {
		return	TRUE;
	}

	return	TRUE;
}
Ejemplo n.º 16
0
BOOL TSetupSheet::SetData()
{
	if (resId == SETUP_SHEET1) {
		SetDlgItemTextU8(GROUP_COMBO, cfg->GroupNameStr);
		SetDlgItemTextU8(NICKNAME_EDIT, cfg->NickNameStr);

		CheckDlgButton(CLIPMODE_CHECK, (cfg->ClipMode & CLIP_ENABLE));
		CheckDlgButton(CLIPCONFIRM_CHECK, (cfg->ClipMode & CLIP_CONFIRM) ? 1 : 0);

		for (TBrObj *obj=cfg->brList.Top(); obj; obj=cfg->brList.Next(obj))
			SendDlgItemMessage(BROADCAST_LIST, LB_ADDSTRING, 0, (LPARAM)obj->Host());

		for (int i=0; i < hosts->HostCnt(); i++) {
			Host	*host = hosts->GetHost(i);

			if (*host->groupName) {
				Wstr	group_w(host->groupName, BY_UTF8);
				if (SendDlgItemMessageW(GROUP_COMBO, CB_FINDSTRING,
						(WPARAM)-1, (LPARAM)group_w.Buf()) == CB_ERR) {
					SendDlgItemMessageW(GROUP_COMBO, CB_ADDSTRING,
							(WPARAM)0, (LPARAM)group_w.Buf());
				}
			}
		}
		CheckDlgButton(DIALUP_CHECK, cfg->DialUpCheck);
	}
	else if (resId == SETUP_SHEET2) {
		CheckDlgButton(BALLOONNOTIFY_CHECK, cfg->BalloonNotify);

		SendDlgItemMessage(OPEN_COMBO, CB_ADDSTRING, 0, (LPARAM)GetLoadStr(IDS_OPENCHECK_NONE));
		SendDlgItemMessage(OPEN_COMBO, CB_ADDSTRING, 0, (LPARAM)GetLoadStr(IDS_OPENCHECK_BALLOON));
		SendDlgItemMessage(OPEN_COMBO, CB_ADDSTRING, 0, (LPARAM)GetLoadStr(IDS_OPENCHECK_DLG));
		SendDlgItemMessage(OPEN_COMBO, CB_ADDSTRING, 0, (LPARAM)GetLoadStr(IDS_OPENCHECK_ICON));
		SendDlgItemMessage(OPEN_COMBO, CB_SETCURSEL, cfg->OpenCheck, 0);
//		CheckDlgButton(OPEN_CHECK, cfg->OpenCheck);

		SetDlgItemTextU8(QUOTE_EDIT, cfg->QuoteStr);

		CheckDlgButton(HOTKEY_CHECK, cfg->HotKeyCheck);
		CheckDlgButton(ABNORMALBTN_CHECK, cfg->AbnormalButton);

		if (cfg->lcid != -1 || GetSystemDefaultLCID() == 0x411) {
			::ShowWindow(GetDlgItem(LCID_CHECK), SW_SHOW);
			::EnableWindow(GetDlgItem(LCID_CHECK), TRUE);
			CheckDlgButton(LCID_CHECK, cfg->lcid == -1 || cfg->lcid == 0x411 ? FALSE : TRUE);
		}

		SendDlgItemMessage(EXTBROADCAST_COMBO, CB_ADDSTRING, 0, (LPARAM)GetLoadStr(IDS_LIMITED));
		SendDlgItemMessage(EXTBROADCAST_COMBO, CB_ADDSTRING, 0, (LPARAM)GetLoadStr(IDS_DIRECTED));
		SendDlgItemMessage(EXTBROADCAST_COMBO, CB_ADDSTRING, 0, (LPARAM)GetLoadStr(IDS_BOTH));
		SendDlgItemMessage(EXTBROADCAST_COMBO, CB_SETCURSEL, cfg->ExtendBroadcast, 0);

		SetDlgItemTextU8(MAINICON_EDIT, cfg->IconFile);
		SetDlgItemTextU8(REVICON_EDIT, cfg->RevIconFile);
	}
	else if (resId == SETUP_SHEET3) {
		CheckDlgButton(QUOTE_CHECK, cfg->QuoteCheck);
		CheckDlgButton(SECRET_CHECK, cfg->SecretCheck);
		CheckDlgButton(ONECLICK_CHECK, cfg->OneClickPopup);
		SetDlgItemTextU8(LRUUSER_EDIT, FmtStr("%d", cfg->lruUserMax));
		// ControlIME ... 0:off, 1:senddlg on (finddlg:off), 2:always on
		CheckDlgButton(CONTROLIME_CHECK, cfg->ControlIME ? 1 : 0);
		CheckDlgButton(FINDDLGIME_CHECK, cfg->ControlIME >= 2 ? 0 : 1);

		CheckDlgButton(NOPOPUP_CHECK, cfg->NoPopupCheck);
		CheckDlgButton(ABSENCENONPOPUP_CHECK, cfg->AbsenceNonPopup);
		CheckDlgButton(NOBEEP_CHECK, cfg->NoBeep);
		CheckDlgButton(RECVLOGON_CHECK, cfg->RecvLogonDisp);
		CheckDlgButton(RECVIPADDR_CHECK, cfg->RecvIPAddr);
		CheckDlgButton(NOERASE_CHECK, cfg->NoErase);

		SetDlgItemTextU8(SOUND_EDIT, cfg->SoundFile);
	}
	else if (resId == SETUP_SHEET4) {
		CheckDlgButton(LOG_CHECK, cfg->LogCheck);
		CheckDlgButton(LOGONLOG_CHECK, cfg->LogonLog);
		CheckDlgButton(IPADDR_CHECK, cfg->IPAddrCheck);
		CheckDlgButton(IMAGESAVE_CHECK, (cfg->ClipMode & 2) ? 1 : 0);
		CheckDlgButton(LOGUTF8_CHECK, cfg->LogUTF8);
		CheckDlgButton(PASSWDLOG_CHECK, cfg->PasswdLogCheck);
		SetDlgItemTextU8(LOG_EDIT, cfg->LogFile);
	}
	else if (resId == SETUP_SHEET5) {
		if (*cfg->PasswordStr == 0)
			::EnableWindow(GetDlgItem(OLDPASSWORD_EDIT), FALSE);
	}
	else if (resId == SETUP_SHEET6) {
		CheckDlgButton(DEFAULTURL_CHECK, cfg->DefaultUrl);

		for (UrlObj *obj = (UrlObj *)cfg->urlList.TopObj(); obj;
					 obj = (UrlObj *)cfg->urlList.NextObj(obj)) {
			UrlObj *tmp_obj = new UrlObj;
			strcpy(tmp_obj->protocol, obj->protocol);
			strcpy(tmp_obj->program, obj->program);
			tmpUrlList.AddObj(tmp_obj);
			SendDlgItemMessage(URL_LIST, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)obj->protocol);
		}
		CheckDlgButton(SHELLEXEC_CHECK, cfg->ShellExec);
		SendDlgItemMessage(URL_LIST, LB_SETCURSEL, curIdx >= 0 ? curIdx : 0, 0);
		PostMessage(WM_COMMAND, URL_LIST, 0);
	}
	return	TRUE;
}
Ejemplo n.º 17
0
BOOL TSetupSheet::SetData()
{
	if (resId == MAIN_SHEET) {
		if (sv) {
			sv->bufSize			= cfg->bufSize;
			sv->estimateMode	= cfg->estimateMode;
			sv->ignoreErr		= cfg->ignoreErr;
			sv->enableVerify	= cfg->enableVerify;
			sv->enableAcl		= cfg->enableAcl;
			sv->enableStream	= cfg->enableStream;
			sv->speedLevel		= cfg->speedLevel;
			sv->isExtendFilter	= cfg->isExtendFilter;
			sv->enableOwdel		= cfg->enableOwdel;
		}
		SetDlgItemInt(BUFSIZE_EDIT, cfg->bufSize);
		CheckDlgButton(ESTIMATE_CHECK, cfg->estimateMode);
		CheckDlgButton(IGNORE_CHECK, cfg->ignoreErr);
		CheckDlgButton(VERIFY_CHECK, cfg->enableVerify);
		CheckDlgButton(ACL_CHECK, cfg->enableAcl);
		CheckDlgButton(STREAM_CHECK, cfg->enableStream);
		SendDlgItemMessage(SPEED_SLIDER, TBM_SETRANGE, 0, MAKELONG(SPEED_SUSPEND, SPEED_FULL));
		SetSpeedLevelLabel(this, cfg->speedLevel);
		CheckDlgButton(EXTENDFILTER_CHECK, cfg->isExtendFilter);
		CheckDlgButton(OWDEL_CHECK, cfg->enableOwdel);
	}
	else if (resId == IO_SHEET) {
		SetDlgItemInt(MAXTRANS_EDIT, cfg->maxTransSize);
		SetDlgItemInt(MAXOVL_EDIT, cfg->maxOvlNum);
		CheckDlgButton(READOSBUF_CHECK, cfg->isReadOsBuf);
		SetDlgItemInt(NONBUFMINNTFS_EDIT, cfg->nbMinSizeNtfs);
		SetDlgItemInt(NONBUFMINFAT_EDIT, cfg->nbMinSizeFat);
	}
	else if (resId == PHYSDRV_SHEET) {
		SetDlgItemText(DRIVEMAP_EDIT, cfg->driveMap);
		SendDlgItemMessage(NETDRVMODE_COMBO, CB_ADDSTRING, 0, (LPARAM)GetLoadStr(IDS_NETDRV_UNC));
		SendDlgItemMessage(NETDRVMODE_COMBO, CB_ADDSTRING, 0, (LPARAM)GetLoadStr(IDS_NETDRV_SVR));
		SendDlgItemMessage(NETDRVMODE_COMBO, CB_ADDSTRING, 0, (LPARAM)GetLoadStr(IDS_NETDRV_ALL));
		SendDlgItemMessage(NETDRVMODE_COMBO, CB_SETCURSEL, cfg->netDrvMode, 0);
	}
	else if (resId == PARALLEL_SHEET) {
		SetDlgItemInt(MAXRUN_EDIT, cfg->maxRunNum);
		CheckDlgButton(FORCESTART_CHECK, cfg->forceStart);
	}
	else if (resId == COPYOPT_SHEET) {
		CheckDlgButton(SAMEDIR_RENAME_CHECK, cfg->isSameDirRename);
		CheckDlgButton(EMPTYDIR_CHECK, cfg->skipEmptyDir);
		CheckDlgButton(REPARSE_CHECK, cfg->isReparse);
		::EnableWindow(GetDlgItem(REPARSE_CHECK), TRUE);
		CheckDlgButton(MOVEATTR_CHECK, cfg->enableMoveAttr);
		CheckDlgButton(SERIALMOVE_CHECK, cfg->serialMove);
		CheckDlgButton(SERIALVERIFYMOVE_CHECK, cfg->serialVerifyMove);
		SetDlgItemInt(TIMEGRACE_EDIT, cfg->timeDiffGrace);
	}
	else if (resId == DEL_SHEET) {
		CheckDlgButton(NSA_CHECK, cfg->enableNSA);
		CheckDlgButton(DELDIR_CHECK, cfg->delDirWithFilter);
	}
	else if (resId == LOG_SHEET) {
		SetDlgItemInt(HISTORY_EDIT, cfg->maxHistoryNext);
		CheckDlgButton(ERRLOG_CHECK, cfg->isErrLog);
		CheckDlgButton(UTF8LOG_CHECK, cfg->isUtf8Log);
		::EnableWindow(GetDlgItem(UTF8LOG_CHECK), TRUE);
		CheckDlgButton(FILELOG_CHECK, cfg->fileLogMode);
		CheckDlgButton(TIMESTAMP_CHECK, (cfg->fileLogFlags & FastCopy::FILELOG_TIMESTAMP) ?
			TRUE : FALSE);
		CheckDlgButton(FILESIZE_CHECK,  (cfg->fileLogFlags & FastCopy::FILELOG_FILESIZE)  ?
			TRUE : FALSE);
		CheckDlgButton(ACLERRLOG_CHECK, cfg->aclErrLog);
		::EnableWindow(GetDlgItem(ACLERRLOG_CHECK), TRUE);
		CheckDlgButton(STREAMERRLOG_CHECK, cfg->streamErrLog);
		::EnableWindow(GetDlgItem(STREAMERRLOG_CHECK), TRUE);
	}
	else if (resId == MISC_SHEET) {
		CheckDlgButton(EXECCONFIRM_CHECK, cfg->execConfirm);
		CheckDlgButton(TASKBAR_CHECK, cfg->taskbarMode);
		CheckDlgButton(SPAN1_RADIO + cfg->infoSpan, 1);

		if ((cfg->lcid != -1 || GetSystemDefaultLCID() == 0x411)) {
			::ShowWindow(GetDlgItem(LCID_CHECK), SW_SHOW);
			::EnableWindow(GetDlgItem(LCID_CHECK), TRUE);
			CheckDlgButton(LCID_CHECK, cfg->lcid == -1 || cfg->lcid == 0x411 ? FALSE : TRUE);
		}
	}
	return	TRUE;
}
Ejemplo n.º 18
0
Archivo: cfg.cpp Proyecto: glukki/ipmsg
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(&reg, SENDEDITFONT_STR, &SendEditFont);
		ReadFontRegistry(&reg, SENDLISTFONT_STR, &SendListFont);
		ReadFontRegistry(&reg, RECVHEADFONT_STR, &RecvHeadFont);
		ReadFontRegistry(&reg, RECVEDITFONT_STR, &RecvEditFont);
		ReadFontRegistry(&reg, 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;
}