locked
Access commands of SDI through command line RRS feed

  • Question

  • Hi. I have an SDI app with some simple commands in file menu, let say, 3 commands.

    How can I start this SDI app in command line, in hidden mode, and access those 3 commands through command line parameter ?

    I have tried this:

    	// Parse command line for standard shell commands, DDE, file open
    	CCommandLineInfo cmdInfo;
    	ParseCommandLine(cmdInfo);
    
    	CString sCmdLine(m_lpCmdLine);
    	if(! sCmdLine.IsEmpty())
    	{
    		AfxMessageBox(sCmdLine);
    		m_nCmdShow = SW_HIDE;
    	}
    
    	// Dispatch commands specified on the command line.  Will return FALSE if
    	// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
    	if (! ProcessShellCommand(cmdInfo))
    		return FALSE;
    
    	// The one and only window has been initialized, so show and update it
    	m_pMainWnd->ShowWindow(m_nCmdShow);
    	m_pMainWnd->UpdateWindow();
    	// call DragAcceptFiles only if there's a suffix
    	//  In an SDI app, this should occur after ProcessShellCommand
    	return TRUE;
    

    and I call through command line:

    MyProgram.exe aaa

    but the program is shown, and tell me (though a message box):

    aaa was not found

    and the app is closing ...

    Is there a way to call some menu command through command line arguments, and start the app in hidden mode ?

    Monday, August 7, 2017 6:49 AM

Answers

  • Hi mesajflaviu,

    Thanks for posting here.

    >>and I call through command line:

    MyProgram.exe aaa

    but the program is shown, and tell me (though a message box):

    aaa was not found

    and the app is closing ...

    Is there a way to call some menu command through command line arguments, and start the app in hidden mode ?

    This is because the ProcessShellCommand couldn't recognize your command. The app name with command means new file or open file. The CCommandLineInfo object only contains these shell commands below.

    If you just want to start the app in hidden mode, you could just comment ProcessShellCommand method. For example:

    Hope this could be help of you.

    Best Regards,

    Sera Yu


    MSDN Community Support<br/> Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact <a href="mailto:MSDNFSF@microsoft.com">MSDNFSF@microsoft.com</a>.

    • Marked as answer by flaviu_ Monday, August 7, 2017 11:25 AM
    Monday, August 7, 2017 9:07 AM