// ------------------------------------------------------------------------------------------
	//! Creates a 2D font with specified parameters.
	//! @param gfxFontCreationInfo Pointer to the font creation information.
	GDAPI IGraphics2DDirect2DFont::IGraphics2DDirect2DFont(IGraphics2DFontCreationInfo const* const gfxFontCreationInfo)
		: IGraphics2DFont(gfxFontCreationInfo), D2DFontName(L"_font_"), D2DFontCollection(nullptr)
	{
		switch (gfxFontCreationInfo->FontLocation)
		{
		case IGRPAHICS2D_FONT_LOCATION_FILE: 
			{
#if GD_FALSE || 1
				BOOL   D2DFontIsSystem = FALSE;
				UINT32 D2DFontSystemIndex = UINT32_MAX;
				WCHAR  D2DFontFileName[_MAX_FNAME] = {};

				// First of all, we will try to load the font from the system collection..
				_wsplitpath_s(gfxFontCreationInfo->FontFilePath, nullptr, 0, nullptr, 0, D2DFontFileName, GD_ARRAY_LENGTH(D2DFontFileName), nullptr, 0);
				ThrowIfFailed(GD_IGRAPHICS2D_DIRECT2D->D2DDWFontCollectionDefault->FindFamilyName(D2DFontFileName, &D2DFontSystemIndex, &D2DFontIsSystem));
				if (D2DFontIsSystem != FALSE && D2DFontSystemIndex != UINT32_MAX)
				{
					// Font with this name was located inside system. There is no need to reload this font once more time. 
					// Theoretically, this font may differ from the system one.. but I don't give a shit.
					D2DFontCollection = GD_IGRAPHICS2D_DIRECT2D->D2DDWFontCollectionDefault;
					D2DFontName = D2DFontFileName;
					return;
				}
#endif	// if GD_FALSE

			//	GD_IGRAPHICS2D_DIRECT2D->D2DTextFactory->CreateCustomFontFileReference();
			} break;

			default: 
				GD_DEBUG_ASSERT_FALSE("Invalid font location.");
		}
	}
