Ejemplo n.º 1
0
std::string CFileFind::GetFileTitle() const
{
	if( m_hContext == NULL)
		return FALSE;

	std::string strFullName = GetFileName();
	char strResult[_MAX_PATH];

	_tsplitpath( strFullName.c_str(), NULL, NULL, strResult, NULL);
	return strResult;
}
Ejemplo n.º 2
0
tstring Helium::GetProcessName()
{
    HMODULE moduleHandle = GetModuleHandle( NULL );

    tchar_t module[ MAX_PATH + 1 ];
    GetModuleFileName( moduleHandle, module, MAX_PATH );

    tchar_t file[ MAX_PATH + 1 ];
    _tsplitpath( module, NULL, NULL, file, NULL );

    return file;
}
Ejemplo n.º 3
0
/* Tony Hoyle's function for testing whether a given volume uses UTC or 
 * local time to record file modification times
 * 
 * Reproduced here with permission of Tony Hoyle.
 * 
 * This code is copyright by Tony Hoyle and is licensed under the Gnu 
 * Public License. (See above)
 *
 * NTFS, HPFS, and OWFS store file times as UTC times.
 * FAT stores file times as local time.
 *
 * INPUTS:
 *      LPCSTR name: fully qualified path
 *
 * OUTPUTS:
 *      Return true if the file system on the volume in question 
 *      stores file times as UTC
 */
