Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


How to open a txt using notepad in directx?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 monkeyboi   Members   -  Reputation: 188

Like
0Likes
Like

Posted 14 August 2012 - 06:39 AM

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

Sponsor:

#2 SimonForsman   Crossbones+   -  Reputation: 6322

Like
0Likes
Like

Posted 14 August 2012 - 06:59 AM

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, 14 August 2012 - 09:11 AM.

I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

#3 monkeyboi   Members   -  Reputation: 188

Like
0Likes
Like

Posted 14 August 2012 - 08:39 AM

The link is invalid

#4 Álvaro   Crossbones+   -  Reputation: 13933

Like
0Likes
Like

Posted 14 August 2012 - 08:47 AM

http://msdn.microsof...3(v=vs.85).aspx

#5 monkeyboi   Members   -  Reputation: 188

Like
0Likes
Like

Posted 14 August 2012 - 01:34 PM

Thanks a lot got it solved

Jerry

#6 monkeyboi   Members   -  Reputation: 188

Like
0Likes
Like

Posted 14 August 2012 - 04:05 PM

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

#7 monkeyboi   Members   -  Reputation: 188

Like
0Likes
Like

Posted 14 August 2012 - 04:07 PM

Sorry the Unhandled exception is
Unhandled exception at 0x771b15de in RayTracter.exe: 0xC0000005: Access violation reading location 0x00000000.

#8 monkeyboi   Members   -  Reputation: 188

Like
0Likes
Like

Posted 14 August 2012 - 04:25 PM

oops my apologize I accidently delete a texture file without tracking the unsuccessful construction.

#9 TwoOfDiamonds   Members   -  Reputation: 147

Like
0Likes
Like

Posted 14 August 2012 - 04:54 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS