0

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?

2
  • How is the exe invoked? From javascript or c++? Do you have the source code for the c++ console app?
    – parrowdice
    Nov 15 '13 at 9:52
  • exe is invoked using nsIProcess, this interface is available within firefox extension (javascript). And yes I have source code for the console app as well
    – Hassan
    Nov 15 '13 at 10:56
1

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 CreateProcess with 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 of nsIProcess.
  • Using another helper application, which is a "Windows" application, which will call CreateProcess to launch your actual application with CREATE_NO_WINDOW.
1
  • 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?
    – Hassan
    Nov 15 '13 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.