How to normally start process using wxWidgets - shell

According official manuals, i tested this code:
wxProcess * proc = wxProcess::Open("C:\\windows\\notepad.exe");
but this code doesn't work properly, i see working notepad process in System Manager, but there is no notepad windows and etc. Also if i start console application - no text neither in new console window nor in mine.
How to fix that?
Thanks!

If you need neither IO redirection nor process termination notification, the simplest way to launch a process is to use wxExecute with wxEXEC_ASYNC flag.

Provided code works fine for me with any other application, e.g. calc.
wxProcess * process = wxProcess::Open(wxT("calc"));
wxLogDebug(wxT("Process: %s"), process != NULL ? wxT("OK") : wxT("Error"));
Shows OK and calc window appears.

Related

How do I write to the CommandPrompt from Windows GUI?

Operating Environment: Windows 7, Visual Studio 2010, CLR GUI.
So I've been given the unglorious task of enhancing a GUI application that is started from a command prompt. Because it is. Because poor design decisions by previous implementers. Anyway, it launches one of several GUIs depending upon the input arguments.
I'd like to be able to print back to the same command prompt window if (when) the user types something that the code doesn't understand.
Here's what I've tried (none of which output anything):
int main( array<System::String^>^ args )
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
OutputDebugString("hello");
Trace::WriteLine("hello");
Debug::Trace::WriteLine("hello");
Console::WriteLine("hello");
std::cout << "hello";
printf("hello");
return 0;
}
Thanks in advance!
Update: I don't want to use AllocConsole(), as that opens a new console that disappears along with all of the data when the application exits. Similarly, a pop-up message box won't work. I'm looking for a way to make the output persistent.
The only way I can get output from the application to date is via a message box (non-persistent) or opening a new console that disappears when the application exits (via AllocConsole() ). And I'm running from a command prompt, not the debugger's "Play" button.
Update
Why the down-vote for not doing research? I spent a day trying to solve this, looking through dozens of posts trying to find a solution, and to date I've found others looking for the same answer, but not finding it. AllocConsole() or changing the project type is always the solution, but neither is a solution for me.
Update
I added the "full code", which is the 2 statements. THAT IS ALL THE CODE. So simple. I'm skipping the start of the GUI because I don't care about that right now, I just want it to print back to the console where the application was started. The most basic HelloWorld. If there are project settings I need to post, I don't know which ones would be relevant. This is where I want to print to the console, before the GUI is ever up. I can't show the GUI if there is an error in the user input.
Right click on the project, select Properties
Under Linker -> System, Change Subsystem from Windows to Console.
A Windows subsystem application cannot write to console, but by changing the subsystem to Console (which can write to the calling console), the Form part of the application can still work (tested in Visual Studio 2010).

How do I programmatically stop all synths?

How do I programmatically tell supercollider to stop all synths, as in the equivalent of Ctrl+. in the IDE?
I don't have SC booted at the moment, but s.freeAll should do the job, as it frees all nodes attached to the server.
http://doc.sccode.org/Classes/Server.html#freeAll
You can all Ctrl+. from code directly:
CmdPeriod.run
This is more complete than s.freeAll as it also stops language-side Threads, including the one that contains this command. To see how to have threads escape CmdPeriod, check out the helpfiles for CmdPeriod and for SkipJack

Debugging application when launched via ShellExecute

I am trying to launch an application via the ShellExecute() API call. This application contains only a main function which does some processing and exits.
Now I have put DebugBreak() in starting of main. When ShellExecute() is called the application is launched successfully but it does not ask for breaking.
How can I debug my application when launched from other application using ShellExecute()?
I am using VC++ .
If DebugBreak() isn't workign for you, try _CrtDbgBreak(). Note that _CrtDbgBreak only works in a debug build.
_CrtDebugBreak definitely works for me to make a launched process break on startup, although I'm pretty sure DebugBreak does also.
Note that both functions will make it look like the process has crashed, since they raise an exception. That is normal and gives you the opportunity to attach a debugger via the crash dialog. (The crash dialog also lets you terminate the process; don't use that, obviously.)
Also note that if you have a catch-all SEH exception handler around your main then the exception raise by DebugBreak & friends will be swallowed up and the app will simply exit without showing the crash dialog or letting you attach to it.
You can't do this with VC++; with WinDbg this is just .childdbg 1 to debug all child processes. With VC++, you can use Image File Execution Options in a pinch - check out http://codereflect.com/2009/09/20/how-to-debug-child-process-using-windbgvisual-studio/ for more info. Really though, if you've got the time to learn WinDbg, it's much better at this.
you can try this, it's ok in xp system.
app.exe is your application name,
-s1...-s3 is command line arguments.
HINSTANCE hRet = ShellExecute(NULL, L"open", L"vsjitdebugger.exe", L" app.exe -s1 a1 -s2 a2 a3 -s3", szExePath, SW_SHOW);
There is now a Microsoft Child Process Debugging Power Tool.
The method I use for things like this is to embed some interactive code, which you can either delete afterwards, comment out or conditionally enable. In a few cases we have this code enabled by querying an environment variable which is set by the tool that launches the main application. This allows me to click a check box, hit launch and have the breakpoint dialog in seconds.
if (MessageBox(NULL,
_T("Attach the debugger now, then choose Yes to hit a breakpoint"),
_T("Attach Debugger"),
MB_YESNO) == IDYES)
__debugbreak();
This gives you the ability to attach the debugger when the dialog box appears and the option to hit a breakpoint or not. My earlier versions didn't give me the option and after a while I realised some of the time I wanted the breakpoint, and some of the time I didn't.

Printing on console WIN32/WTL

I am developing WTL GUI application.
I want to print something on console.
How to enable console printing in win32/WTL application.
Use AllocConsole to attach to a new console. (This will fail if your program is being run from a console window in the first place, but that's ok.) Also look at this page for a fully worked example.

webbrowser disable script debugging in Visual Basic 6

I want to disable script errors from popping up in a VB6 application. (I have VB6 installed on this machine).
Currently, if I navigate to a particular page, it pops up saying "INternet Explorer Script Error: An error has ocurred in the script on this page" ... "Do you want to continue running scripts on this page?"
Setting the webbrowser1.silent to 'true' does not work. Instead all that happens, is instead of displaying an error message, it starts up the actual 'script' debugger, and then exits the program. On a machine without the (visual studio) debugger, it still pops up a message asking to use the debugger, i.e., on Vista, (when silent is set to true).
Manually changing the 'disable script debugging (other)' (and regular one), doesn't seem to working in MSIE (also testing version 6.0 for xp users).
How do I disable script errors?
Thanks in advance!
WebBrowser.ScriptErrorsSuppressed = True
(The above code will Not work in VB6)
(Try this instead)
WebBrowser1.Silent = True
The webbrowser.silent can be reset to true when the application is run if you've set it in the design window. You may have to reset it to true when starting the application (ie: at runtime) and see if that works.
I Think It's That You Need
Write This Code In Your Form_Load Or Everywhere You Want
WebBrowser.ScriptErrorsSuppressed = True

Resources