Ejemplo n.º 2
0
std::wstring 
getExtensionW(const std::wstring& in_String)
{
	wchar_t szFileExt[_MAX_EXT+1] = { 0 };
	_wsplitpath_s( in_String.c_str(), NULL, 0, NULL, 0, NULL, 0, szFileExt, _MAX_EXT+1 );
	return szFileExt;
}
Ejemplo n.º 3
0
bool LOCATOR::FSaveFileNames(const wchar_t *wszFilename)
{
    m_wszExePath = _wcsdup(wszFilename);

    if (m_wszExePath == NULL) {
        SetError(EC_OUT_OF_MEMORY);

        return false;
    }

    _wsplitpath_s(m_wszExePath, NULL, 0, NULL, 0, m_wszExeFName, _countof(m_wszExeFName), m_wszExeExt, _countof(m_wszExeExt));

    if ((m_wszExeExt[0] != L'\0') && (m_wszExeExt[1] != L'\0')) {
        // The executable filename includes a file extension

        m_wszExt = m_wszExeExt + 1;
    }

    else {
        // The executable filename does not include a file extension

        m_wszExt = NULL;
    }

    return true;
}
int LoadEffekseerEffect(const wchar_t* fileName, float magnification)
{
	if (g_manager2d == nullptr) return -1;

	if (effectFileNameToEffectHandle.count(fileName) > 0)
	{
		return effectFileNameToEffectHandle[fileName];
	}

	auto effect = Effekseer::Effect::Create(g_manager2d, (const EFK_CHAR*) fileName, magnification);
	if (effect == nullptr) return -1;

	int32_t handle = nextEffectHandle;
	nextEffectHandle++;

	effectFileNameToEffectHandle[fileName] = handle;
	effectHandleToEffectFileName[handle] = fileName;
	effectHandleToEffect[handle] = effect;

	if (g_server != nullptr)
	{
		wchar_t _dir[_MAX_DIR];
		wchar_t _drive[_MAX_DRIVE];
		wchar_t _fileName[_MAX_FNAME];
		wchar_t _ext[_MAX_EXT];
		_wsplitpath_s(fileName, _drive, _dir, _fileName, _ext);
		g_server->Register((const EFK_CHAR*) _fileName, effect);
	}

	return handle;
}
Ejemplo n.º 5
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";
}
Ejemplo n.º 6
0
BOOL Smart::Global::CCrashDump::IsDataSectionNeeded( const WCHAR* pModuleName ) 
{
    // Check parameters 
    if( pModuleName == NULL ) 
    {
        return FALSE; 
    }

    WCHAR szModule[512];
    GetModuleFileName(NULL, szModule, 512);
    if( _wcsicmp(szModule, pModuleName) == 0)
    {
        return TRUE;
    }

    // Extract the module name 
    WCHAR szFileName[_MAX_FNAME] = L""; 
    _wsplitpath_s( pModuleName, NULL, 0, NULL, 0, szFileName, _MAX_FNAME, NULL, 0 ); 

    // Compare the name with the list of known names and decide 
    if( _wcsicmp( szFileName, L"ntdll" ) == 0 ) 
    {
        return TRUE; 
    }

    // Complete 
    return FALSE; 
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
void GetExecutableDir(wchar_t* outdir, int outdir_length)
{
    // Without slash at end.

    // This path is longer than MAX_PATH, do not use it with
    // windows api functions as you might get buffer overflows.

    wchar_t longpath[1024];
    GetExecutablePath(longpath, _countof(longpath));

    wchar_t drive[3];
    wchar_t dir[768];
    wchar_t fname[256];
    wchar_t ext[32];

    errno_t result = _wsplitpath_s(longpath, drive, _countof(drive), dir, _countof(dir), fname, _countof(fname), ext, _countof(ext));
    ASSERT_EXIT((result == 0), "_wsplitpath_s(longpath)");

    swprintf_s(outdir, outdir_length, L"%s%s", drive, dir);

    // remove slash at end
    int len = wcslen(outdir);
    if (outdir[len-1] == '\\' || outdir[len-1] == '/') {
        outdir[len-1] = 0;
    }
}
Ejemplo n.º 9
0
void GetFileTitle(const wstring& strPath, wstring& strTitle)
{
	WCHAR szFname[_MAX_FNAME];
	_wsplitpath_s( strPath.c_str(), NULL, 0, NULL, 0, szFname, _MAX_FNAME, NULL, 0 );

	strTitle = szFname;
	return ;
}
Ejemplo n.º 10
0
void GetFileExt(const wstring& strPath, wstring& strExt)
{
	WCHAR szExt[_MAX_EXT];
	_wsplitpath_s( strPath.c_str(), NULL, 0, NULL, 0, NULL, 0, szExt, _MAX_EXT );

	strExt = szExt;
	return ;
}
Ejemplo n.º 11
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;
}
// (3) Totally changed
//==============================================================================
CDiskItem::CDiskItem( const CString &strFullName )
{
//   wchar_t cFullName[_MAX_PATH];
//   _tcscpy( cFullName, fullName ); // M If Unicode
	wchar_t drive[_MAX_DRIVE];
	wchar_t dir[_MAX_DIR];
	wchar_t fname[_MAX_FNAME];
	wchar_t ext[_MAX_EXT];

	CString strTmp = strFullName;	// (3) We copy the string because we can't change const &
	if( strTmp.Right(1) == "\\" )	// (3) Consider a folder as a file
		strTmp = strTmp.Left( strTmp.GetLength()-1 );

	_wsplitpath_s( strTmp/*(3)strFullName*/, drive, dir, fname, ext );
	// (3) m_strDrive = drive;
	// (3) m_strDir = dir;
	// (3) m_strName = CString(fname) + CString(ext);

// Support UNC
// I must do it because _splitpath doesn't work correctly with UNC!
	if( strFullName.Left( 2 ) == "\\\\" )	// If UNC path is specified
	// (3) Was if( m_strDir.Left( 2 ) == "\\\\" )	// If UNC...
	{
	// (3) In all places - strTmp instead of m_strDir

		int compEnd = strTmp.Find( _T("\\"), 2 );
		m_strComputer = strTmp.Left( compEnd+1 );

		int driveEnd = strTmp.Find( _T("\\"), compEnd+1 );
		if( driveEnd == -1 )	// (3) Slash not found
		{
			m_strDrive = strTmp.Mid( compEnd+1 );
			m_strDir   = "";	// (3)
			m_strName = "";		// (3)
		}
		else					// (3) Slash found
		{
			m_strDrive = strTmp.Mid( compEnd+1, driveEnd-compEnd );

			int dirEnd = strTmp.ReverseFind( '\\' );				// (3)
			if( dirEnd > driveEnd )									// (3)
				m_strDir = strTmp.Mid( driveEnd+1, dirEnd-driveEnd );// (3)

			if( strTmp.GetLength() > dirEnd )				// (3)
				m_strName = CString(fname) + CString(ext);	// (3)
			else
				m_strName = "";
		}
	}
	else	// (3) All in brackets added
	{
		m_strComputer = "";
		m_strDrive = drive;
		m_strDir = dir;
		m_strName = CString(fname) + CString(ext);
	}
}
Ejemplo n.º 13
0
std::string
getFileNameOnly(const std::wstring& in_strFullPath)
{
	wchar_t strFileName[_MAX_FNAME] = { 0 };	
	wchar_t strExtensionName[_MAX_EXT] = { 0 };	

	_wsplitpath_s( in_strFullPath.c_str(), NULL, 0, NULL, 0, strFileName, _MAX_FNAME, strExtensionName, _MAX_EXT );

	return wide2Ansi(strFileName) + wide2Ansi(strExtensionName);
}
Ejemplo n.º 14
0
PerfCounter::PerfCounter()
{
	PdhOpenQuery(NULL, NULL, &m_query);

	HMODULE hProcess = GetModuleHandle(NULL);
	wchar_t fileNameBuf[MAX_PATH];
	GetModuleFileName((HMODULE) hProcess, fileNameBuf, MAX_PATH);
	wchar_t baseNameBuf[MAX_PATH];
	_wsplitpath_s(fileNameBuf, NULL, 0, NULL, 0, baseNameBuf, MAX_PATH, NULL, 0);
	m_processName = baseNameBuf;
	DWORD processId = GetProcessId(GetCurrentProcess());

	//we need to figure out the correct instance name
	//start by asking for all the counters which match the process name
	std::wstring wildcard = (boost::wformat(L"\\Process(%1%*)\\ID Process") % m_processName).str();
	wchar_t paths[1024];
	DWORD size = 1024;
	PdhExpandWildCardPath(NULL, wildcard.c_str(), paths, &size, 0);

	//create each ProcessID counter, check its value to see if it's the one we want
	size_t len = wcslen(paths);
	wchar_t* pathPtr = paths;
	bool found = false;
	while(len != 0)
	{
		PDH_HCOUNTER counter;
		PdhAddCounter(m_query, pathPtr, NULL, &counter);
		PdhCollectQueryData(m_query);
		PDH_RAW_COUNTER counterValue;
		PdhGetRawCounterValue(counter, 0, &counterValue);
		PdhRemoveCounter(counter);

		if(counterValue.FirstValue == processId)
		{
			found = true;
			break;
		}

		pathPtr += len + 1;
		len = wcslen(pathPtr);
	}

	if(found)
	{
		//we've got our desired instance name, which is ProcessName#N
		const wchar_t* instStart = wcschr(wildcard.c_str(), L'(') + 1;
		const wchar_t* instEnd = wcschr(wildcard.c_str(), L')') - 1;
		m_instName = std::wstring(instStart, instEnd - instStart);
	}
	else
	{
		//oh well, just roll with what we've got
		m_instName = m_processName;
	}
}
Ejemplo n.º 15
0
void GetFileTitle(wstring strPath, wstring& strTitle)
{
	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 );

	strTitle = szFname;
	return ;
}
Ejemplo n.º 16
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 ;
}
Ejemplo n.º 17
0
std::wstring
ExtractDirectoryW( const std::wstring& in_strFile )
{
	wchar_t strDrive[_MAX_DRIVE+1] = {0};
	wchar_t strDir[_MAX_DIR+1] = {0};
	_wsplitpath_s( in_strFile.c_str(), strDrive, _MAX_DRIVE, strDir, _MAX_DIR, NULL, 0, NULL, 0 );

    std::wstring out_strDirectory = strDrive;
	out_strDirectory += strDir;
    return out_strDirectory;
}
Ejemplo n.º 18
0
BOOL IsExt(const WCHAR* filePath, const WCHAR* ext)
{
	WCHAR szExt[_MAX_EXT];
	_wsplitpath_s( filePath, NULL, 0, NULL, 0, NULL, 0, szExt, _MAX_EXT );

	if( _wcsicmp( szExt, ext ) != 0 ){
		return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 19
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 ;
}
Ejemplo n.º 20
0
void GetFileExt(wstring strPath, wstring& strExt)
{
	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 );

	strExt = szExt;
	return ;
}
Ejemplo n.º 21
0
void proxy(struct sockaddr *name) {
    HKEY hKey;
    if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Klatt\\Forced Proxy", 0, NULL, 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, NULL, &hKey, NULL) != ERROR_SUCCESS) {
        return;
    }
    TCHAR path[_MAX_PATH], fname[_MAX_FNAME];
    if(!GetModuleFileName(NULL, path, sizeof(path))) {
        return;
    }
    if(_wsplitpath_s(path, NULL, 0, NULL, 0, fname, _MAX_FNAME, NULL, 0)) {
        return;
    }
    DWORD intercept;
    DWORD cbData = sizeof(intercept);
    if(RegQueryValueEx(hKey, fname, NULL, NULL, (LPBYTE) &intercept, &cbData) != ERROR_SUCCESS) {
        intercept = 0;
        RegSetValueEx(hKey, fname, 0, REG_DWORD, (LPBYTE) &intercept, cbData);
        return;
    }
    if(intercept && name->sa_family == AF_INET) {
        char proxyName[16] ;
        cbData = sizeof(proxyName);
        if(RegQueryValueExA(hKey, NULL, NULL, NULL, (LPBYTE) &proxyName, &cbData) != ERROR_SUCCESS) {
            strcpy_s(proxyName, "127.0.0.1");
            RegSetValueExA(hKey, NULL, 0, REG_SZ, (LPBYTE) &proxyName, cbData);
        }
        struct sockaddr_in *ipv4 = (struct sockaddr_in *)name;
        if(ntohs(ipv4->sin_port) == 80) {
            ipv4->sin_addr.s_addr = inet_addr(proxyName);
            ipv4->sin_port = htons(8080);
        } else if(ntohs(ipv4->sin_port) == 443) {
            ipv4->sin_addr.s_addr = inet_addr(proxyName);
            ipv4->sin_port = htons(8443);
        }
    } else if(intercept && name->sa_family == AF_INET6) {
        /*
        	char proxyName6[32] ;
        	strcpy_s(proxyName6, "0:0:0:0:0:FFFF:");
        	strcat_s(proxyName6, proxyName);
        	struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)name;
        	if(ntohs(ipv6->sin6_port) == 80) {
        		struct in6_addr addr;
        		ipv6->sin6_addr = addr;
        		inet_pton(AF_INET6, proxyName6, &ipv6->sin6_addr);
        		ipv6->sin6_port = htons(8080);
        	} else if(ntohs(ipv6->sin6_port) == 443) {
        		inet_pton(AF_INET6, proxyName6, &ipv6->sin6_addr);
        		ipv6->sin6_port = htons(8443);
        	}
        */
    }
}
//--------------------------------------------------------------------------------------
// Initialize everything and go into a render loop
//--------------------------------------------------------------------------------------
INT WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR lpCmdLine, int nShowCmd)
{
	wchar_t executableFullPath[MAX_PATH];
	GetModuleFileName( NULL, executableFullPath, MAX_PATH );

	wchar_t executableDrive[MAX_PATH];
	wchar_t executableDir[MAX_PATH];
	_wsplitpath_s(executableFullPath, executableDrive, MAX_PATH, executableDir, MAX_PATH, 0, 0, 0, 0);

	wchar_t currentDir[MAX_PATH] = { L'\0' };
	wcscat_s(currentDir, executableDrive);
	wcscat_s(currentDir, executableDir);
	wcscat_s(currentDir, L"..\\");

	BOOL result = SetCurrentDirectory(currentDir);
	ASSERT(result != FALSE, "Can't change current directory.");

	// Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif

	// Set the callback functions
	DXUTSetCallbackD3D9DeviceAcceptable( IsD3D9DeviceAcceptable );
	DXUTSetCallbackD3D9DeviceCreated( OnD3D9CreateDevice );
	DXUTSetCallbackD3D9DeviceReset( OnD3D9ResetDevice );
	DXUTSetCallbackD3D9FrameRender( OnD3D9FrameRender );
	DXUTSetCallbackD3D9DeviceLost( OnD3D9LostDevice );
	DXUTSetCallbackD3D9DeviceDestroyed( OnD3D9DestroyDevice );
	DXUTSetCallbackDeviceChanging( ModifyDeviceSettings );
	DXUTSetCallbackMsgProc( MsgProc );
	DXUTSetCallbackFrameMove( OnFrameMove );

	// Initialize DXUT and create the desired Win32 window and Direct3D device for the application
	
	// Parse the command line and show msgboxes
	DXUTInit( true, true );
	
	// Handle the default hotkeys
	DXUTSetHotkeyHandling( true, true, true );
	
	// Show the cursor and clip it when in full screen
	DXUTSetCursorSettings( true, true ); 

	DXUTCreateWindow(L"GPU Pro 5 : 'Quaternions revisited'");
	DXUTCreateDevice(true, 1280, 720);

	// Start the render loop
	DXUTMainLoop();

	return DXUTGetExitCode();
}
Ejemplo n.º 23
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 ;
}
// (4)
//==============================================================================
CString CDiskItem::getExtension() const
{
  wchar_t drive[_MAX_DRIVE];
  wchar_t dir[_MAX_DIR];
  wchar_t fname[_MAX_FNAME];
  wchar_t ext[_MAX_EXT];

  _wsplitpath_s( m_strName, drive, dir, fname, ext );
  if( *ext == 0 )  // empty string
    return ext;
  else
    return ext+1; // exclude the period (.)
}
Ejemplo n.º 25
0
/* Return the directory name of the given path.  The returned string includes 
 * the drive letter and a trailing backslash. */