BOOL IsUTCVolume ( LPCTSTR name )
{
    _TCHAR szDrive[_MAX_DRIVE + 1] = _T("");
    _TCHAR szFs[32]=_T("");
    _tsplitpath(name, szDrive, NULL, NULL, NULL);

    _tcscat(szDrive, _T("\\"));
    GetVolumeInformation( szDrive, NULL, 0, NULL, NULL, NULL, szFs, 32 );
    return ! ( _tcsicmp( szFs, _T("NTFS") ) 
               && _tcsicmp( szFs, _T("HPFS") ) 
               && _tcsicmp( szFs, _T("OWFS") ) );
}
Ejemplo n.º 4
0
CString CFileFind::GetFileTitle() const
{
	ASSERT(m_hContext != NULL);
	ASSERT_VALID(this);

	CString strFullName = GetFileName();
	CString strResult;

	_tsplitpath(strFullName, NULL, NULL, strResult.GetBuffer(_MAX_PATH), NULL);
	strResult.ReleaseBuffer();
	return strResult;
}
Ejemplo n.º 5
0
void CFilePath_i::SetPath(LPCTSTR szPath, BOOL bIsFolderPath)
{
	TCHAR szParamPath[MAX_PATH];
	TCHAR szDrive[_MAX_DRIVE], szDir[_MAX_DIR];
	TCHAR szName[_MAX_FNAME], szExt[_MAX_EXT];

	// Reset
	m_sOriginalPath.Empty();
	m_sDriveLabel.Empty();
	bool m_bIsRelative = FALSE;
	m_aDir.RemoveAll();
	m_sExtName.Empty();

	// Original path
	m_sOriginalPath = szPath;

	// Get args and remove them from path
	szParamPath[0] = 0x0;
	lstrcpy(szParamPath, szPath);

	PathUnquoteSpaces(szParamPath);
	if (szParamPath[0] == 0x0) return;

	_tsplitpath(szParamPath, szDrive, szDir, szName, szExt);

	// Drive
	m_sDrive = szDrive;

	// Directory
	m_sDir = szDir;
	m_sDir.Replace(_T('/'), _T('\\'));
	if (!_sDir.IsEmpty()) _bIsRelative = (_sDir[0] != _T('\\'));
	
	// FileTitle
	if (bIsFolderPath)
	{
		_sDir = AddBackSlash(_sDir);
		_sDir += szName;
		_sDir = AddBackSlash(_sDir);
	}
	else
	{
		_sFileTitle = szName;
	}

	// Get extension name (e.g.: "txt")
  if (!_sFileTitle.IsEmpty())
	{
		_sExtName = szExt;
		_sExtName.Remove(_T('.'));
	}
}
Ejemplo n.º 6
0
void UTBStr::tsplitpath(const TCHAR * path, TCHAR * drive, size_t driveSizeInTCHARacters, TCHAR * dir,
   size_t dirSizeInTCHARacters, TCHAR * fname, size_t nameSizeInTCHARacters, TCHAR * ext, size_t extSizeInBytes)
{
#if _MSC_VER >= 1400
	_tsplitpath_s(path, drive, driveSizeInTCHARacters, dir, dirSizeInTCHARacters, fname, nameSizeInTCHARacters, ext, extSizeInBytes);
#else
	UNREFERENCED_PARAMETER(driveSizeInTCHARacters);
	UNREFERENCED_PARAMETER(dirSizeInTCHARacters);
	UNREFERENCED_PARAMETER(nameSizeInTCHARacters);
	UNREFERENCED_PARAMETER(extSizeInBytes);
	_tsplitpath(path, drive, dir, fname, ext);
#endif
}
Ejemplo n.º 7
0
void CModelViewRender::LoadModel()
{
    ASSERT(GetDocument() != NULL);
    CString strPath = GetDocument()->GetPathName();
    LPCTSTR szPath = strPath;
    TCHAR extStr[_MAX_EXT];
    TCHAR fileName[_MAX_FNAME];
    _tsplitpath(szPath, NULL, NULL, fileName, extStr);

    if (strPath.IsEmpty())
    {
        m_ToolBox->Log(LOGWARNING, _T("%s(%i):LoadModel shouldn't have been called with NULL path\n"), __FILE__, __LINE__);
        return;
    }

    StdString szFilename = fileName;
    szFilename += extStr;
    m_hszModelName = szFilename;

    CFileVersionSetter setter( _T("2.5") );

    if (0 == _tcsicmp(extStr, _T(".cfg")))
    {
        IArchive *pArchive = CreateMemoryArchive();
        if (pArchive != NULL)
        {
            pArchive->Write(szPath, _T("Filepath"));
            pArchive->SetIsWriting(false);
            static CHashString hszCal3DRenderObject(_T("Cal3DRenderObject"));
            CreateEEObject(&m_hszEntityName, &hszCal3DRenderObject, m_hszModelName, pArchive);
            FillAnimationList();
            pArchive->Close();
        }
    }
    else if (0 == _tcsicmp(extStr, _T(".hrc")))
    {
        IArchive *pArchive = CreateMemoryArchive();
        if (pArchive != NULL)
        {
            pArchive->Write(szPath);
            pArchive->SetIsWriting(false);
            static CHashString hszCal3DRenderObject(_T("CHierarchicalModel"));
            CreateEEObject(&m_hszEntityName, &hszCal3DRenderObject, m_hszModelName, pArchive);
            pArchive->Close();
        }
    }
    else
    {
        m_ToolBox->Log(LOGWARNING, _T("%s(%i):LoadModel was passed %s extension, which is not recognized\n"), __FILE__, __LINE__, extStr);
    }
}
Ejemplo n.º 8
0
bool LoadAttributeFileWAV(FILE_INFO *pFileMP3)
{
	CRiffSIF riff;
	wchar_t ext[_MAX_EXT];
	_tsplitpath(GetFullPath(pFileMP3), NULL, NULL, NULL, ext);
    if(_strcmpi(ext, ".wav") == 0){
        if(riff.Load(GetFullPath(pFileMP3),'W','A','V','E') != ERROR_SUCCESS){
            return false;
        }
    }
    else if(_strcmpi(ext, ".avi") == 0){
        if(riff.Load(GetFullPath(pFileMP3),'A','V','I',' ') != ERROR_SUCCESS){
            return false;
        }
	    //ISBJ songname
	    SetTrackNameSI(pFileMP3, riff.GetField('I','S','B','J'));
    }
    else{
        return false;
    }
    //INAM/ISBJ タイトル
    //ISBJ よりも INAM を優先
    SetTrackNameSI(pFileMP3, riff.GetField('I','N','A','M'));
    if(wcslen(GetTrackNameSI(pFileMP3)) == 0){
        SetTrackNameSI(pFileMP3, riff.GetField('I','S','B','J'));
    }
	//IART アーティスト名
	SetArtistNameSI(pFileMP3, riff.GetField('I','A','R','T'));
	//IPRD アルバム名
	SetAlbumNameSI(pFileMP3, riff.GetField('I','P','R','D'));
	//ICMT コメント
	SetCommentSI(pFileMP3, riff.GetField('I','C','M','T'));
	//ICRD 日付
	SetYearSI(pFileMP3, riff.GetField('I','C','R','D'));
	//IGNR ジャンル
	SetGenreSI(pFileMP3, riff.GetField('I','G','N','R'));
	//ICOP 著作権
	SetCopyrightSI(pFileMP3, riff.GetField('I','C','O','P'));
	//IENG エンジニア	
    SetEngineerSI(pFileMP3, riff.GetField('I','E','N','G'));
	//ISRC ソース	
	SetSourceSI(pFileMP3, riff.GetField('I','S','R','C'));
	//ISFT ソフトウェア
	SetSoftwareSI(pFileMP3, riff.GetField('I','S','F','T'));
	//ITRK トラック番号
	SetTrackNumberSI(pFileMP3, riff.GetField('I','T','R','K'));

	extern bool GetValues_mp3infp(FILE_INFO *pFileMP3);
	GetValues_mp3infp(pFileMP3);
    return true;
}
Ejemplo n.º 9
0
void CBCGPBaseInfoWriter::ParseFileName(const CString& pathName, CString& fileName, CString& extName)
{
	fileName.Empty ();
	extName.Empty ();

#if _MSC_VER < 1400
	_tsplitpath (pathName, NULL, NULL, fileName.GetBuffer (_MAX_FNAME), extName.GetBuffer (_MAX_EXT));
#else
	_tsplitpath_s (pathName, NULL, 0, NULL, 0, fileName.GetBuffer (_MAX_FNAME), _MAX_FNAME, extName.GetBuffer (_MAX_EXT), _MAX_EXT);
#endif

	fileName.ReleaseBuffer ();
	extName.ReleaseBuffer ();
}
Ejemplo n.º 10
0
static CString GetAppPathDir()
{
	TCHAR szModulePath[_MAX_PATH];
	GetModuleFileName( _hdllInstance, szModulePath, _MAX_PATH );

	TCHAR drive[_MAX_DRIVE];
	TCHAR dir[_MAX_DIR];
	_tsplitpath( szModulePath, drive, dir, NULL, NULL );

	TCHAR szPath[_MAX_PATH] = {0};
	_tmakepath( szPath, drive, dir, NULL, NULL );

	return CString( szPath );
}
Ejemplo n.º 11
0
 CConfig(const std::_tstring & id, const boost::filesystem::path & path) : m_id(id), m_CfgPath(path)
 {
     TCHAR szFileName[_MAX_FNAME];
     TCHAR szExt[_MAX_FNAME];
     _tsplitpath(pathToWString(m_CfgPath).c_str(), NULL, NULL, szFileName, szExt);
     if (szExt[0] == '.')
     {
         InitConfigPath(szFileName, &szExt[1]);
     }
     else
     {
         InitConfigPath(szFileName, szExt);
     }
 }
