Exemplo n.º 1
0
HWND ShowHelpW(HWND hOwner, WCHAR *help_dir, WCHAR *help_file, WCHAR *section)
{
	if (NULL != strstr(WtoA(help_file), "http"))
	{
		//从help_file中发现“http”字符,打开URL
		//Found "http" in help_file string, open web URL.
		WCHAR	path[MAX_PATH];

		MakePathW(path, L"", help_file);
		if (section)
			wcscpy(path + wcslen(path), section);
		::ShellExecuteW(NULL, NULL, path, NULL, NULL, SW_SHOW);
		return	NULL;
	}
	else
	{
		//从help_file中未发现“http”字符,打开chm
		//Not found "http" in help_file string, open chm file.
#if defined(ENABLE_HTML_HELP)
		if (!pHtmlHelpW) InitHtmlHelp();

		if (pHtmlHelpW) {
			WCHAR	path[MAX_PATH];

			MakePathW(path, help_dir, help_file);
			if (section)
				wcscpy(path + wcslen(path), section);
			return	pHtmlHelpW(hOwner, path, HH_HELP_FINDER, 0);
		}
#endif
		return	NULL;
	}
}
Exemplo n.º 2
0
BOOL ConvertVirtualStoreConf(WCHAR *execDir, WCHAR *userDir, WCHAR *virtualDir)
{
#define FASTCOPY_INI_W			L"FastCopy.ini"
	WCHAR	buf[MAX_PATH];
	WCHAR	org_ini[MAX_PATH], usr_ini[MAX_PATH], vs_ini[MAX_PATH];
	BOOL	is_admin = ::IsUserAnAdmin();
	BOOL	is_exists;

	MakePathW(usr_ini, userDir, FASTCOPY_INI_W);
	MakePathW(org_ini, execDir, FASTCOPY_INI_W);

#ifdef _WIN64
	ConvertToX86Dir(org_ini);
#endif

	is_exists = ::GetFileAttributesW(usr_ini) != 0xffffffff;
	 if (!is_exists) {
		::CreateDirectoryW(userDir, NULL);
	}

	if (virtualDir && virtualDir[0]) {
		MakePathW(vs_ini,  virtualDir, FASTCOPY_INI_W);
		if (::GetFileAttributesW(vs_ini) != 0xffffffff) {
			if (!is_exists) {
				is_exists = ::CopyFileW(vs_ini, usr_ini, TRUE);
			}
			MakePathW(buf, userDir, L"to_OldDir(VirtualStore).lnk");
			SymLinkW(virtualDir, buf);
			swprintf(buf, L"%s.obsolete", vs_ini);
			::MoveFileW(vs_ini, buf);
			if (::GetFileAttributesW(vs_ini) != 0xffffffff) {
				::DeleteFileW(vs_ini);
			}
		}
	}

	if ((is_admin || !is_exists) && ::GetFileAttributesW(org_ini) != 0xffffffff) {
		if (!is_exists) {
			is_exists = ::CopyFileW(org_ini, usr_ini, TRUE);
		}
		if (is_admin) {
			swprintf(buf, L"%s.obsolete", org_ini);
			::MoveFileW(org_ini, buf);
			if (::GetFileAttributesW(org_ini) != 0xffffffff) {
				::DeleteFileW(org_ini);
			}
		}
	}

	MakePathW(buf, userDir, L"to_ExeDir.lnk");
//	if (GetFileAttributesW(buf) == 0xffffffff) {
		SymLinkW(execDir, buf);
//	}

	return	TRUE;
}
Exemplo n.º 3
0
BOOL NetPlaceConvertW(WCHAR *src, WCHAR *dst)
{
	IShellLinkW		*shellLink;
	IPersistFile	*persistFile;
	WCHAR	wDstBuf[MAX_PATH];
	WCHAR	*wSrc = src;
	WCHAR	*wDst = wDstBuf;
	BOOL	ret = FALSE;
	DWORD	attr, attr_mask = FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_READONLY;

	if ((attr = ::GetFileAttributesW(src)) == 0xffffffff || (attr & attr_mask) != attr_mask)
		return	FALSE;	// ディレクトリかつronly でないものは関係ない

	if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
				  IID_IShellLinkW, (void **)&shellLink))) {
		if (SUCCEEDED(shellLink->QueryInterface(IID_IPersistFile, (void **)&persistFile))) {
			if (SUCCEEDED(persistFile->Load(wSrc, STGM_READ))) {
				if (SUCCEEDED(shellLink->GetPath(wDst, MAX_PATH, 0, SLGP_UNCPRIORITY))) {
					MakePathW(dst, wDstBuf, L"");
					ret = TRUE;
				}
			}
			persistFile->Release();
		}
		shellLink->Release();
	}

	return	ret;
}
Exemplo n.º 4
0
BOOL ShellExt::Load(WCHAR *parent_dir, WCHAR *dll_name)
{
	if (hShDll) {
		UnLoad();
	}

	WCHAR	path[MAX_PATH];
	MakePathW(path, parent_dir, dll_name);
	if ((hShDll = TLoadLibraryW(path)) == NULL)
		return	FALSE;

	RegisterDllProc  = (HRESULT (WINAPI *)(void))GetProcAddress(hShDll, REGISTER_PROC);
	UnRegisterDllProc= (HRESULT (WINAPI *)(void))GetProcAddress(hShDll, UNREGISTER_PROC);
	RegisterDllUserProc  = (HRESULT (WINAPI *)(void))GetProcAddress(hShDll, REGISTERUSER_PROC);
	UnRegisterDllUserProc= (HRESULT (WINAPI *)(void))GetProcAddress(hShDll, UNREGISTERUSER_PROC);
	IsRegisterDllProc= (BOOL (WINAPI *)(BOOL))GetProcAddress(hShDll, ISREGISTER_PROC);
	SetMenuFlagsProc = (BOOL (WINAPI *)(BOOL, int))GetProcAddress(hShDll, SETMENUFLAGS_PROC);
	GetMenuFlagsProc = (int (WINAPI *)(BOOL))GetProcAddress(hShDll, GETMENUFLAGS_PROC);
	SetAdminModeProc = (BOOL (WINAPI *)(BOOL))GetProcAddress(hShDll, SETADMINMODE_PROC);

// ver違いで proc error になるが、
// install時に overwrite failを検出して、リネームする

	if (!RegisterDllProc || !UnRegisterDllProc || !IsRegisterDllProc
	|| !RegisterDllUserProc || !UnRegisterDllUserProc
	|| !SetMenuFlagsProc || !GetMenuFlagsProc || !SetAdminModeProc) {
		::FreeLibrary(hShDll);
		hShDll = NULL;
		return	FALSE;
	}

	SetAdminModeProc(isAdmin);

	return	TRUE;
}
Exemplo n.º 5
0
BOOL TInstDlg::AppKick()
{
	WCHAR	setupDir[MAX_PATH], setupPath[MAX_PATH];

	GetDlgItemTextW(FILE_EDIT, setupDir, wsizeof(setupDir));
	SetCurrentDirectoryW(setupDir);

	MakePathW(setupPath, setupDir, IPMSG_EXENAME_W);
	return	(int)ShellExecuteW(NULL, NULL, setupPath, L"/SHOW_HISTORY", 0, SW_SHOW) > 32;
}
Exemplo n.º 6
0
/*=========================================================================
  File Log for TMainDlg
=========================================================================*/
BOOL TMainDlg::StartFileLog()
{
	WCHAR	logDir[MAX_PATH] = L"";
	WCHAR	wbuf[MAX_PATH]   = L"";

	if (fileLogMode == NO_FILELOG || (!isListLog && IsListing())) return FALSE;

	if (fileLogMode == AUTO_FILELOG || wcschr(fileLogPath, '\\') == 0) {
		MakePathW(logDir, cfg.userDir, LoadStrW(IDS_FILELOG_SUBDIR));
		if (::GetFileAttributesW(logDir) == 0xffffffff)
			::CreateDirectoryW(logDir, NULL);

		if (fileLogMode == FIX_FILELOG && *fileLogPath) {
			wcscpy(wbuf, fileLogPath);
			MakePathW(fileLogPath, logDir, wbuf);
		}
	}

	if (fileLogMode == AUTO_FILELOG || *fileLogPath == 0) {
		SYSTEMTIME	st = startTm;
		for (int i=0; i < 100; i++) {
			swprintf(wbuf, LoadStrW(IDS_FILELOGNAME),
				st.wYear, st.wMonth, st.wDay, st.wHour,
				st.wMinute, st.wSecond, i);
			MakePathW(fileLogPath, logDir, wbuf);

			hFileLog = ::CreateFileW(fileLogPath, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
						0, CREATE_NEW, 0, 0);
			if (hFileLog != INVALID_HANDLE_VALUE) break;
		}
	}
	else {
		hFileLog = ::CreateFileW(fileLogPath, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
					0, OPEN_ALWAYS, 0, 0);
	}

	if (hFileLog == INVALID_HANDLE_VALUE) return FALSE;

	WriteLogHeader(hFileLog, FALSE);
	return	TRUE;
}
Exemplo n.º 7
0
BOOL TInstDlg::RunAsAdmin(BOOL is_imme)
{
	SHELLEXECUTEINFOW	sei = {0};
	WCHAR				buf[MAX_PATH * 2];
	WCHAR				exe_path[MAX_PATH];
	WCHAR				setup_path[MAX_PATH];
	WCHAR				app_data[MAX_PATH];
	WCHAR				virtual_store[MAX_PATH];
	WCHAR				fastcopy_dir[MAX_PATH];
	WCHAR				*fastcopy_dirname = NULL;
	int					len;

	::GetModuleFileNameW(NULL, exe_path, sizeof(exe_path));

	if (!(len = GetDlgItemTextW(FILE_EDIT, setup_path, MAX_PATH))) return FALSE;
	if (setup_path[len-1] == '\\') setup_path[len-1] = 0;
	if (!::GetFullPathNameW(setup_path, MAX_PATH, fastcopy_dir, &fastcopy_dirname)) return FALSE;

	if (!::SHGetSpecialFolderPathW(NULL, buf, CSIDL_APPDATA, FALSE)) return FALSE;
	MakePathW(app_data, buf, fastcopy_dirname);

	wcscpy(buf, fastcopy_dir);
#ifdef _WIN64
	ConvertToX86Dir(buf);
#endif
	if (!TMakeVirtualStorePathW(buf, virtual_store)) return FALSE;

	swprintf(buf, L"/runas=%p,%d,%d,%d,%d,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"",
		hWnd, cfg.mode, is_imme, cfg.programLink, cfg.desktopLink,
		cfg.startMenu, cfg.deskTop,
		setup_path, app_data, virtual_store);

	sei.cbSize = sizeof(SHELLEXECUTEINFO);
	sei.lpVerb = L"runas";
	sei.lpFile = exe_path;
	sei.lpDirectory = NULL;
	sei.nShow = SW_NORMAL;
	sei.lpParameters = buf;

	EnableWindow(FALSE);
	BOOL ret = ::ShellExecuteExW(&sei);
	EnableWindow(TRUE);

	return	ret;
}
Exemplo n.º 8
0
BOOL ConvertToX86Dir(WCHAR *target)
{
	WCHAR	buf[MAX_PATH];
	WCHAR	buf86[MAX_PATH];
	int		len;

	if (!::SHGetSpecialFolderPathW(NULL, buf, CSIDL_PROGRAM_FILES, FALSE)) return FALSE;
	len = (int)wcslen(buf);
	buf[len++] = '\\';
	buf[len] = 0;

	if (wcsnicmp(buf, target, len)) return FALSE;

	if (!::SHGetSpecialFolderPathW(NULL, buf86, CSIDL_PROGRAM_FILESX86, FALSE)) return FALSE;
	MakePathW(buf, buf86, target + len);
	wcscpy(target, buf);

	return	 TRUE;
}
Exemplo n.º 9
0
BOOL ShellExt::Load(WCHAR *parent_dir, WCHAR *dll_name)
{
	if (hShellExtDll) UnLoad();

	WCHAR	path[MAX_PATH];
	MakePathW(path, parent_dir, dll_name);
	if ((hShellExtDll = TLoadLibraryW(path)) == NULL)
		return	FALSE;

	RegisterDllProc		= (HRESULT (WINAPI *)(void))GetProcAddress(hShellExtDll, REGISTER_PROC);
	UnRegisterDllProc	= (HRESULT (WINAPI *)(void))GetProcAddress(hShellExtDll, UNREGISTER_PROC);
	IsRegisterDllProc	= (BOOL (WINAPI *)(void))GetProcAddress(hShellExtDll, ISREGISTER_PROC);
	SetMenuFlagsProc	= (BOOL (WINAPI *)(int))GetProcAddress(hShellExtDll, SETMENUFLAGS_PROC);
	GetMenuFlagsProc	= (int (WINAPI *)(void))GetProcAddress(hShellExtDll, GETMENUFLAGS_PROC);
	UpdateDllProc		= (BOOL (WINAPI *)(void))GetProcAddress(hShellExtDll, UPDATEDLL_PROC);

	if (!RegisterDllProc || !UnRegisterDllProc || !IsRegisterDllProc
	|| !SetMenuFlagsProc || !GetMenuFlagsProc || !UpdateDllProc) {
		::FreeLibrary(hShellExtDll);
		hShellExtDll = NULL;
		return	FALSE;
	}
	return	TRUE;
}
Exemplo n.º 10
0
BOOL Cfg::ReadIni(WCHAR *user_dir, WCHAR *virtual_dir)
{
	if (!Init(user_dir, virtual_dir)) return FALSE;

	int		i, j;
	char	section[100], key[100], *p;
	DynBuf	buf(MAX_HISTORY_CHAR_BUF);
	Wstr	wbuf(MAX_HISTORY_CHAR_BUF);
	char	*section_array[] = {	SRC_HISTORY, DST_HISTORY, DEL_HISTORY,
									INC_HISTORY, EXC_HISTORY,
									FROMDATE_HISTORY, TODATE_HISTORY,
									MINSIZE_HISTORY, MAXSIZE_HISTORY };
	bool	is_filter_array[] = {	false, false, false,
									true, true,
									false, false,
									false, false };
	WCHAR	***history_array[] = {	&srcPathHistory, &dstPathHistory, &delPathHistory,
									&includeHistory, &excludeHistory,
									&fromDateHistory, &toDateHistory,
									&minSizeHistory, &maxSizeHistory };

/*
	WCHAR	wtestbuf[MAX_HISTORY_CHAR_BUF];
	WCHAR	*wtest[] = {
							L"12345",
							L"abc\\[abc\\]\\",
							L"aaa\\aaa",
							L"abc[\\ax]",
							L"abc[\\ax]\\",
							L"12[[]345",
							L"12[[]345\\",
							L"12\\a3\\[45\\",
							L"12345",
							NULL };


	for (int i=0; wtest[i]; i++) GetFilterStrCore(wtest[i], wtestbuf);
*/
	srcPathHistory	= NULL;
	dstPathHistory	= NULL;
	delPathHistory	= NULL;
	includeHistory	= NULL;
	excludeHistory	= NULL;

	jobArray = NULL;
	jobMax = 0;

	finActArray = NULL;
	finActMax = 0;

	ini.SetSection(MAIN_SECTION);
	iniVersion		= ini.GetInt(INI_VERSION_KEY, CUR_INI_VERSION);
	bufSize			= ini.GetInt(BUFSIZE_KEY, DEFAULT_BUFSIZE);
	maxRunNum		= ini.GetInt(MAXRUNNUM_KEY, DEFAULT_MAXRUNNUM);
	maxTransSize	= ini.GetInt(MAXTRANSSIZE_KEY, DEFAULT_MAXTRANSSIZE);
	maxOvlNum		= ini.GetInt(MAXOVLNUM_KEY, DEFAULT_MAXOVLNUM);
	maxOvlSize		= ini.GetInt(MAXOVLSIZE_KEY, -1);
	if ((maxTransSize % maxOvlNum)) {
		maxTransSize = (maxTransSize + maxOvlNum - 1) / maxOvlNum * maxOvlNum;
	}
	if (bufSize < maxTransSize * BUFIO_SIZERATIO) {
		bufSize = maxTransSize * BUFIO_SIZERATIO;
	}
	maxOpenFiles	= ini.GetInt(MAXOPENFILES_KEY, DEFAULT_MAXOPENFILES);
	maxAttrSize		= ini.GetInt(MAXATTRSIZE_KEY, DEFAULT_MAXATTRSIZE);
	maxDirSize		= ini.GetInt(MAXDIRSIZE_KEY, DEFAULT_MAXDIRSIZE);
	nbMinSizeNtfs	= ini.GetInt(NONBUFMINSIZENTFS_KEY, DEFAULT_NBMINSIZE_NTFS);
	nbMinSizeFat	= ini.GetInt(NONBUFMINSIZEFAT_KEY, DEFAULT_NBMINSIZE_FAT);
	timeDiffGrace	= ini.GetInt(TIMEDIFFGRACE_KEY, 0);

	isReadOsBuf		= ini.GetInt(ISREADOSBUF_KEY, FALSE);
	isWShareOpen	= ini.GetInt(WRITESHAREOPEN_KEY, FALSE);
	maxHistoryNext	= maxHistory = ini.GetInt(MAX_HISTORY_KEY, DEFAULT_MAX_HISTORY);
	copyMode		= ini.GetInt(COPYMODE_KEY, DEFAULT_COPYMODE);
	copyFlags		= ini.GetInt(COPYFLAGS_KEY, DEFAULT_COPYFLAGS);
	copyUnFlags		= ini.GetInt(COPYUNFLAGS_KEY, DEFAULT_COPYUNFLAGS);

	skipEmptyDir	= ini.GetInt(SKIPEMPTYDIR_KEY, DEFAULT_EMPTYDIR);
	forceStart		= ini.GetInt(FORCESTART_KEY, DEFAULT_FORCESTART);
	ignoreErr		= ini.GetInt(IGNORE_ERR_KEY, TRUE);
	estimateMode	= ini.GetInt(ESTIMATE_KEY, 0);
	diskMode		= ini.GetInt(DISKMODE_KEY, 0);
	netDrvMode		= ini.GetInt(NETDRVMODE_KEY, 0);
	aclReset		= ini.GetInt(ACLRESET_KEY, 0);
	isTopLevel		= ini.GetInt(ISTOPLEVEL_KEY, FALSE);
	isErrLog		= ini.GetInt(ISERRLOG_KEY, TRUE);
	isUtf8Log		= ini.GetInt(ISUTF8LOG_KEY, TRUE);
	fileLogMode		= ini.GetInt(FILELOGMODE_KEY, 0);
	fileLogFlags	= ini.GetInt(FILELOGFLAGS_KEY, 0);
	aclErrLog		= ini.GetInt(ACLERRLOG_KEY, FALSE);
	streamErrLog	= ini.GetInt(STREAMERRLOG_KEY, FALSE);
	debugFlags		= ini.GetInt(DEBUGFLAGS_KEY, 0);
	isRunasButton	= ini.GetInt(ISRUNASBUTTON_KEY, FALSE);
	isSameDirRename	= ini.GetInt(ISSAMEDIRRENAME_KEY, TRUE);
	shextAutoClose	= ini.GetInt(SHEXTAUTOCLOSE_KEY, TRUE);
	shextTaskTray	= ini.GetInt(SHEXTTASKTRAY_KEY, FALSE);
	shextNoConfirm	= ini.GetInt(SHEXTNOCONFIRM_KEY, FALSE);
	shextNoConfirmDel = ini.GetInt(SHEXTNOCONFIRMDEL_KEY, FALSE);
	execConfirm		= ini.GetInt(EXECCONRIM_KEY, FALSE);
	lcid			= ini.GetInt(LCID_KEY, -1);
	waitTick		= ini.GetInt(WAITTICK_KEY, DEFAULT_WAITTICK);
	isAutoSlowIo	= ini.GetInt(ISAUTOSLOWIO_KEY, TRUE);
	speedLevel		= ini.GetInt(SPEEDLEVEL_KEY, SPEED_FULL);
	alwaysLowIo		= ini.GetInt(ALWAYSLOWIO_KEY, FALSE);
	enableOwdel		= ini.GetInt(OWDEL_KEY, FALSE);
	enableAcl		= ini.GetInt(ACL_KEY, FALSE);
	enableStream	= ini.GetInt(STREAM_KEY, FALSE);
	enableVerify	= ini.GetInt(VERIFY_KEY, FALSE);
	useOverlapIo	= ini.GetInt(USEOVERLAPIO_KEY, TRUE);
	usingMD5		= ini.GetInt(USEMD5_KEY, TRUE);
	enableNSA		= ini.GetInt(NSA_KEY, FALSE);
	delDirWithFilter= ini.GetInt(DELDIR_KEY, FALSE);
	enableMoveAttr	= ini.GetInt(MOVEATTR_KEY, FALSE);
	serialMove		= ini.GetInt(SERIALMOVE_KEY, TRUE);
	serialVerifyMove = ini.GetInt(SERIALVERIFYMOVE_KEY, TRUE);
	isReparse		= ini.GetInt(REPARSE_KEY, TRUE);
	isLinkDest		= ini.GetInt(LINKDEST_KEY, FALSE);
	maxLinkHash		= ini.GetInt(MAXLINKHASH_KEY, DEFAULT_LINKHASH);
	allowContFsize	= ini.GetInt(ALLOWCONTFSIZE_KEY, DEFAULT_ALLOWCONTFSIZE);
	isReCreate		= ini.GetInt(RECREATE_KEY, FALSE);
	isExtendFilter	= ini.GetInt(EXTENDFILTER_KEY, FALSE);
	taskbarMode		= ini.GetInt(TASKBARMODE_KEY, 0);
	finishNotify	= ini.GetInt(FINISHNOTIFY_KEY, 1);
	finishNotifyTout = ini.GetInt(FINISHNOTIFYTOUT_KEY, FINISH_NOTIFY_DEFAULT);

	infoSpan		= ini.GetInt(INFOSPAN_KEY, DEFAULT_INFOSPAN);
	if (infoSpan < 0 || infoSpan > 2) infoSpan = DEFAULT_INFOSPAN;

	ini.GetStr(WINPOS_KEY, buf, MAX_PATH, "");
	winpos.x   =      (p = strtok(buf,  ", \t")) ? atoi(p) : INVALID_POINTVAL;
	winpos.y   = p && (p = strtok(NULL, ", \t")) ? atoi(p) : INVALID_POINTVAL;
	winsize.cx = p && (p = strtok(NULL, ", \t")) ? atoi(p) : INVALID_SIZEVAL;
	winsize.cy = p && (p = strtok(NULL, ", \t")) ? atoi(p) : INVALID_SIZEVAL;

	ini.GetStr(DRIVEMAP_KEY, driveMap, sizeof(driveMap), "");

	ini.GetStr(STATUSFONT_KEY, buf, MAX_HISTORY_CHAR_BUF, "");
	IniStrToW(buf, statusFont);
	statusFontSize = ini.GetInt(STATUSFONTSIZE_KEY, 0);

/* logfile */
	ini.GetStr(LOGFILE_KEY, buf, MAX_PATH, DEFAULT_FASTCOPYLOG);
	IniStrToW(buf, wbuf.Buf());
	if (wcschr(wbuf.s(), '\\') == NULL) {
		Wstr	wname(wbuf);
		MakePathW(wbuf.Buf(), userDir, wname.s());
	}
	errLogPath = wcsdup(wbuf.s());

/* History */
	for (i=0; i < sizeof(section_array) / sizeof(char *); i++) {
		char	*section_p = section_array[i];
		bool	&is_filter = is_filter_array[i];
		WCHAR	**&history = *history_array[i];

		ini.SetSection(section_p);
		history = (WCHAR **)calloc(maxHistory, sizeof(WCHAR *));
		for (j=0; j < maxHistory + 30; j++) {
			wsprintf(key, "%d", j);
			if (j < maxHistory) {
				if (is_filter) {
					GetFilterStr(key, buf, wbuf.Buf());
				} else {
					ini.GetStr(key, buf, MAX_HISTORY_CHAR_BUF);
					IniStrToW(buf, wbuf.Buf());
				}
				history[j] = wcsdup(wbuf.s());
			}
			else if (!ini.DelKey(key))
				break;
		}
	}

/* Job */
	for (i=0; i < JOB_MAX; i++) {
		Job		job;

		wsprintf(section, FMT_JOB_KEY, i);
		ini.SetSection(section);

		if (ini.GetStr(TITLE_KEY, buf, MAX_HISTORY_CHAR_BUF) <= 0)
			break;
		IniStrToW(buf, wbuf.Buf());
		job.title = wcsdup(wbuf.s());

		ini.GetStr(SRC_KEY, buf, MAX_HISTORY_CHAR_BUF);
		IniStrToW(buf, wbuf.Buf());
		job.src = wcsdup(wbuf.s());

		ini.GetStr(DST_KEY, buf, MAX_HISTORY_CHAR_BUF);
		IniStrToW(buf, wbuf.Buf());
		job.dst = wcsdup(wbuf.s());

		ini.GetStr(CMD_KEY, buf, MAX_HISTORY_CHAR_BUF);
		IniStrToW(buf, wbuf.Buf());
		job.cmd = wcsdup(wbuf.s());

		GetFilterStr(INCLUDE_KEY, buf, wbuf.Buf());
		job.includeFilter = wcsdup(wbuf.s());
		GetFilterStr(EXCLUDE_KEY, buf, wbuf.Buf());
		job.excludeFilter = wcsdup(wbuf.s());

		ini.GetStr(FROMDATE_KEY, buf, MAX_HISTORY_CHAR_BUF);
		IniStrToW(buf, wbuf.Buf());
		job.fromDateFilter = wcsdup(wbuf.s());
		ini.GetStr(TODATE_KEY, buf, MAX_HISTORY_CHAR_BUF);
		IniStrToW(buf, wbuf.Buf());
		job.toDateFilter = wcsdup(wbuf.s());

		ini.GetStr(MINSIZE_KEY, buf, MAX_HISTORY_CHAR_BUF);
		IniStrToW(buf, wbuf.Buf());
		job.minSizeFilter = wcsdup(wbuf.s());
		ini.GetStr(MAXSIZE_KEY, buf, MAX_HISTORY_CHAR_BUF);
		IniStrToW(buf, wbuf.Buf());
		job.maxSizeFilter = wcsdup(wbuf.s());

		job.estimateMode = ini.GetInt(ESTIMATE_KEY, 0);
		job.diskMode = ini.GetInt(DISKMODE_KEY, 0);
		job.ignoreErr = ini.GetInt(IGNORE_ERR_KEY, TRUE);
		job.enableOwdel = ini.GetInt(OWDEL_KEY, FALSE);
		job.enableAcl = ini.GetInt(ACL_KEY, FALSE);
		job.enableStream = ini.GetInt(STREAM_KEY, FALSE);
		job.enableVerify = ini.GetInt(VERIFY_KEY, FALSE);
		job.isFilter = ini.GetInt(FILTER_KEY, FALSE);
		job.bufSize = ini.GetInt(BUFSIZE_KEY, DEFAULT_BUFSIZE);
		if (job.bufSize < maxTransSize * BUFIO_SIZERATIO) {
			job.bufSize = maxTransSize * BUFIO_SIZERATIO;
		}

		AddJobW(&job);
	}

/* FinAct */
	for (i=0; i < FINACT_MAX; i++) {
		FinAct	act;

		wsprintf(buf, FMT_FINACT_KEY, i);
		ini.SetSection(buf);

		if (ini.GetStr(TITLE_KEY, buf, MAX_HISTORY_CHAR_BUF) <= 0)
			break;
		IniStrToW(buf, wbuf.Buf());
		act.title = wcsdup(wbuf.Buf());

		ini.GetStr(SOUND_KEY, buf, MAX_HISTORY_CHAR_BUF);
		IniStrToW(buf, wbuf.Buf());
		act.sound = wcsdup(wbuf.s());

		ini.GetStr(CMD_KEY, buf, MAX_HISTORY_CHAR_BUF);
		IniStrToW(buf, wbuf.Buf());
		act.command = wcsdup(wbuf.s());

		act.flags = ini.GetInt(FLAGS_KEY, 0);

		if (ini.GetStr(SHUTDOWNTIME_KEY, buf, MAX_HISTORY_CHAR_BUF) > 0) {
			act.shutdownTime = strtol(buf, 0, 10);
		}
		AddFinActW(&act);
	}

	if (::GetFileAttributesW(ini.GetIniFileNameW()) == 0xffffffff) {
		WriteIni();
	}
	needIniConvert = FALSE;

	return	TRUE;
}
Exemplo n.º 11
0
BOOL Cfg::Init(WCHAR *user_dir, WCHAR *virtual_dir)
{
	WCHAR	buf[MAX_PATH], path[MAX_PATH], *fname = NULL;

	::GetModuleFileNameW(NULL, buf, MAX_PATH);
	::GetFullPathNameW(buf, MAX_PATH, path, &fname);
	if (!fname) return FALSE;

	execPath = wcsdup(path);
	fname[-1] = 0; // remove '\\' of dir\\fname
	execDir = wcsdup(path);

	errLogPath = NULL;
	userDir = NULL;
	virtualDir = NULL;

	if (IsWinVista() && TIsVirtualizedDirW(execDir)) {
		if (user_dir) {
			userDir = wcsdup(user_dir);
			if (virtual_dir) virtualDir = wcsdup(virtual_dir);
		}
		else {
			WCHAR	virtual_store[MAX_PATH];
			WCHAR	fastcopy_dir[MAX_PATH];
			WCHAR	*fastcopy_dirname = NULL;

			::GetFullPathNameW(path, MAX_PATH, fastcopy_dir, &fastcopy_dirname);

			::SHGetSpecialFolderPathW(NULL, buf, CSIDL_APPDATA, FALSE);
			MakePathW(path, buf, fastcopy_dirname);
			userDir = wcsdup(path);

			wcscpy(buf, execDir);
#ifdef _WIN64
			ConvertToX86Dir(buf);
#endif
			if (!TMakeVirtualStorePathW(buf, virtual_store)) return FALSE;
			virtualDir = wcsdup(virtual_store);
		}
		ConvertVirtualStoreConf(execDir, userDir, virtualDir);
	}
	if (!userDir) userDir = wcsdup(execDir);

	WCHAR	ini_path[MAX_PATH];
	MakePathW(ini_path, userDir, FASTCOPY_INI);

	ini.Init(ini_path);
	ini.SetSection(MAIN_SECTION);
	needIniConvert = FALSE;

	if (ini.GetInt(INI_VERSION_KEY, -1) < CUR_INI_VERSION) {
		if (::GetFileAttributesW(ini_path) != 0xffffffff) {
			WCHAR	bak_path[MAX_PATH];
			wcscpy(bak_path, ini_path);
			wcscat(bak_path, L".bak");
			if (!::MoveFileExW(ini_path, bak_path, MOVEFILE_REPLACE_EXISTING)) {
				::DeleteFileW(ini_path);
			}
			ini.UnInit();
			ini.Init(ini_path);
		}
		WCHAR	ini_path_old[MAX_PATH];
		MakePathW(ini_path_old, userDir, FASTCOPY_INI_OLD);

		if (::GetFileAttributesW(ini_path_old) != 0xffffffff) {
			ini.UnInit();
			ini.Init(ini_path_old); // loading done
			ini.SetIniFileNameW(ini_path);
			needIniConvert = TRUE;

			// obsolete message file
			MakePathW(ini_path_old, userDir, FASTCOPY_INI_OBSOLETE);
			HANDLE hFile = ::CreateFileW(ini_path_old, GENERIC_WRITE, 0, 0, CREATE_ALWAYS,
											FILE_ATTRIBUTE_NORMAL, 0);
			DWORD	size;
			::WriteFile(hFile, FASTCOPY_OBSOLETE_MSG, sizeof(FASTCOPY_OBSOLETE_MSG), &size, 0);
			::CloseHandle(hFile);
		}
	}

	return	TRUE;
}
Exemplo 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() && !::IsUserAnAdmin()) {
		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);
				Wstr	w_buf(buf, BY_MBCS);
				DeleteLinkW(w_buf.Buf());
			}
		}
		reg.CloseKey();
	}

	ShellExtFunc(setupDir, UNREGISTER_SHELLEXT);

