• Advertisement
Sign in to follow this  

How to open a txt using notepad in directx?

This topic is 1988 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How to open a txt using notepad in directx? Currently I am using system("notepad Config.cfg") which can open a command window and the Config.cfg, but the programm will stop at that line. My expection is open the Config.cfg then keep going and rendering stuffs in directx

Thanks in advance

Jerry

Share this post


Link to post
Share on other sites
Advertisement
To launch an application in Windows (it has nothing to do with DirectX). you can use CreateProcess

http://msdn.microsof...p/ms682425.aspx

link fixed (i hope)

ShellExecute (linked to by alvaro) might be more appropriate though, (It opens the file using the users favourite editor) Edited by SimonForsman

Share this post


Link to post
Share on other sites
This is my main function. Everything works fine except when I exit the programm there is a Unhandled exception says "Unhandled exception at 0x771b15de in RayTracter.exe: 0x00000000: The operation completed successfully." and it stop at line "if (*lpszCommandLine==DQUOTECHAR) inDoubleQuote=!inDoubleQuote;"

#ifdef _WINMAIN_
/*
* Skip past program name (first token in command line).
* Check for and handle quoted program name.
*/
#ifdef WPRFLAG
/* OS may not support "W" flavors */
if (_wcmdln == NULL)
return 255;
lpszCommandLine = (wchar_t *)_wcmdln;
#else /* WPRFLAG */
lpszCommandLine = (unsigned char *)_acmdln;
#endif /* WPRFLAG */
while (*lpszCommandLine > SPACECHAR ||
(*lpszCommandLine&&inDoubleQuote)) {
/*
* Flip the count from 1 to 0 or 0 to 1 if current character
* is DOUBLEQUOTE
*/
if (*lpszCommandLine==DQUOTECHAR) inDoubleQuote=!inDoubleQuote;//stop here


INT WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int )
{
// 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 );
DXUTSetCallbackKeyboard( KeyboardProc );
DXUTSetCallbackFrameMove( OnFrameMove );
Config();
// TODO: Perform any application-level initialization here
// Initialize DXUT and create the desired Win32 window and Direct3D device for the application
DXUTInit( true, true ); // Parse the command line and show msgboxes
DXUTSetHotkeyHandling( true, true, true ); // handle the default hotkeys
DXUTSetCursorSettings( true, true ); // Show the cursor and clip it when in full screen
DXUTCreateWindow( L"RayTracing" );
DXUTCreateDevice( true, g_Screen_Width, g_Screen_Height );
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
LPTSTR szCmdline = _tcsdup(TEXT("notepad Config.cfg"));
if( !CreateProcess(NULL, szCmdline,
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi))
{
printf( "CreateProcess failed (%d).\n", GetLastError() );
}
DXUTMainLoop();
// TODO: Perform any application-level cleanup here
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );

// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
delete[] szCmdline;
return DXUTGetExitCode();
}


What causes this problem?

Jerry

Share this post


Link to post
Share on other sites
Sorry the Unhandled exception is
Unhandled exception at 0x771b15de in RayTracter.exe: 0xC0000005: Access violation reading location 0x00000000.

Share this post


Link to post
Share on other sites
oops my apologize I accidently delete a texture file without tracking the unsuccessful construction.

Share this post


Link to post
Share on other sites

Currently I am using system("notepad Config.cfg") which can open a command window and the Config.cfg, but the programm will stop at that line

As a side note , system() runs a process and waits for it to finish and only after that it will allow the application to continue its course.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement