views:

324

answers:

2

I put this below code inside my *.dll for Internet Explorer.

FILE  *child = _popen("java -jar c:\\simmetrics.jar c:\\chtml.txt c:\\thtml.txt > c:\\output.txt", "r");

fclose(child);

My problem is, when I run my Internet Explorer, the will be a cmd.exe console open too. I don't want the console to suddenly appear when I run my browser. How can I avoid this or hide it or not to execute it at all)?

update:

How to properly call javaw from the code? It still popping up the console windows :(

FILE  *child = _popen("javaw -jar c:\\simmetrics.jar c:\\chtml.txt c:\\thtml.txt > c:\\output.txt", "r");

update:

Is there any other way? The console window still being called everytime I run this line of code inside my program.

+4  A: 

Try using javaw.exe instead. It's the same as java.exe except it's a Windows graphical program and not a console program so it won't open a command console. (As a side effect you won't be able to see stdout and stderr without redirecting them to a log file.)

John Kugelman
When I type javaw inside my cmd console, and press ENTER, there seems no help-manual appear. May I know why and how to fix this?
karikari
Is there any other way. It still pops up the cmd console.
karikari
+1  A: 

You can use CreateProcess instead of _popen. It's a bit more cumbersome, but you can pass the CREATE_NO_WINDOW flag as part of the dwCreationFlags parameter to prevent the console window from appearing.

If you need to capture the output of the process you've created, you can use CreatePipe/ReadFile to do so. MSDN has a thorough example of doing this here.

Chris Schmich