Ejemplo n.º 12
0
CLIB_API const boost::filesystem::path & GetIniPath(boost::filesystem::path & path)
{
    boost::filesystem::path programPath;
    std::string leaf = pathToString(GetProgramPath(programPath).leaf());
    TCHAR szFileName[_MAX_FNAME];
    TCHAR szExt[_MAX_FNAME];
    _tsplitpath(CA2T(leaf.c_str()), NULL, NULL, szFileName, szExt);
    std::_tstring iniName = szFileName;
    iniName += _T(".");
    iniName += INI;
    boost::filesystem::path appFolder;
    path = GetApplicationFolder(appFolder) / stringToPath(iniName);
    return path;
}
Ejemplo n.º 13
0
void CPerfLog::Startup()
{
	if (m_bInitialized)
		return;

	CIni ini(thePrefs.GetConfigFile(), _T("PerfLog"));

	m_eMode = (ELogMode)ini.GetInt(_T("Mode"), None);
	if (m_eMode != None && m_eMode != OneSample && m_eMode != AllSamples)
		m_eMode = None;
	if (m_eMode != None)
	{
		m_eFileFormat = (ELogFileFormat)ini.GetInt(_T("FileFormat"), CSV);

		// set default log file path
		CString strDefFilePath = thePrefs.GetMuleDirectory(EMULE_CONFIGBASEDIR);
		if (m_eFileFormat == CSV)
			strDefFilePath += _T("perflog.csv");
		else
			strDefFilePath += _T("perflog.mrtg");

		m_strFilePath = ini.GetString(_T("File"), strDefFilePath);
		if (m_strFilePath.IsEmpty())
			m_strFilePath = strDefFilePath;

		if (m_eFileFormat == MRTG)
		{
			TCHAR drv[_MAX_DRIVE];
			TCHAR dir[_MAX_DIR];
			TCHAR nam[_MAX_FNAME];
			_tsplitpath(m_strFilePath, drv, dir, nam, NULL);
			m_strFilePath.Empty();

			_tmakepathlimit(m_strMRTGDataFilePath.GetBuffer(MAX_PATH), drv, dir, CString(nam) + _T("_data"), _T("mrtg"));
			m_strMRTGDataFilePath.ReleaseBuffer();

			_tmakepathlimit(m_strMRTGOverheadFilePath.GetBuffer(MAX_PATH), drv, dir, CString(nam) + _T("_overhead"), _T("mrtg"));
			m_strMRTGOverheadFilePath.ReleaseBuffer();
		}

		m_dwInterval = MIN2MS(ini.GetInt(_T("Interval"), 5));
		if ((int)m_dwInterval <= 0)
			m_dwInterval = MIN2MS(5);
	}

	m_bInitialized = true;

	if (m_eMode == OneSample)
		LogSamples();
}
Ejemplo n.º 14
0
BOOL SetCurrentPathToModulePath(HMODULE hModule)
{
	TCHAR szPath[MAX_PATH];
	if(::GetModuleFileName(hModule, szPath, MAX_PATH))
	{
		TCHAR drive[MAX_PATH], dir[MAX_PATH], fname[MAX_PATH], ext[MAX_PATH];
		_tsplitpath(szPath, drive, dir, fname, ext);
		lstrcpy(szPath, drive);
		lstrcat(szPath, dir);

		return ::SetCurrentDirectory(szPath);
	}

	return FALSE;
}
/* 外部ヘルプ1
	@date 2012.09.26 Moca HTMLHELP対応
*/
void CViewCommander::Command_EXTHELP1( void )
{
retry:;
	if( CHelpManager().ExtWinHelpIsSet( &(GetDocument()->m_cDocType.GetDocumentAttribute()) ) == false){
//	if( 0 == wcslen( GetDllShareData().m_Common.m_szExtHelp1 ) ){
		ErrorBeep();
//From Here Sept. 15, 2000 JEPRO
//		[Esc]キーと[x]ボタンでも中止できるように変更
		if( IDYES == ::MYMESSAGEBOX( NULL, MB_YESNOCANCEL | MB_ICONEXCLAMATION | MB_APPLMODAL | MB_TOPMOST, GSTR_APPNAME,
//To Here Sept. 15, 2000
			LS(STR_ERR_CEDITVIEW_CMD01)
		) ){
			/* 共通設定 プロパティシート */
			if( !CEditApp::getInstance()->OpenPropertySheet( ID_PROPCOM_PAGENUM_HELPER ) ){
				return;
			}
			goto retry;
		}
		//	Jun. 15, 2000 genta
		else{
			return;
		}
	}

	CNativeW		cmemCurText;
	const TCHAR*	helpfile = CHelpManager().GetExtWinHelp( &(GetDocument()->m_cDocType.GetDocumentAttribute()) );

	/* 現在カーソル位置単語または選択範囲より検索等のキーを取得 */
	m_pCommanderView->GetCurrentTextForSearch( cmemCurText, false );
	TCHAR path[_MAX_PATH];
	if( _IS_REL_PATH( helpfile ) ){
		// 2003.06.23 Moca 相対パスは実行ファイルからのパス
		// 2007.05.21 ryoji 相対パスは設定ファイルからのパスを優先
		GetInidirOrExedir( path, helpfile );
	}else{
		auto_strcpy( path, helpfile );
	}
	// 2012.09.26 Moca HTMLHELP対応
	TCHAR	szExt[_MAX_EXT];
	_tsplitpath( path, NULL, NULL, NULL, szExt );
	if( 0 == _tcsicmp(szExt, _T(".chi")) || 0 == _tcsicmp(szExt, _T(".chm")) || 0 == _tcsicmp(szExt, _T(".col")) ){
		std::wstring pathw = to_wchar(path);
		Command_EXTHTMLHELP( pathw.c_str(), cmemCurText.GetStringPtr() );
	}else{
		::WinHelp( m_pCommanderView->m_hwndParent, path, HELP_KEY, (ULONG_PTR)cmemCurText.GetStringPtr() );
	}
	return;
}
Ejemplo n.º 16
0
bool ArxLoader::loadLibrary()
{
    TCHAR szPath[_MAX_PATH] = {0}, szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFile[_MAX_FNAME], szExt[_MAX_EXT];
    _tsplitpath( ( LPCTSTR )m_arxFilePath, szDrive, szDir, szFile, szExt ); // 拆分路径

    // 判断扩展名是否为arx
    if( CString( szExt ) != _T( ".arx" ) ) return false;

    bool flag = false; // 默认为加载失败(服务已注册或者无法加载)
    AcRxObject* pSvc;
    if ( !( pSvc = acrxServiceDictionary->at ( ( LPCTSTR )m_serviceName ) ) ) // 服务尚未注册
    {
        flag = acrxDynamicLinker->loadModule ( ( LPCTSTR )m_arxFilePath, 0 );
    }
    return flag;
}
Ejemplo n.º 17
0
BOOL CNewPackingToolDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
	if (!CDocument::OnOpenDocument(lpszPathName))
		return FALSE;

	static CMainFrame*  pFrame = (CMainFrame*)AfxGetMainWnd();

	TCHAR strDir[_MAX_DIR];
	TCHAR strDrv[_MAX_DRIVE];
	TCHAR strFileName[200];
	TCHAR strExt[20];

	_tsplitpath( lpszPathName, strDrv, strDir, strFileName, strExt );

	strupr(strExt);

	if ( strcmp( strExt, ".BIN" ) == 0 || 
		strcmp( strExt, ".BEFF" ) == 0 || 
		strcmp( strExt, ".BEFL" ) == 0 || 
		strcmp( strExt, ".BMHM" ) == 0 || 
		strcmp( strExt, ".BSAD" ) == 0 )
	{
		if ( m_FileMng.AddFile( lpszPathName, "rb" ) )
		{
			pFrame->AddFile(m_FileMng.GetFileName( m_nFileNum ));
			++m_nFileNum;
		}
	}
	else if ( strcmp( strExt, ".DOF" ) == 0 )
	{
		if ( m_FileMng.AddFile( lpszPathName, "dof" ) )
		{
			pFrame->AddFile(m_FileMng.GetFileName( m_nFileNum ));
			++m_nFileNum;
		}
	}
	else
	{
		if ( m_FileMng.AddFile( lpszPathName, "rt" ) )
		{
			pFrame->AddFile(m_FileMng.GetFileName( m_nFileNum ));
			++m_nFileNum;
		}
	}

	return TRUE;
}
Ejemplo n.º 18
0
//
// 从完整路径中分离出文件名
//
CString WINAPI GetName(TCHAR *sFilename, BOOL IsIncludeExt) 
{
	TCHAR sDrive[_MAX_DRIVE];
	TCHAR sDir[_MAX_DIR];
	TCHAR sFname[_MAX_FNAME];
	TCHAR sExt[_MAX_EXT];

	_tsplitpath(sFilename, sDrive, sDir, sFname, sExt);

	CString rVal;
	if(IsIncludeExt)
		rVal.Format(_T("%s%s"), sFname, sExt);
	else 
		rVal.Format(_T("%s"), sFname);

	return rVal;
}
Ejemplo n.º 19
0
//
// 从完整路径中分离出路径
//
CString WINAPI GetPath(TCHAR *sFilename) 
{
	TCHAR sDrive[_MAX_DRIVE];
	TCHAR sDir[_MAX_DIR];
	TCHAR sFname[_MAX_FNAME];
	TCHAR sExt[_MAX_EXT];

	_tsplitpath(sFilename, sDrive, sDir, sFname, sExt);

	CString rVal(CString(sDrive) + CString(sDir));
	int nLen = rVal.GetLength();

	if (rVal.GetAt(nLen-1) != _T('\\'))
		rVal += _T("\\");

	return rVal;
}  
Ejemplo n.º 20
0
/*static*/
std::string 
CSettings::GetConfigFileName() {

	TCHAR szBuf[1024] = {0};
	
	if(GetModuleFileName(NULL, szBuf, sizeof(szBuf))) {
		TCHAR szDrive[8] = {0};
		TCHAR szDir[512] = {0};
		TCHAR szName[128] = {0};
		_tsplitpath( szBuf, szDrive, szDir, szName, NULL);
		std::string strName = szName;
		std::string strDrive = szDrive;
		std::string strDir = szDir;
		return strDrive + strDir + strName + std::string(".ini");
	};
	return std::string("");	
};
Ejemplo n.º 21
0
MMF_IMAGE_TYPE MMFImage::GetFileType(){
	LPTSTR ext = new TCHAR[20];
	//fget file extension 
	_tsplitpath(m_fileName, NULL, NULL , NULL, ext);

	//get file type
	if (_tcsicmp(ext, ".bmp") == 0 ){
		delete [] ext;
		return MMF_BITMAP;
	}
		
	if (_tcsicmp(ext, ".tga") == 0 ){
		delete [] ext;
		return  MMF_TGA;
	}
return MMF_IMAGE_TYPE(-1);
}
Ejemplo n.º 22
0
/**
 * @brief Get module's path component (without filename).
 * @param [in] hModule Module's handle.
 * @param [in,out] path Char table where path is copied.
 * @param [in] size Size of the char table.
 * @return Module's path.
 */