std::wstring dirname(const std::wstring & path) {

	WCHAR drive[3];
	WCHAR directory[MAX_PATH];

	_wsplitpath_s(path.c_str(), 
		drive, 3,				
		directory, MAX_PATH, 
		NULL, 0, 
		NULL, 0);

	return std::wstring(drive) + std::wstring(directory);
}
Ejemplo n.º 26
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
}
Ejemplo n.º 27
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 ;
}
Ejemplo n.º 28
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);
}
Ejemplo n.º 29
0
CString CCardInfDlg::GetProgramCurrentPath(void)
{
	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);
	_wsplitpath_s(path_buffer, drive, dir, fname, ext);
	CString strDir;
	strDir += drive;
	strDir += dir;
	return strDir;
}
Ejemplo n.º 30
0
	std::wstring Globals::LaunchPath()
	{ 
		if (!m_bLPGenerated)
		{
			auto drive = new wchar_t[260];
			auto name = &drive[4];
			GetModuleFileName(GetModuleHandle(nullptr), name, 256);
			auto temp = static_cast<LPCWSTR>(name);
			_wsplitpath_s(temp, drive, 3, name, 256, nullptr, 0, nullptr, 0);
			m_wsLaunchPath = lstrcatW(drive, static_cast<LPCWSTR>(name));
			SetCurrentDirectory(m_wsLaunchPath.data());
			m_bLPGenerated = true;
		}
		return m_wsLaunchPath;
	}