Пример #1
0
BOOL CWriteMain::GetNextFileName(wstring filePath, wstring& newPath)
{
	WCHAR szPath[_MAX_PATH];
	WCHAR szDrive[_MAX_DRIVE];
	WCHAR szDir[_MAX_DIR];
	WCHAR szFname[_MAX_FNAME];
	WCHAR szExt[_MAX_EXT];
	_wsplitpath_s( filePath.c_str(), szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFname, _MAX_FNAME, szExt, _MAX_EXT );
	_wmakepath_s(  szPath, _MAX_PATH, szDrive, szDir, NULL, NULL );

	BOOL findFlag = FALSE;
	for( int i=1; i<1000; i++ ){
		WIN32_FIND_DATA findData;
		HANDLE find;

		wstring name;
		Format(name, L"%s%s-(%d)%s", szPath, szFname, i, szExt);
		newPath = name;
		
		find = FindFirstFile( newPath.c_str(), &findData);
		if ( find == INVALID_HANDLE_VALUE ) {
			findFlag = TRUE;
			break;
		}
		FindClose(find);
	}
	return findFlag;
}
Пример #2
0
void GetDefSettingPath(wstring& strPath)
{
/*	strPath = L"";

	WCHAR szPathM[_MAX_PATH];
	::SHGetFolderPath(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL, 0, szPathM);

	strPath = szPathM;
	strPath += SAVE_FOLDER;
	ChkFolderPath(strPath);
*/
	WCHAR strExePath[512] = L"";
	GetModuleFileName(NULL, strExePath, 512);

	WCHAR szPath[_MAX_PATH];	// パス
	WCHAR szDrive[_MAX_DRIVE];
	WCHAR szDir[_MAX_DIR];
	WCHAR szFname[_MAX_FNAME];
	WCHAR szExt[_MAX_EXT];
	_wsplitpath_s( strExePath, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFname, _MAX_FNAME, szExt, _MAX_EXT );
	_wmakepath_s(  szPath, _MAX_PATH, szDrive, szDir, NULL, NULL );
	
	strPath = L"";
	strPath += szPath;
	strPath += L"Setting";
}
Пример #3
0
BOOL CWriteMain::Start(
	LPCWSTR fileName,
	BOOL overWriteFlag,
	ULONGLONG createSize
	)
{
	Stop();

	this->savePath = fileName;
	_OutputDebugString(L"★CWriteMain::Start CreateFile:%s\r\n", this->savePath.c_str());
	this->file = _CreateDirectoryAndFile(this->savePath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, overWriteFlag ? CREATE_ALWAYS : CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
	if( this->file == INVALID_HANDLE_VALUE ){
		_OutputDebugString(L"★CWriteMain::Start Err:0x%08X\r\n", GetLastError());
		WCHAR szPath[_MAX_PATH];
		WCHAR szDrive[_MAX_DRIVE];
		WCHAR szDir[_MAX_DIR];
		WCHAR szFname[_MAX_FNAME];
		WCHAR szExt[_MAX_EXT];
		_wsplitpath_s(fileName, szDrive, szDir, szFname, szExt);
		_wmakepath_s(szPath, szDrive, szDir, szFname, NULL);
		for( int i = 1; ; i++ ){
			Format(this->savePath, L"%s-(%d)%s", szPath, i, szExt);
			this->file = CreateFile(this->savePath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, overWriteFlag ? CREATE_ALWAYS : CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
			if( this->file != INVALID_HANDLE_VALUE || i >= 999 ){
				DWORD err = GetLastError();
				_OutputDebugString(L"★CWriteMain::Start CreateFile:%s\r\n", this->savePath.c_str());
				if( this->file != INVALID_HANDLE_VALUE ){
					break;
				}
				_OutputDebugString(L"★CWriteMain::Start Err:0x%08X\r\n", err);
				this->savePath = L"";
				return FALSE;
			}
		}
	}

	//ディスクに容量を確保
	if( createSize > 0 ){
		LARGE_INTEGER stPos;
		stPos.QuadPart = createSize;
		SetFilePointerEx( this->file, stPos, NULL, FILE_BEGIN );
		SetEndOfFile( this->file );
		SetFilePointer( this->file, 0, NULL, FILE_BEGIN );
	}
	this->wrotePos = 0;

	//コマンドに分岐出力
	if( this->teeCmd.empty() == false ){
		this->teeFile = CreateFile(this->savePath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
		if( this->teeFile != INVALID_HANDLE_VALUE ){
			this->teeThreadStopFlag = FALSE;
			this->teeThread = (HANDLE)_beginthreadex(NULL, 0, TeeThread, this, 0, NULL);
		}
	}

	return TRUE;
}
Пример #4
0
void GetFileName(const wstring& strPath, wstring& strName)
{
	WCHAR strFileName[_MAX_FNAME + _MAX_EXT + 8];
	WCHAR szFname[_MAX_FNAME];
	WCHAR szExt[_MAX_EXT];
	_wsplitpath_s( strPath.c_str(), NULL, 0, NULL, 0, szFname, _MAX_FNAME, szExt, _MAX_EXT );
	_wmakepath_s( strFileName, NULL, NULL, szFname, szExt );

	strName = strFileName;
	return ;
}
Пример #5
0
void GetFileFolder(const wstring& strPath, wstring& strFolder)
{
	WCHAR szPath[_MAX_DRIVE + _MAX_DIR + 8];
	WCHAR szDrive[_MAX_DRIVE];
	WCHAR szDir[_MAX_DIR];
	_wsplitpath_s( strPath.c_str(), szDrive, _MAX_DRIVE, szDir, _MAX_DIR, NULL, 0, NULL, 0 );
	_wmakepath_s( szPath, szDrive, szDir, NULL, NULL );

	strFolder = szPath;
	ChkFolderPath(strFolder);
	return ;
}
Пример #6
0
void GetFileName(wstring strPath, wstring& strName)
{
	WCHAR strFileName[512] = L"";
	WCHAR szDrive[_MAX_DRIVE];
	WCHAR szDir[_MAX_DIR];
	WCHAR szFname[_MAX_FNAME];
	WCHAR szExt[_MAX_EXT];
	_wsplitpath_s( strPath.c_str(), szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFname, _MAX_FNAME, szExt, _MAX_EXT );
	_wmakepath_s( strFileName, _MAX_PATH, NULL, NULL, szFname, szExt );

	strName = strFileName;
	return ;
}
Пример #7
0
void ConfigParser::ParseConfig(HANDLE hmod, CmdLineArgsParser &parser)
{
#if defined(ENABLE_DEBUG_CONFIG_OPTIONS) && CONFIG_PARSE_CONFIG_FILE
    Assert(!_hasReadConfig);
    _hasReadConfig = true;

    char16 configBuffer[MaxTokenSize];
    int err = 0;
    char16 modulename[_MAX_PATH];
    char16 filename[_MAX_PATH];

    GetModuleFileName((HMODULE)hmod, modulename, _MAX_PATH);
    char16 drive[_MAX_DRIVE];
    char16 dir[_MAX_DIR];

    _wsplitpath_s(modulename, drive, _MAX_DRIVE, dir, _MAX_DIR, nullptr, 0, nullptr, 0);
    _wmakepath_s(filename, drive, dir, _configFileName, _u(".config"));

    FILE* configFile;
    if (_wfopen_s(&configFile, filename, _u("r, ccs=UNICODE")) != 0 || configFile == nullptr)
    {
        WCHAR configFileFullName[MAX_PATH];

        StringCchPrintf(configFileFullName, MAX_PATH, _u("%s.config"), _configFileName);

        // try the one in the current working directory (Desktop)
        if (_wfullpath(filename, configFileFullName, _MAX_PATH) == nullptr)
        {
            return;
        }
        if (_wfopen_s(&configFile, filename, _u("r, ccs=UNICODE")) != 0 || configFile == nullptr)
        {
            return;
        }
    }

    while (fwscanf_s(configFile, _u("%s"), configBuffer, MaxTokenSize) != FINISHED)
    {
        if ((err = parser.Parse(configBuffer)) != 0)
        {
            break;
        }
    }
    fclose(configFile);

    if (err !=0)
    {
        return;
    }
#endif
}
Пример #8
0
void GetFileFolder(wstring strPath, wstring& strFolder)
{
	WCHAR szPath[512] = L"";
	WCHAR szDrive[_MAX_DRIVE];
	WCHAR szDir[_MAX_DIR];
	WCHAR szFname[_MAX_FNAME];
	WCHAR szExt[_MAX_EXT];
	_wsplitpath_s( strPath.c_str(), szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFname, _MAX_FNAME, szExt, _MAX_EXT );
	_wmakepath_s( szPath, _MAX_PATH, szDrive, szDir, NULL, NULL );

	strFolder = szPath;
	ChkFolderPath(strFolder);
	return ;
}
Пример #9
0
void GetModuleIniPath(wstring& strPath)
{
	WCHAR strExePath[MAX_PATH];
	DWORD len = GetModuleFileName(NULL, strExePath, MAX_PATH);
	if( len == 0 || len >= MAX_PATH ){
		throw std::runtime_error("");
	}

	WCHAR szPath[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + 4 + 8];
	WCHAR szDrive[_MAX_DRIVE];
	WCHAR szDir[_MAX_DIR];
	WCHAR szFname[_MAX_FNAME];
	_wsplitpath_s( strExePath, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFname, _MAX_FNAME, NULL, 0 );
	_wmakepath_s(  szPath, szDrive, szDir, szFname, L".ini" );
	strPath = szPath;
}
Пример #10
0
void GetModuleFolderPath(wstring& strPath)
{
	WCHAR strExePath[MAX_PATH];
	DWORD len = GetModuleFileName(NULL, strExePath, MAX_PATH);
	if( len == 0 || len >= MAX_PATH ){
		throw std::runtime_error("");
	}

	WCHAR szPath[_MAX_DRIVE + _MAX_DIR + 8];
	WCHAR szDrive[_MAX_DRIVE];
	WCHAR szDir[_MAX_DIR];
	_wsplitpath_s( strExePath, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, NULL, 0, NULL, 0 );
	_wmakepath_s(  szPath, szDrive, szDir, NULL, NULL );
	strPath = szPath;
	ChkFolderPath(strPath);
}
Пример #11
0
void GetCommonIniPath(wstring& strPath)
{
	WCHAR strExePath[512] = L"";
	GetModuleFileName(NULL, strExePath, 512);

	WCHAR szPath[_MAX_PATH];	// パス
	WCHAR szDrive[_MAX_DRIVE];
	WCHAR szDir[_MAX_DIR];
	WCHAR szFname[_MAX_FNAME];
	WCHAR szExt[_MAX_EXT];
	_wsplitpath_s( strExePath, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFname, _MAX_FNAME, szExt, _MAX_EXT );
	_wmakepath_s(  szPath, _MAX_PATH, szDrive, szDir, NULL, NULL );
	
	strPath = L"";
	strPath += szPath;
	strPath += L"Common.ini";
}
Пример #12
0
bool LOCATOR::FLocateDbgDefault()
{
    if (FRestrictReferencePath()) {
        return false;
    }

    wchar_t wszDrive[_MAX_DRIVE];
    wchar_t wszDir[_MAX_DIR];
    wchar_t wszDbgPath[PDB_MAX_FILENAME];

    _wsplitpath_s(m_wszExePath, wszDrive, _countof(wszDrive), wszDir, _countof(wszDir), NULL, 0, NULL, 0);

    _wmakepath_s(wszDbgPath, _countof(wszDbgPath), wszDrive, wszDir, m_wszExeFName, L".dbg");

    bool f = FLocateDbgValidate(wszDbgPath);

    return f;
}
Пример #13
0
void GetModuleFolderPath(wstring& strPath)
{
	WCHAR strExePath[512] = L"";
	GetModuleFileName(NULL, strExePath, 512);

	WCHAR szPath[_MAX_PATH];	// パス
	WCHAR szDrive[_MAX_DRIVE];
	WCHAR szDir[_MAX_DIR];
	WCHAR szFname[_MAX_FNAME];
	WCHAR szExt[_MAX_EXT];
	_wsplitpath_s( strExePath, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFname, _MAX_FNAME, szExt, _MAX_EXT );
	_wmakepath_s(  szPath, _MAX_PATH, szDrive, szDir, NULL, NULL );
	int iLen = lstrlen(szPath);
	szPath[iLen-1] = '\0';
	
	strPath = L"";
	strPath += szPath;
	ChkFolderPath(strPath);
}
Пример #14
0
bool LOCATOR::FLocatePdbDefault(const wchar_t *wszReference)
{
    assert(m_wszCache == NULL);

    if (wszReference != NULL && !FRestrictReferencePath()) {
        // Attempt to open the PDB in the reference directory

        wchar_t wszDrive[_MAX_DRIVE];
        wchar_t wszDir[_MAX_DIR];

        _wsplitpath_s(wszReference, wszDrive, _countof(wszDrive), wszDir, _countof(wszDir), NULL, 0, NULL, 0);

        if (wszDir[0] == L'\0') {
            wszDir[0] = L'.';
            wszDir[1] = L'\0';
        }

        wchar_t wszFName[_MAX_FNAME];
        wchar_t wszExt[_MAX_EXT];

        _wsplitpath_s(m_wszPdb, NULL, 0, NULL, 0, wszFName, _countof(wszFName), wszExt, _countof(wszExt));

        wchar_t wszPdb[PDB_MAX_FILENAME];

        _wmakepath_s(wszPdb, _countof(wszPdb), wszDrive, wszDir, wszFName, wszExt);

        if (FOpenValidate4(wszPdb)) {
            return true;
        }
    }

    if (FRestrictOriginalPath()) {
        return false;
    }

    return FOpenValidate4(m_wszPdb);
}
Пример #15
0
void CClassicCopyFile::GetFileInfo( IAccessible *pAcc, bool bSrc )
{
	long count;
	pAcc->get_accChildCount(&count);
	CComVariant children[20];
	AccessibleChildren(pAcc,0,count,children,&count);

	wchar_t fname[_MAX_PATH]=L"";
	wchar_t dir[_MAX_PATH]=L"";
	CString size;
	CString date;

	// get the file name, directory, size and date
	for (int i=0;i<count;i++)
	{
		CComBSTR name;
		if (children[i].vt==VT_DISPATCH)
		{
			CComQIPtr<IAccessible> pChild=children[i].pdispVal;
			if (pChild)
				pChild->get_accName(CComVariant(CHILDID_SELF),&name);
		}
		else
		{
			pAcc->get_accName(children[i],&name);
		}
		switch (i)
		{
			case 2: if (wcslen(name)<_countof(fname)) wcscpy_s(fname,name); break;
			case 3: if (wcslen(name)<_countof(dir)) wcscpy_s(dir,name); break;
			case 4: size=name; break;
			case 5: date=name; break;
		}
	}

	if (bSrc)
	{
		m_FileName=fname;
		m_SrcSize=size;
		m_SrcTime=date;
	}
	else
	{
		m_DstSize=size;
		m_DstTime=date;
	}

	if (!fname[0] || !dir[0]) return;

	wchar_t fname2[_MAX_PATH];
	memcpy(fname2,fname,sizeof(fname2));
	*PathFindExtension(fname2)=0;

	int len1=Strlen(fname2);
	// the directory text is something like "filename (directory)". we need to parse out the real directory name
	int len2=Strlen(dir);
	if (dir[0]==0x202A) len1++; // for RTL languages the first character is some RTL marker. needs to be skipped
	if (len1+1>=len2 || dir[len1]!=L' ' || dir[len1+1]!=L'(' || dir[len2-1]!=L')') return;
	dir[len2-1]=0;

	// construct the full file name
	wchar_t path[_MAX_PATH];
	_wmakepath_s(path,NULL,dir+len1+2,fname,NULL);

	if (!bSrc)
	{
		DWORD attrib=GetFileAttributes(path);
		if (attrib!=INVALID_FILE_ATTRIBUTES)
		{
			if (attrib&FILE_ATTRIBUTE_READONLY) m_bReadOnly=true;
			if (attrib&FILE_ATTRIBUTE_SYSTEM) m_bSystem=true;
		}
	}

	// get file icon
	HICON hIcon=NULL;
	PIDLIST_ABSOLUTE pidl=NULL;
	if (SUCCEEDED(SHParseDisplayName(path,NULL,&pidl,0,NULL)) && pidl)
	{
		int iconSize=GetSystemMetrics(SM_CXICON);
		HBITMAP hBitmap=NULL;
		CComPtr<IShellItemImageFactory> pFactory;
		if (SUCCEEDED(SHCreateItemFromIDList(pidl,IID_IShellItemImageFactory,(void**)&pFactory)) && pFactory)
		{
			SIZE size={iconSize,iconSize};
			if (FAILED(pFactory->GetImage(size,SIIGBF_ICONONLY,&hBitmap)))
				hBitmap=NULL;
		}

		ILFree(pidl);
		if (hBitmap)
		{
			HBITMAP hMonoBitmap=CreateBitmap(iconSize,iconSize,1,1,NULL);
			ICONINFO info={TRUE,0,0,hMonoBitmap,hBitmap};
			hIcon=CreateIconIndirect(&info);
			DeleteObject(hMonoBitmap);
			DeleteObject(hBitmap);
		}
	}
	if (!hIcon) return;

	if (bSrc)
		m_SrcIcon=hIcon;
	else
		m_DstIcon=hIcon;
}
Пример #16
0
BOOL __stdcall AtlTraceLoadSettingsU(const WCHAR *pszFileName, DWORD_PTR dwProcess /* = 0 */)
{
    WCHAR szFileName[MAX_PATH];
    if(!pszFileName)
    {
        WCHAR szDrive[_MAX_DRIVE];
        WCHAR szDir[_MAX_DIR];
        WCHAR szFName[_MAX_FNAME];
        WCHAR szExt[_MAX_EXT];

        DWORD dwret = ::GetModuleFileNameW(NULL, szFileName, MAX_PATH);
        if( dwret == 0 || dwret == MAX_PATH )
            return FALSE;
#if _SECURE_ATL
        ATL_CRT_ERRORCHECK(_wsplitpath_s(szFileName, szDrive, _countof(szDrive), szDir, _countof(szDir), szFName, _countof(szFName), szExt, _countof(szExt)));
        ATL_CRT_ERRORCHECK(wcsncpy_s(szExt, _MAX_EXT, TRACE_SETTINGS_EXTW, _countof(TRACE_SETTINGS_EXTW)));
        ATL_CRT_ERRORCHECK(_wmakepath_s(szFileName, MAX_PATH, szDrive, szDir, szFName, szExt));
#else
        _wsplitpath(szFileName, szDrive, szDir, szFName, szExt);
        wcscpy(szExt, L".trc");
        _wmakepath(szFileName, szDrive, szDir, szFName, szExt);
#endif
        pszFileName = szFileName;
    }

    if(pszFileName)
    {
        if(-1 != GetFileAttributesW(pszFileName))
        {
            // file exists
            WCHAR szSection[MAX_PATH], szKey[MAX_PATH], szValue[MAX_PATH];
            WCHAR szName[MAX_PATH];
            UINT nModules, nCategories, nStatus, nLevel;
            UINT nModule;
            CAtlTraceProcess *pProcess;
            CAtlTraceModule *pModule;
            CAtlTraceCategory *pCategory;
            LPCWSTR pszProcess = L"Process";
            WCHAR cEnabled, cFuncAndCategoryNames, cFileNameAndLineInfo;
            CAtlAllocator *pAllocator = &g_Allocator;

            if (dwProcess)
                pAllocator = reinterpret_cast<CAtlAllocator*>(dwProcess);

            pProcess = pAllocator->GetProcess();
            ATLASSERT(pProcess);
            if(!pProcess)
                return FALSE;

            pProcess->m_bLoaded = true;

            ::GetPrivateProfileStringW(pszProcess, L"Info", L"", szValue, MAX_PATH, pszFileName);
            szValue[MAX_PATH -1] = 0;
#if _SECURE_ATL
            if(5 != swscanf_s(szValue, L"ModuleCount:%u, Level:%u, Enabled:%c, "
                              L"FuncAndCategoryNames:%c, FileNameAndLineNo:%c", &nModules, &pProcess->m_nLevel, &cEnabled, sizeof(cEnabled),
                              &cFuncAndCategoryNames, sizeof(cFuncAndCategoryNames), &cFileNameAndLineInfo, sizeof(cFileNameAndLineInfo)))
#else
            if(5 != swscanf(szValue, L"ModuleCount:%u, Level:%u, Enabled:%c, "
                            L"FuncAndCategoryNames:%c, FileNameAndLineNo:%c", &nModules, &pProcess->m_nLevel, &cEnabled,
                            &cFuncAndCategoryNames, &cFileNameAndLineInfo))
#endif
            {
                return FALSE;
            }
            pProcess->m_bEnabled = cEnabled != L'f';
            pProcess->m_bFuncAndCategoryNames = cFuncAndCategoryNames != L'f';
            pProcess->m_bFileNameAndLineNo = cFileNameAndLineInfo != L'f';

            for(UINT i = 0; i < nModules; i++)
            {
                if(swprintf(szKey, MAX_PATH, L"Module%d", i+1) < 0)
                    return FALSE;

                ::GetPrivateProfileStringW(pszProcess, szKey, L"", szSection, MAX_PATH, pszFileName);
                szSection[MAX_PATH -1] = 0;
                ::GetPrivateProfileStringW(szSection, L"Name", L"", szName, MAX_PATH, pszFileName);
                szName[MAX_PATH -1] = 0;
                if(!pAllocator->FindModule(szName, &nModule))
                    continue;

                pModule = pAllocator->GetModule(nModule);
                ATLASSERT(pModule);
                if(!pModule)
                    continue;

                ::GetPrivateProfileStringW(szSection, L"Settings", L"", szValue, MAX_PATH, pszFileName);
                szValue[MAX_PATH -1] = 0;
#if _SECURE_ATL
                if(3 != swscanf_s(szValue, L"CategoryCount:%u, Level:%u, Status:%u", &nCategories, &nLevel, &nStatus))
#else
                if(3 != swscanf(szValue, L"CategoryCount:%u, Level:%u, Status:%u", &nCategories, &nLevel, &nStatus))
#endif
                    continue;

                SetSettings(pModule, nLevel, nStatus);

                for(UINT j = 0; j < nCategories; j++)
                {
                    if(swprintf(szKey, MAX_PATH, L"Category%d", j+1) < 0)
                        return FALSE;
                    ::GetPrivateProfileStringW(szSection, szKey, L"", szValue, MAX_PATH, pszFileName);
                    szValue[MAX_PATH -1] = 0;
#if _SECURE_ATL
                    if(3 != swscanf_s(szValue, L"Level:%u, Status:%u, Name:%s", &nLevel, &nStatus, szName, _countof(szName)))
#else
                    if(3 != swscanf(szValue, L"Level:%u, Status:%u, Name:%s", &nLevel, &nStatus, szName))
#endif
                        continue;

                    UINT iCategory = pModule->m_iFirstCategory;
                    while( iCategory != UINT( -1 ) )
                    {
                        pCategory = pAllocator->GetCategory(iCategory);

                        if( lstrcmpW(pCategory->Name(), szName) == 0 )
                        {
                            SetSettings(pCategory, nLevel, nStatus);
                        }
                        iCategory = pCategory->m_iNextCategory;
                    }
                }
            }
            NotifyTool();
        }
    }
    return TRUE;
}
Пример #17
0
UINT WINAPI CWriteMain::TeeThread(LPVOID param)
{
	CWriteMain* sys = (CWriteMain*)param;
	wstring cmd = sys->teeCmd;
	Replace(cmd, L"$FilePath$", sys->savePath);
	vector<WCHAR> cmdBuff(cmd.c_str(), cmd.c_str() + cmd.size() + 1);

	WCHAR szCurrentDir[_MAX_PATH];
	DWORD ret = GetModuleFileName(NULL, szCurrentDir, _MAX_PATH);
	if( ret && ret < _MAX_PATH ){
		//カレントは実行ファイルのあるフォルダ
		WCHAR szDrive[_MAX_DRIVE];
		WCHAR szDir[_MAX_DIR];
		_wsplitpath_s(szCurrentDir, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, NULL, 0, NULL, 0);
		_wmakepath_s(szCurrentDir, szDrive, szDir, NULL, NULL);

		//標準入力にパイプしたプロセスを起動する
		HANDLE tempPipe;
		HANDLE writePipe;
		if( CreatePipe(&tempPipe, &writePipe, NULL, 0) ){
			HANDLE readPipe;
			BOOL bRet = DuplicateHandle(GetCurrentProcess(), tempPipe, GetCurrentProcess(), &readPipe, 0, TRUE, DUPLICATE_SAME_ACCESS);
			CloseHandle(tempPipe);
			if( bRet ){
				SECURITY_ATTRIBUTES sa;
				sa.nLength = sizeof(sa);
				sa.lpSecurityDescriptor = NULL;
				sa.bInheritHandle = TRUE;
				STARTUPINFO si = {};
				si.cb = sizeof(si);
				si.dwFlags = STARTF_USESTDHANDLES;
				si.hStdInput = readPipe;
				//標準(エラー)出力はnulデバイスに捨てる
				si.hStdOutput = CreateFile(L"nul", GENERIC_WRITE, 0, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
				si.hStdError = CreateFile(L"nul", GENERIC_WRITE, 0, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
				PROCESS_INFORMATION pi;
				bRet = CreateProcess(NULL, &cmdBuff.front(), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, szCurrentDir, &si, &pi);
				CloseHandle(readPipe);
				if( si.hStdOutput != INVALID_HANDLE_VALUE ){
					CloseHandle(si.hStdOutput);
				}
				if( si.hStdError != INVALID_HANDLE_VALUE ){
					CloseHandle(si.hStdError);
				}
				if( bRet ){
					CloseHandle(pi.hThread);
					CloseHandle(pi.hProcess);
					while( sys->teeThreadStopFlag == FALSE ){
						__int64 readablePos;
						{
							CBlockLock lock(&sys->wroteLock);
							readablePos = sys->wrotePos - sys->teeDelay;
						}
						LARGE_INTEGER liPos = {};
						DWORD read;
						if( SetFilePointerEx(sys->teeFile, liPos, &liPos, FILE_CURRENT) &&
						    readablePos - liPos.QuadPart >= (__int64)sys->teeBuff.size() &&
						    ReadFile(sys->teeFile, &sys->teeBuff.front(), (DWORD)sys->teeBuff.size(), &read, NULL) && read > 0 ){
							DWORD write;
							if( WriteFile(writePipe, &sys->teeBuff.front(), read, &write, NULL) == FALSE ){
								break;
							}
						}else{
							Sleep(100);
						}
					}
					//プロセスは回収しない(標準入力が閉じられた後にどうするかはプロセスの判断に任せる)
				}
			}
			CloseHandle(writePipe);
		}
	}
	return 0;
}