void CConfig::AutoRun_RegKey(CString AutoRun) { if (AutoRun==_T("1")) { TCHAR path[MAX_PATH]; CString keyStr; CString fileName; HKEY hRegKey; GetModuleFileName(NULL,path,sizeof(path)); CString strPath = path; keyStr =_T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"); if(RegOpenKey(HKEY_LOCAL_MACHINE,keyStr,&hRegKey) != ERROR_SUCCESS) return ; else { _wsplitpath(strPath.GetBuffer(0),NULL,NULL,fileName.GetBufferSetLength(MAX_PATH+1),NULL); if(!::RegSetValueEx(hRegKey, fileName, 0, REG_SZ, (CONST BYTE *)strPath.GetBuffer(0), strPath.GetLength()*2)!= ERROR_SUCCESS) return; strPath.ReleaseBuffer(); } } else { TCHAR path[MAX_PATH]; CString str; HKEY hRegKey; BOOL bResult; GetModuleFileName(NULL,path,sizeof(path)); CString strPath = path; str=_T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"); if(RegOpenKey(HKEY_LOCAL_MACHINE, str, &hRegKey) != ERROR_SUCCESS) bResult=FALSE; else { _wsplitpath(strPath.GetBuffer(0),NULL,NULL,str.GetBufferSetLength(MAX_PATH+1),NULL); strPath.ReleaseBuffer(); str.ReleaseBuffer(); if(::RegDeleteValue(hRegKey, str) != ERROR_SUCCESS) bResult=FALSE; else bResult=TRUE; strPath.ReleaseBuffer(); } } }
//---------------------------------------------------------------------------------------- bool IsDataSectionNeeded( const WCHAR* pModuleName ) { // Check parameters if( pModuleName == 0 ) { return false; } WCHAR curDir[MAX_PATH] = L""; GetCurrentDirectoryW(MAX_PATH-1, curDir); wcscat(curDir, L"\\"); // Extract the module name WCHAR drive[_MAX_DRIVE] = L""; WCHAR dir[_MAX_DIR]=L""; WCHAR fileName[_MAX_FNAME]=L""; _wsplitpath( pModuleName, drive, dir, fileName, 0 ); WCHAR modulePath[_MAX_DRIVE + _MAX_DIR]=L""; wcscat(modulePath, drive); wcscat(modulePath, dir); // Compare the name with the list of known names and decide if( wcsicmp( curDir, modulePath ) == 0 ) { return true; } else if( wcsicmp( fileName, L"ntdll" ) == 0 ) { return true; } return false; }
static BOOL CreateUpperDirectory(LPCTSTR filename) { TCHAR drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; TCHAR path[_MAX_PATH]; _wsplitpath(filename, drive, dir, fname, ext); int len = _tcslen(dir); if (len <= 1) { // "/" return TRUE; } dir[len - 1] = _T('\0'); _stprintf(path, _T("%s%s"), drive, dir); if (!CreateUpperDirectory(path)) { return FALSE; } if (!CreateDirectory(path, NULL)) { DWORD error = GetLastError(); switch (error) { case ERROR_ALREADY_EXISTS: return TRUE; default: return FALSE; } } return TRUE; }
LPCTSTR CLogFile::GetLogFileName() { if (file_type != LOGFILE_ONE_FILE) { WCHAR drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; _wsplitpath(log_file_name, drive, dir, fname, ext); switch (file_type) { case LOGFILE_PER_YEAR: _stprintf(temp_file_name, TEXT("%s%s%s_%04d"), drive, dir, fname, last_date.wYear); break; case LOGFILE_PER_MONTH: _stprintf(temp_file_name, TEXT("%s%s%s_%04d_%02d"), drive, dir, fname, last_date.wYear, last_date.wMonth); break; case LOGFILE_PER_DAY: _stprintf(temp_file_name, TEXT("%s%s%s_%04d_%02d_%02d"), drive, dir, fname, last_date.wYear, last_date.wMonth, last_date.wDay); break; case LOGFILE_PER_HOUR: _stprintf(temp_file_name, TEXT("%s%s%s_%04d_%02d_%02d.%02d"), drive, dir, fname, last_date.wYear, last_date.wMonth, last_date.wDay, last_date.wHour); break; case LOGFILE_PER_TENMIN: _stprintf(temp_file_name, TEXT("%s%s%s_%04d_%02d_%02d.%02d.%1d0"), drive, dir, fname, last_date.wYear, last_date.wMonth, last_date.wDay, last_date.wHour, last_date.wMinute / 10); break; } _stprintf(temp_file_name + _tcslen(temp_file_name), TEXT("%s"), ext); return temp_file_name; } else return log_file_name; }
void setWindowFileName(std::wstring fileName) { wchar_t drive[_MAX_DRIVE],dir[_MAX_DIR],fname[_MAX_FNAME],ext[_MAX_EXT]; _wsplitpath(fileName.c_str(), drive, dir, fname, ext); std::wstring windowTitle = std::wstring(fname) + std::wstring(L" - ") + std::wstring(mainWindowTitleW); SetWindowTextW(hwnd, windowTitle.c_str()); }
//--- IOS_ERROR_CODE IOSFileExtractW( const WCHAR * pszFullFileName, WCHAR * pszFileName, uint uicchBufferLen ) { #if defined(_UNICODE) return ::IOSFileExtract( pszFullFileName, pszFileName, uicchBufferLen ); #else if ( pszFullFileName && pszFileName ) { if ( g_bUnicodePlatform ) { CAPointer<WCHAR> fFile = new WCHAR[_MAX_FNAME]; CAPointer<WCHAR> fExt = new WCHAR[_MAX_EXT]; // выделить диск и каталог _wsplitpath( pszFullFileName, NULL, NULL, fFile, fExt); if ( uint(wcslen(fFile) + wcslen(fExt)) < uicchBufferLen ) { wcscpy( pszFileName, fFile ); pszFileName = _wcsninc(pszFileName, wcslen(pszFileName) ); wcscpy( pszFileName, fExt ); } else return IOS_ERR_OUT_OF_MEMORY; return IOS_ERR_OK; } else { CPathStrA pConverted(pszFullFileName); CPathStrA pBuffer( (int)uicchBufferLen * 2 ); IOS_ERROR_CODE nError = ::IOSFileExtract( pConverted, pBuffer, uicchBufferLen * 2 ); wcsncpy( pszFileName, CPathStrW(pBuffer), uicchBufferLen ); return nError; } } return IOS_ERR_INVALID_FILE_NAME; #endif }
void CNetTrafficMonitorDlg::OnSelfStarting() { TCHAR szFileFullPath[MAX_PATH] = { 0 }; TCHAR szFileName[_MAX_FNAME] = { 0 }; GetModuleFileName(NULL, szFileFullPath, MAX_PATH); // 得到程序自身的全路径 _wsplitpath(szFileFullPath, NULL, NULL, szFileName, NULL); // 获得程序名 HKEY hKey; LPCTSTR lpRun = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"); // 找到系统的启动项 if (ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER, lpRun, &hKey)) // 打开启动项Key { if (m_bSelfStarting) { if (ERROR_SUCCESS == RegDeleteValue(hKey, szFileName)) // 删除一个子Key { m_bSelfStarting = FALSE; } } else { if (ERROR_SUCCESS == RegSetValueEx(hKey, szFileName, 0, REG_SZ, (LPBYTE)szFileFullPath, (lstrlen(szFileFullPath) + 1) * sizeof(TCHAR))) // 添加一个子Key,并设置值 { m_bSelfStarting = TRUE; } } } RegCloseKey(hKey); // 关闭注册表 }
void getPath() { wchar_t szFullPath[MAX_PATH]; wchar_t drive[_MAX_DRIVE]; wchar_t dir[_MAX_DIR]; ZeroMemory(_szPath, sizeof(wchar_t)*MAX_PATH); ZeroMemory(_szRascalDll, sizeof(wchar_t)*MAX_PATH); ZeroMemory(_szX264Dll, sizeof(wchar_t)*MAX_PATH); ZeroMemory(_szX264Dest, sizeof(wchar_t)*MAX_PATH); ZeroMemory(_szX264Cfg, sizeof(wchar_t)*MAX_PATH); ZeroMemory(szFullPath, sizeof(wchar_t)*MAX_PATH); GetModuleFileName(NULL, szFullPath, MAX_PATH); _wsplitpath(szFullPath, drive, dir, NULL, NULL); StringCchPrintf(_szPath, sizeof(wchar_t)*MAX_PATH, L"%s%s",drive, dir); StringCchPrintf(_szRascalDll, sizeof(wchar_t)*MAX_PATH, L"%sRascal.dll", _szPath); StringCchPrintf(_szX264Cfg, sizeof(wchar_t)*MAX_PATH, L"%sx264cfg.dat", _szPath); StringCchPrintf(_szX264Dll, sizeof(wchar_t)*MAX_PATH, L"%sx264vfw.dll", _szPath); StringCchPrintf(_szX264Dest, sizeof(wchar_t)*MAX_PATH, L"%sx264vfw.dll", L"C:\\Windows\\System32\\"); }
int EmdMaxExporter::DoExport( const MCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts/* =FALSE */, DWORD options/* =0 */ ) { typedef int(*ExportFunc)( const MCHAR*, ExpInterface*, Interface*, BOOL, DWORD ); // Get full path of .dll which shares same path with .dle TCHAR binFullPath[_MAX_PATH]; TCHAR szDrive[_MAX_DRIVE] = { 0 }, szDir[_MAX_DIR] = { 0 }, szFNAME[_MAX_FNAME] = { 0 }, szExt[_MAX_EXT] = { 0 }; GetModuleFileName( hInstance, binFullPath, sizeof(binFullPath) ); #ifdef UNICODE _wsplitpath( binFullPath, szDrive, szDir, NULL, NULL ); #else _splitpath( binFullPath, szDrive, szDir, NULL, NULL ); #endif TCHAR dllFullPath[_MAX_PATH] = { 0 }; #ifdef UNICODE wcscat( dllFullPath, szDrive ); wcscat( dllFullPath, szDir ); #ifdef _DEBUG wcscat( dllFullPath, _T("EmdExporterMax2011_d.dll") ); #else wcscat( dllFullPath, _T("EmdExporterMax2011.dll") ); #endif // #ifdef DEBUG #else strcat( dllFullPath, szDrive ); strcat( dllFullPath, szDir ); #ifdef _DEBUG strcat( dllFullPath, _T("EmdExporterMax2011_d.dll") ); #else strcat( dllFullPath, _T("EmdExporterMax2011.dll") ); #endif // #ifdef DEBUG #endif // #ifdef UNICODE // Load exporter dll here and do the export HINSTANCE hDLL; hDLL = LoadLibrary( dllFullPath ); ExportFunc exportFunc = (ExportFunc)GetProcAddress( hDLL, "DoExport" ); // well, we don't have a DoExport method... if ( !exportFunc ) return FALSE; BOOL result = (*exportFunc)( name, ei, i, suppressPrompts, options ); FreeLibrary( hDLL ); return result; }
void CDriveIndex::FindInJournal(wstring &strQuery, const WCHAR* &szQueryLower, DWORDLONG QueryFilter, DWORDLONG QueryLength, wstring * strQueryPath, vector<T> &rgJournalIndex, vector<SearchResultFile> &rgsrfResults, unsigned int iOffset, BOOL bEnhancedSearch, int maxResults, int &nResults) { for(unsigned int j = 0; j != rgJournalIndex.size(); j++) { IndexedFile* i = (IndexedFile*)&rgJournalIndex[j]; DWORDLONG Length = (i->Filter & 0xE000000000000000ui64) >> 61ui64; //Bits 61-63 for storing lengths up to 8 DWORDLONG Filter = i->Filter & 0x1FFFFFFFFFFFFFFFui64; //All but the last 3 bits if((Filter & QueryFilter) == QueryFilter && QueryLength <= Length) { USNEntry file = FRNToName(i->Index); float MatchQuality; if(bEnhancedSearch) MatchQuality = FuzzySearch(file.Name, strQuery); else { wstring szLower(file.Name); for(unsigned int j = 0; j != szLower.length(); j++) szLower[j] = tolower(szLower[j]); MatchQuality = szLower.find(strQuery) != -1; } if(MatchQuality > 0.6f) { nResults++; if(maxResults != -1 && nResults > maxResults) { nResults = -1; break; } SearchResultFile srf; srf.Filename = file.Name; srf.Path.reserve(MAX_PATH); Get(i->Index, &srf.Path); BOOL bFound = true; if(strQueryPath != NULL) { wstring strPathLower(srf.Path); for(unsigned int j = 0; j != strPathLower.length(); j++) strPathLower[j] = tolower(strPathLower[j]); bFound = strPathLower.find(*strQueryPath) != -1; } if(bFound) { //split path WCHAR szDrive[_MAX_DRIVE]; WCHAR szPath[_MAX_PATH]; WCHAR szName[_MAX_FNAME]; WCHAR szExt[_MAX_EXT]; _wsplitpath(srf.Path.c_str(), szDrive, szPath, szName, szExt); srf.Path = wstring(szDrive) + wstring(szPath); srf.Filter = i->Filter; srf.MatchQuality = MatchQuality; rgsrfResults.insert(rgsrfResults.end(), srf); } } } } }
int main(int ac,char *av[]) { int rc = 0; SET_THREAD_NAME("bootstrap"); // Disable default invalid crt parameter handling DISABLE_CRT_INVALID_PARAMETER_HANDLER(); // Request the highest possible time-interval accuracy... timeBeginPeriod( 1 ); // (one millisecond time interval accuracy) // If we're being debugged, then let the debugger // catch the exception. Otherwise, let our exception // handler catch it... if (!IsDebuggerPresent()) { if (!sysblk.daemon_mode) // (normal panel mode?) { EnableMenuItem( GetSystemMenu( FindConsoleHandle(), FALSE ), SC_CLOSE, MF_BYCOMMAND | MF_GRAYED ); } if (1 && (g_hDbgHelpDll = LoadLibrary(_T("DbgHelp.dll"))) && (g_pfnMiniDumpWriteDumpFunc = (MINIDUMPWRITEDUMPFUNC*) GetProcAddress( g_hDbgHelpDll, _T("MiniDumpWriteDump"))) ) { GetModuleFileNameW( NULL, g_wszHercPath, _countof( g_wszHercPath ) ); _wsplitpath( g_wszHercPath, g_wszHercDrive, g_wszHercDir, NULL, NULL ); } SetUnhandledExceptionFilter( HerculesUnhandledExceptionFilter ); SetErrorMode( SEM_NOGPFAULTERRORBOX ); } rc = impl(ac,av); // (Hercules, do your thing!) // Each call to "timeBeginPeriod" must be matched with a call to "timeEndPeriod" timeEndPeriod( 1 ); // (no longer care about accurate time intervals) if (!IsDebuggerPresent()) { if (!sysblk.daemon_mode) // (normal panel mode?) { EnableMenuItem( GetSystemMenu( FindConsoleHandle(), FALSE ), SC_CLOSE, MF_BYCOMMAND | MF_ENABLED ); } } return rc; }
bool ExplorerCmd::EvaluateOption(LPCTSTR option) { String opt_str; // Remove quote characters, as they are evaluated at this point. for(; *option; ++option) if (*option != '"') opt_str += *option; option = opt_str; if (option[0] == '/') { ++option; // option /e for windows in explorer mode if (!_tcsicmp(option, TEXT("e"))) _flags |= OWM_EXPLORE; // option /root for rooted explorer windows else if (!_tcsicmp(option, TEXT("root"))) _flags |= OWM_ROOTED; // non-standard options: /mdi, /sdi else if (!_tcsicmp(option, TEXT("mdi"))) _mdi = true; else if (!_tcsicmp(option, TEXT("sdi"))) _mdi = false; else if (!_tcsicmp(option, TEXT("n"))) { // Do nothing } else if (!_tcsicmp(option, TEXT("select"))) { SelectOpt = TRUE; } else return false; } else { if (!_path.empty()) return false; if((SelectOpt == TRUE) && (PathFileExists(option))) { WCHAR szDir[MAX_PATH]; _wsplitpath(option, szPath, szDir, NULL, NULL); wcscat(szPath, szDir); PathRemoveBackslash(szPath); _path = szPath; SelectOpt = FALSE; } else _path = opt_str; } return true; }
HeapProfiler::HeapProfiler() { char fileName[MAX_PATH]; wchar_t processName[MAX_PATH]; wchar_t baseName[MAX_PATH]; GetModuleFileName(NULL, processName, sizeof(processName)); _wsplitpath(processName, NULL, NULL, baseName, NULL); sprintf(fileName, "winheaptrack.%S.%d", baseName, GetCurrentProcessId()); printf("Saving data to %s...\n", fileName); data.output = fopen(fileName, "w+b"); fprintf(data.output, "X %s\n", processName); }
void CFilename::SplitPath(const CStdStringW& path) { _wsplitpath(path.c_str(), drive.GetBuffer(MAX_PATH), dir.GetBuffer(MAX_PATH), fname.GetBuffer(MAX_PATH), ext.GetBuffer(MAX_PATH)); drive.ReleaseBuffer(); dir.ReleaseBuffer(); fname.ReleaseBuffer(); ext.ReleaseBuffer(); }
void PathString::SplitPath(PathString *drive, PathString *dir, PathString *fname, PathString *ext) const //------------------------------------------------------------------------------------------------------ { wchar_t tempDrive[_MAX_DRIVE]; wchar_t tempDir[_MAX_DIR]; wchar_t tempFname[_MAX_FNAME]; wchar_t tempExt[_MAX_EXT]; _wsplitpath(path.c_str(), tempDrive, tempDir, tempFname, tempExt); if(drive) *drive = mpt::PathString::FromNative(tempDrive); if(dir) *dir = mpt::PathString::FromNative(tempDir); if(fname) *fname = mpt::PathString::FromNative(tempFname); if(ext) *ext = mpt::PathString::FromNative(tempExt); }
BOOL CAddCopyrightInfoDlg::MyFindFile(TCHAR* path, char* copyright) { WIN32_FIND_DATA findFileData; TCHAR szFind[MAX_PATH] = {0}; TCHAR szFindTemp[MAX_PATH] = {0}; wcsncpy_s(szFind,path,wcslen(path)); wcsncat_s(szFind,L"\\*.*",4); HANDLE h = FindFirstFile(szFind, &findFileData); if(INVALID_HANDLE_VALUE==h) { MessageBox(_T("请检查路径是否正确")); return FALSE; } while(true) { if(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if(findFileData.cFileName[0]!='.') { wcsncpy_s(szFindTemp,path,wcslen(path)); wcsncat_s(szFindTemp,L"\\",1); wcsncat_s(szFindTemp,findFileData.cFileName,sizeof(findFileData.cFileName)); MyFindFile(szFindTemp, copyright); } } else { TCHAR exName[_MAX_EXT]; _wsplitpath(findFileData.cFileName, NULL, NULL, NULL, exName); if(wcscmp(exName,_T(".cs"))==0)//只有是.cs文件的才写 { TCHAR filePath[MAX_PATH]; wcsncpy_s(filePath,path,wcslen(path)); wcsncat_s(filePath,L"\\",1); wcsncat_s(filePath,findFileData.cFileName,sizeof(findFileData.cFileName)); TCHAR fileName[MAX_PATH]; wcsncpy_s(fileName, filePath, wcslen(filePath)-3);//去除.cs wcsncat_s(fileName,L".bak",4); CopyFile(filePath,fileName,TRUE);//备份文件 WriteCopyright(filePath, fileName, copyright);//写版权信息 } } if(!FindNextFile(h,&findFileData)) break; } FindClose(h); return TRUE; }
AppOctStrmContent::AppOctStrmContent(const MailString file_name) : _file_name(file_name) { TCHAR drive[_MAX_DRIVE]; TCHAR direc[_MAX_DIR]; TCHAR fname[_MAX_FNAME]; TCHAR ext[_MAX_EXT]; #ifdef _UNICODE _wsplitpath(file_name.c_str(), drive, direc, fname, ext); #else _splitpath(file_name.c_str(), drive, direc, fname, ext); #endif _name = fname; _name += ext; }
///////////////////////////////////////////////////////////////////////////// // 获取插件路径 ///////////////////////////////////////////////////////////////////////////// CString GetPlugInRootPath() { //获取平台路径 TCHAR szFullPath[MAX_PATH]; TCHAR szdrive[_MAX_DRIVE]; TCHAR szdir[_MAX_DIR]; ::GetModuleFileName(GetDllInstance(), szFullPath, MAX_PATH); #ifdef _UNICODE _wsplitpath(szFullPath, szdrive, szdir, NULL, NULL); #else _splitpath(szFullPath, szdrive, szdir, NULL, NULL); #endif CString szPath; szPath.Format(_T("%s%s"), szdrive, szdir); return szPath; }
void CLoadingScreen::UpdateSessionName( ) { // If connecting to a remote server, set our mission descriptor to // the ip we're connecting to. if( g_pClientConnectionMgr->IsConnectedToRemoteServer( )) { // Make a loading string using the IP to be joined. wchar_t szLoadingString[256]; // LTSNPrintF( szSession, LTARRAYSIZE(szSession), L"%s", g_pClientConnectionMgr->GetStartGameRequest().m_pNetSession->m_sName ); if ( !LTStrEmpty(g_pClientConnectionMgr->GetServerName())) { LTSNPrintF( szLoadingString, LTARRAYSIZE(szLoadingString), L"%s: %s", LoadString("IDS_CONNECTING_TO_SERVER"), g_pClientConnectionMgr->GetServerName() ); } else { LTSNPrintF( szLoadingString, LTARRAYSIZE(szLoadingString), L"%s", LoadString("IDS_CONNECTING_TO_SERVER")); } m_MissionName.SetFont(g_CurrentLayout.m_sLevelFont); m_MissionName.SetString(szLoadingString); LTSNPrintF( szLoadingString, LTARRAYSIZE(szLoadingString), L" (%S)", g_pClientConnectionMgr->GetStartGameRequest( ).m_TCPAddress ); m_LevelName.SetString(szLoadingString); } // Local game, set the mission descriptor to the level name. else { m_MissionName.SetFont(g_CurrentLayout.m_sTitleFont); if (g_pGameClientShell->IsRunningPerformanceTest()) { m_MissionName.SetString(LoadString( "IDS_TITLE_PERFORMANCE_TEST" )); m_LevelName.SetString(L""); } else { m_MissionName.SetString(LoadString( "IDS_CUSTOM_LEVEL" )); // Split the worldname up into parts so we can get the load string. wchar_t szWorldTitle[MAX_PATH] = L""; _wsplitpath( MPA2W(g_pMissionMgr->GetCurrentWorldName( )).c_str(), NULL, NULL, szWorldTitle, NULL ); m_LevelName.SetString(szWorldTitle); } } }
SIZE_T ApsGetBaseName( __in PWSTR FullPath, __out PWSTR BaseName, __in SIZE_T Length ) { WCHAR Base[MAX_PATH]; WCHAR Extent[32]; _wsplitpath(FullPath, NULL, NULL, Base, Extent); if (Extent[0] != 0) { wcscat(Base, Extent); } wcscpy_s(BaseName, Length, Base); return wcslen(BaseName); }
// --- WCHAR *CAvpFileFindW::GetFileTitle() const { CAPointer<WCHAR> strFullName = GetFileName(); CPathStrW strResult(_MAX_PATH); #if defined(_UNICODE) _tsplitpath(strFullName, NULL, NULL, strResult, NULL); #else if ( g_bUnicodePlatform ) _wsplitpath(strFullName, NULL, NULL, strResult, NULL); else { CAPointer<char> pConverted =::UnicodeToMbcs( strFullName ); CPathStr strAResult(_MAX_PATH); _splitpath(pConverted, NULL, NULL, strAResult, NULL); ::MbcsToUnicode( strAResult, strResult, _MAX_PATH ); } #endif return strResult.Relinquish(); }
static BOOL IsDataSectionNeeded( const WCHAR* pwszModuleName ) { BOOL bNeeded = FALSE; _ASSERTE( pwszModuleName ); _wsplitpath( pwszModuleName, NULL, g_wszFileDir, g_wszFileName, NULL ); if ( _wcsicmp( g_wszFileName, L"ntdll" ) == 0 ) { bNeeded = TRUE; } else if ( _wcsicmp( g_wszFileDir, g_wszHercDir ) == 0 ) { bNeeded = TRUE; } return bNeeded; }
wxString GetZipFileName (const wxString & suOriginName, ubyte4 uiArchive) { wchar_t extension[30]; if (uiArchive < 100) wsprintf (extension, L"%.2d", uiArchive); else wsprintf (extension, L"%d", uiArchive); wxString sName = suOriginName; wchar_t fileName[MAX_PATH]; _wsplitpath (sName.c_str (), NULL, NULL, fileName, NULL); sName = fileName; sName += _(".z"); sName += extension; return sName; }
static void GetRecordingPath(WCHAR* szPath) { WCHAR szDrive[_MAX_PATH]; WCHAR szDirectory[_MAX_PATH]; WCHAR szFilename[_MAX_PATH]; WCHAR szExt[_MAX_PATH]; szDrive[0] = '\0'; szDirectory[0] = '\0'; szFilename[0] = '\0'; szExt[0] = '\0'; _wsplitpath(szPath, szDrive, szDirectory, szFilename, szExt); if (szDrive[0] == '\0' && szDirectory[0] == '\0') { WCHAR szTmpPath[_MAX_PATH]; wcscpy(szTmpPath, L"inp\\"); wcsncpy(szTmpPath + wcslen(szTmpPath), szPath, _MAX_PATH - wcslen(szTmpPath)); szTmpPath[_MAX_PATH-1] = '\0'; wcscpy(szPath, szTmpPath); } }
std::string FileUtils::Dirname(std::string path) { wchar_t pathBuffer[_MAX_PATH]; wchar_t drive[_MAX_DRIVE]; wchar_t dir[_MAX_DIR]; wchar_t fname[_MAX_FNAME]; wchar_t ext[_MAX_EXT]; std::wstring widePath = UTILS_NS::UTF8ToWide(path); wcsncpy(pathBuffer, widePath.c_str(), MAX_PATH - 1); pathBuffer[MAX_PATH - 1] = '\0'; _wsplitpath(pathBuffer, drive, dir, fname, ext); if (dir[wcslen(dir)-1] == '\\') dir[wcslen(dir)-1] = '\0'; std::wstring dirname = drive; dirname += std::wstring(dir); return UTILS_NS::WideToUTF8(dirname); }
void WaMetascanEventHandler::_breakRestIP( std::wstring& rest_ip, std::wstring& url, std::wstring& other ) { wchar_t p_directory[_MAX_DIR]; wchar_t p_filename[_MAX_FNAME]; _wsplitpath( rest_ip.c_str(), NULL, p_directory, p_filename, NULL ); std::wstring s_temp = p_directory; other = p_filename; size_t i = s_temp.length() - 1; for ( ; i > 0 ; i-- ) { if ( s_temp[i] == L':') break; } if ( i == 0 ) url = s_temp.substr( 0, s_temp.length() - 1 ); else url = s_temp.substr( 0, i ); }
/* * Gets the pointer to the error file. * * <p>The error file will only be created, if create != 0.</p> * * <p>The error file has the name <executable file name>-error.log and is * created in the same directory as the executable file. If this fails, * the error file is created in the directory designated for temporary files. * </p> * @param create specifies, if the error file should be created (create != 0) * * @return the pointer to the open error file or NULL, if no error file is * open or can be created */ FILE* getErrorFile( int create ) { const wchar_t* MODE = L"w"; const wchar_t* BASEPOSTFIX = L"-error"; const wchar_t* EXTENSION = L".log"; static FILE* ferr = NULL; wchar_t fname[ _MAX_PATH ]; wchar_t drive[ _MAX_DRIVE ]; wchar_t dir[ _MAX_PATH ]; wchar_t base[ _MAX_FNAME ]; wchar_t newbase[ _MAX_FNAME ]; wchar_t ext[ _MAX_EXT ]; if ( ferr == NULL && create ) { /* get the absolute path of the executable file */ if ( GetModuleFileNameW( NULL, fname, MY_SIZE( fname ) ) ) { /* create error file in the directory of the executable file */ _wsplitpath( fname, drive, dir, base, ext ); wcscpy( newbase, base ); wcscat( newbase, BASEPOSTFIX ); _wmakepath( fname, drive, dir, newbase, EXTENSION ); ferr = _wfopen( fname, MODE ); if ( ferr == NULL ) { /* create error file in the temp directory */ GetTempPathW(MY_SIZE( fname ), fname ); wcscat( fname, newbase ); wcscat( fname, EXTENSION ); ferr = _wfopen( fname, MODE ); } } } return ferr; }
void DisplayFile(wchar_t* szFile, BOOL isFile, ULONG DumpFilter, wchar_t* szObjName, strPassBackFn pDisplayString) { // Open the emit scope WCHAR szScope[1024]; char szString[1024]; if (isFile) { wcscpy(szScope, L"file:"); wcscat(szScope, szFile); } else wcscpy(szScope, szFile); // print bar that separates different files pDisplayString("////////////////////////////////////////////////////////////////\n"); wchar_t rcFname[_MAX_FNAME], rcExt[_MAX_EXT]; _wsplitpath(szFile, 0, 0, rcFname, rcExt); sprintf(szString,"\nFile %S%S: \n",rcFname, rcExt); pDisplayString(szString); if (DumpFilter & MDInfo::dumpValidate) { if (!_wcsicmp(rcExt, OBJ_EXT_W) || !_wcsicmp(rcExt, LIB_EXT_W)) g_ValModuleType = ValidatorModuleTypeObj; else g_ValModuleType = ValidatorModuleTypePE; } if (!_wcsicmp(rcExt, LIB_EXT_W)) DisplayArchive(szFile, DumpFilter, szObjName, pDisplayString); else { MDInfo metaDataInfo(g_pDisp, szScope, pDisplayString, DumpFilter); metaDataInfo.DisplayMD(); } } // void DisplayFile()
static HRESULT vboxDrvCfgInfCopyEx(IN LPCWSTR lpszInfPath, IN DWORD fCopyStyle, OUT LPWSTR lpszDstName, IN DWORD cbDstName, OUT PDWORD pcbDstNameSize, OUT LPWSTR* lpszDstNameComponent) { WCHAR aMediaLocation[_MAX_DIR]; WCHAR aDir[_MAX_DIR]; _wsplitpath(lpszInfPath, aMediaLocation, aDir, NULL, NULL); wcscat(aMediaLocation, aDir); if (!SetupCopyOEMInfW(lpszInfPath, aMediaLocation, SPOST_PATH, fCopyStyle, lpszDstName, cbDstName, pcbDstNameSize, lpszDstNameComponent)) { DWORD dwErr = GetLastError(); HRESULT hr = HRESULT_FROM_WIN32(dwErr); if (fCopyStyle != SP_COPY_REPLACEONLY || hr != VBOXDRVCFG_S_INFEXISTS) { NonStandardLogRelCrap((__FUNCTION__ ": SetupCopyOEMInf fail dwErr=%ld\n", dwErr)); } return hr; } return S_OK; }
///////////////////////////////////////////////////////////////////////////// // 获取平台路径 ///////////////////////////////////////////////////////////////////////////// CString GetPlatRootPath() { //获取平台路径 TCHAR szFullPath[MAX_PATH]; TCHAR szdrive[_MAX_DRIVE]; TCHAR szdir[_MAX_DIR]; ::GetModuleFileName(NULL, szFullPath, MAX_PATH); #ifdef _UNICODE _wsplitpath(szFullPath, szdrive, szdir, NULL, NULL); #else _splitpath(szFullPath, szdrive, szdir, NULL, NULL); #endif CString szPath; szPath.Format(_T("%s%s"), szdrive, szdir); szPath = szPath.Left(szPath.GetLength() - 1); int nPos = szPath.ReverseFind('\\'); if(nPos >= 0) { szPath = szPath.Left(nPos+1); } return szPath; }