#ifdef _WIN64
	if (1) {
#else
	if (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 (TIsVirtualizedDirW(w_setup.Buf())) {
			if (::SHGetSpecialFolderPathW(NULL, wbuf, CSIDL_APPDATA, FALSE)) {
				::GetFullPathNameW(w_setup.Buf(), MAX_PATH, fastcopy_dir, &fastcopy_dirname);
				MakePathW(upath, wbuf, fastcopy_dirname);

				if (::GetFileAttributesW(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;
	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;
}
Exemplo 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 (setupDir[len-1] == '\\') setupDir[len-1] = 0;
	Wstr	w_setup(setupDir);

	if (IsWinVista() && TIsVirtualizedDirW(w_setup.Buf())) {
		if (!::IsUserAnAdmin()) {
			return	RunAsAdmin(TRUE);
		}
		else if (cfg.runImme && cfg.setupDir && lstrcmpiW(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[]	= { WtoA(cfg.startMenu), WtoA(cfg.deskTop), 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]) {
			Wstr	w_setup(setupPath, BY_MBCS);
			Wstr	w_buf(buf, BY_MBCS);
			SymLinkW(w_setup.Buf(), w_buf.Buf());
		}
		else {
			Wstr	w_buf(buf, BY_MBCS);
			DeleteLinkW(w_buf.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() && TIsVirtualizedDirW(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) {
			wcscpy(usr_path, cfg.appData);
		}
		else {
			::SHGetSpecialFolderPathW(NULL, wbuf, CSIDL_APPDATA, FALSE);
			MakePathW(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;

	TLaunchDlg	dlg(msg, this);

	if (dlg.Exec() == IDOK) {
		ShellExecute(NULL, "open", setupPath, "", setupDir, SW_SHOW);
	}

	::PostQuitMessage(0);
	return	TRUE;
}