I have developed a firefox extension (add-on), and embed a c++ console application (.exe) in it. I pass command line arguments to that exe and it performs some actions associated with those arguments. Problem is whenever that exe is invoked a console window appears and disappears. I want that to be silent. Any thoughts?
I'm assuming you actually execute your executable via nsIProcess right now. Unfortunately nsIProcess does not give you enough control over the process creation to avoid the console window.
You'll either have to modify the console application itself, to be a "Windows" application not "Console" application (WinMain() vs. main()), or if that is not possible, you'll have to somehow call CreateProcess yourself with dwCreationFlags including the CREATE_NO_WINDOW flags.
The latter can be either done by:
- Calling
CreateProcesswith appropriate flags directly, if your add-on code is already C++. - Using js-ctypes to import
CreateProcess, define the necessary structures and call it, replacing your use ofnsIProcess. - Using another helper application, which is a "Windows" application, which will call
CreateProcessto launch your actual application withCREATE_NO_WINDOW.
-
yes i am using nsIProcess. Since I am new to C++ let me ask some beginner questions: Just changing the name of main method to WinMain() would work or need to do something else as well? And WinMain takes arguments?– HassanNov 15 '13 at 10:57
nsIProcess, this interface is available within firefox extension (javascript). And yes I have source code for the console app as well