void paths_GetModulePath(HMODULE hModule, LPTSTR path, int size)
{
	TCHAR temp[MAX_PATH + 1] = {0};
	if (GetModuleFileName(hModule, temp, MAX_PATH))
	{
		TCHAR drive[_MAX_DRIVE] = {0};
		TCHAR dir[_MAX_DIR] = {0};
		_tsplitpath(temp, drive, dir, NULL, NULL);
		const int drive_len = _tcslen(drive);
		const int dir_len = _tcslen(dir);
		if (drive_len + dir_len < size)
		{
			_tcsncpy(path, drive, drive_len);
			_tcsncat(path, dir, size - drive_len);
		}
	}
}
Ejemplo n.º 23
0
BOOL CFileEditCtrl::FECOpenFile()
{
	// Set up the CFileDialog and call CFileDialog::DoModal().
	// return TRUE if the user clicked the OK button, return FALSE otherwise
	BOOL bReturnValue = FALSE;
	BOOL bDirectory = TRUE;						// assume user of this class has set the initial directory
	TCHAR lpstrDirectory[_MAX_PATH] = _T("");
	if (m_pCFileDialog->m_ofn.lpstrInitialDir == NULL)	// user has not set the initial directory
	{											// flag it, set initial directory to
		bDirectory = FALSE;						// directory in edit control
		POSITION pos = GetStartPosition();
		if (pos)
			_tcscpy(lpstrDirectory, GetNextPathName(pos));
		m_pCFileDialog->m_ofn.lpstrInitialDir = lpstrDirectory;
	}
	if (m_pCFileDialog->DoModal() == IDOK)		// Start the CFileDialog
	{											// user clicked OK, enter files selected into edit control
		CString szFileSeperator;
#if defined FEC_NORESOURCESTRINGS
		szFileSeperator = (CString)FEC_IDS_SEPERATOR;
#else
		szFileSeperator.LoadString(FEC_IDS_SEPERATOR);
#endif
		ASSERT (_tcslen(szFileSeperator) == 1);	// must be one character only
		szFileSeperator += _T(" ");
		CString szPath;
		POSITION pos = m_pCFileDialog->GetStartPosition();
		if (pos)
			szPath = m_pCFileDialog->GetNextPathName(pos);	// first file has complete path
		while (pos)
		{
			CString szTempPath = m_pCFileDialog->GetNextPathName(pos);
			TCHAR lpstrName[_MAX_PATH];			// remaining files are name and extension only
			TCHAR lpstrExt[_MAX_PATH];
			_tsplitpath(szTempPath, NULL, NULL, lpstrName, lpstrExt);
			szPath += szFileSeperator + lpstrName + lpstrExt;
		}
		SetWindowText (szPath);
		bReturnValue = TRUE;
	}
	if (!bDirectory)							// reset OPENFILENAME
		m_pCFileDialog->m_ofn.lpstrInitialDir = NULL;
	SetFocus();									// ensure focus returns to this control
	return bReturnValue;
}
Ejemplo n.º 24
0
SystemImageList::SystemImageList() {
	//Get the temp directory. This is used to then bring back the system image list
	TCHAR pszTempDir[_MAX_PATH];
	GetTempPath(_MAX_PATH, pszTempDir);
	TCHAR pszDrive[_MAX_DRIVE + 1];
	_tsplitpath(pszTempDir, pszDrive, NULL, NULL, NULL);
	int nLen = _tcslen(pszDrive);
	if (pszDrive[nLen-1] != _T('\\'))
		_tcscat(pszDrive, _T("\\"));

	//Attach to the system image list
	SHFILEINFO sfi;
	HIMAGELIST hSystemImageList = (HIMAGELIST) SHGetFileInfo(pszTempDir, 0, &sfi, sizeof(SHFILEINFO),
															SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
	m_ImageList.Attach(hSystemImageList);
	//auto tmp = m_ImageList.AddIcon((HICON)::LoadImage(GetModuleHandle(NULL), ResourceLoader::getIconPath(_T("Hub.ico")).c_str(), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR | LR_LOADFROMFILE));
	//auto tmp = m_ImageList.AddIcon((HICON)::LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAGNET), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
}
Ejemplo n.º 25
0
void Initialize(HMODULE hModule)
{
	TCHAR path[MAX_PATH] = {0}, fname[MAX_PATH] = {0};
	DWORD nameLen = GetModuleFileName(NULL, path, MAX_PATH);
	path[nameLen] = 0;
	_tsplitpath(path, NULL, NULL, fname, NULL);
	ATLTRACE(TEXT("TVCUSACore path:%s fname:%s"), path, fname);

	if (_tcscmp(fname, TEXT("Special")) != 0)
	{
		// 自卸载,线程句柄无法CloseHandle
		::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)FreeLibrary, (LPVOID)hModule, 0, NULL);
	}
	else
	{
		::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)HookThread, NULL, 0, NULL);
	}
}
Ejemplo n.º 26
0
inline CString __getappdir(CString& strFileName)
{
	_TCHAR path_buffer[_MAX_PATH];
	_TCHAR drive[_MAX_DRIVE];
	_TCHAR dir[_MAX_DIR];
	_TCHAR fname[_MAX_FNAME];
	_TCHAR ext[_MAX_EXT];
	
	GetModuleFileName(NULL, path_buffer, _MAX_PATH);
	_tsplitpath( path_buffer, drive, dir, fname, ext );

	strFileName = fname;
	strFileName += ext;

	CString strDir = drive;
	strDir += dir;
	return strDir;
};
Ejemplo n.º 27
0
void STEPluginLoad(HWND hWnd) {
	STEP_hWnd = hWnd;

	CSuperTagEditorApp	*pApp = (CSuperTagEditorApp *)AfxGetApp();
	CString strINI;
	{
		wchar_t*	szName = pApp->MakeFileName(L"ini");
		wchar_t   drive[_MAX_DRIVE];
		wchar_t   dir[_MAX_DIR];
		wchar_t   buff[_MAX_PATH] = {'\0'};
		_tsplitpath(szName, drive, dir, NULL, NULL);
		_tmakepath_s(buff,_MAX_PATH, drive, dir, L"Plugin", L"ini");
		strINI = buff;
		BOOL isExists = Profile_Initialize(strINI, TRUE);
		Profile_Free();
		if (!isExists) {
			_tmakepath_s(buff,_MAX_PATH, drive, dir, L"DefaultPlugin", L"ini");
			strINI = buff;
		}
		delete szName;
	}

	CString strSection;
	int i; for ( i=0;;i++) {
		wchar_t   buff[_MAX_PATH] = {'\0'};
		strSection.Format(L"Load%03d", i);
		Profile_Initialize(strINI, TRUE);
		Profile_GetString(strSection, L"Path", L"", buff, sizeof(buff), strINI);
		Profile_Free();
		if (wcslen(buff) == 0) {
			break;
		}
		PSTEPlugin pPlugin = STEPluginLoadFile(buff);
		if (pPlugin == NULL) {
			//pPlugin->bUse = false;
			MessageBox(hWnd, CString(L"プラグイン(") + buff + L")の読み込みに失敗しました", L"プラグインエラー", MB_ICONSTOP|MB_OK|MB_TOPMOST);
			continue;
		}
		Profile_Initialize(strINI, TRUE);
		pPlugin->bUse = Profile_GetInt(strSection, L"Use", 1, strINI) ? true : false;
		Profile_Free();
	}
	STEP_wndToolBar->UpdatePluginButton();
}
Ejemplo n.º 28
0
INT_PTR CMsnProto::SetAvatar(WPARAM, LPARAM lParam)
{
	TCHAR* szFileName = (TCHAR*)lParam;

	TCHAR tFileName[MAX_PATH];
	MSN_GetAvatarFileName(NULL, tFileName, _countof(tFileName), NULL);
	_tremove(tFileName);

	if (szFileName == NULL) {
		delSetting("PictObject");
		delSetting("AvatarHash");
		ForkThread(&CMsnProto::msn_storeAvatarThread, NULL);
	}
	else {
		int fileId = _topen(szFileName, _O_RDONLY | _O_BINARY, _S_IREAD);
		if (fileId < 0) return 1;

		size_t dwPngSize = _filelengthi64(fileId);
		unsigned char* pData = (unsigned char*)mir_alloc(dwPngSize);
		if (pData == NULL) {
			_close(fileId);
			return 2;
		}

		_read(fileId, pData, (unsigned)dwPngSize);
		_close(fileId);

		TCHAR drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
		_tsplitpath(szFileName, drive, dir, fname, ext);

		MSN_SetMyAvatar(fname, pData, dwPngSize);

		StoreAvatarData* par = (StoreAvatarData*)mir_alloc(sizeof(StoreAvatarData));
		par->szName = mir_tstrdup(fname);
		par->data = pData;
		par->dataSize = dwPngSize;
		par->szMimeType = "image/png";

		ForkThread(&CMsnProto::msn_storeAvatarThread, par);
	}

	MSN_SetServerStatus(m_iStatus);
	return 0;
}
Ejemplo n.º 29
0
HRESULT CHdrPropSheet::CheckFileType()
{
	TCHAR ext[_MAX_EXT];
	_tsplitpath(m_szPath, NULL, NULL, NULL, ext);

	TCHAR exts[1024];
	LoadSetting(_T("exts"), exts, lengthof(exts), DEFAULT_EXTS);

	LPCTSTR separator = _T(";");
	LPTSTR tok = _tcstok(exts, separator);
	while (tok != NULL) {
		if (::lstrcmpi(tok, ext) == 0) {
			return S_OK;
		}
		tok = _tcstok(NULL, separator);
	}

	return E_FAIL;
}
Ejemplo n.º 30
0
const ModuleFileInfomations& GetModuleFileInformations()
{
	static ModuleFileInfomations __s_mi;
	static BOOL bLoad = FALSE;
	
	if(!bLoad)
	{
		// Get application's full path.
		
		::GetModuleFileName(NULL, __s_mi.strFullPath.GetBufferSetLength(MAX_PATH + 1), MAX_PATH);
		__s_mi.strFullPath.ReleaseBuffer();
		
		// Break full path into seperate components.
		_splitpath(
			__s_mi.strFullPath, 
			__s_mi.strDrive.GetBufferSetLength(_MAX_DRIVE + 1),
			__s_mi.strDir.GetBufferSetLength(_MAX_DIR + 1),
			__s_mi.strName.GetBufferSetLength(_MAX_FNAME + 1),
			__s_mi.strExt.GetBufferSetLength(_MAX_EXT + 1));
		__s_mi.strDrive.ReleaseBuffer();
		__s_mi.strDir.ReleaseBuffer();
		__s_mi.strName.ReleaseBuffer();
		__s_mi.strExt.ReleaseBuffer();
		
		
		TCHAR   sDrive[_MAX_DRIVE];   
		TCHAR   sDir[_MAX_DIR];   
		TCHAR   sFilename[_MAX_FNAME],Filename[_MAX_FNAME];   
		TCHAR   sExt[_MAX_EXT];   
		GetModuleFileName(AfxGetInstanceHandle(),   Filename,   _MAX_PATH);   
		_tsplitpath(Filename,   sDrive,   sDir,   sFilename,   sExt);   
		CString   homeDir(CString(sDrive)   +   CString(sDir));   
		int   nLen   =   homeDir.GetLength();   
		if(homeDir.GetAt(nLen-1)   !=   _T('\\'))   
			homeDir   +=   _T('\\');   
		
		__s_mi.strPath = homeDir;
		
		bLoad = TRUE;
	}
	
	return __s_mi;
}