How to remove the console?

Started by
2 comments, last by Tac-Tics 17 years, 9 months ago
I have a Java jar file which contains a program I wish to run. However, I want to make a simple bootstrap program in C to get it running without the need to open up the console. Originally, I just had some jazz along the line of
#include ...
int main() { 
    system("java -jar myjar.jar"); 
    return 0;
}
But the windows console appears (albiet blank). My question is how to I get rid of the console entirely? I thought that maybe if I switch it over to a WinMain, Windows would interpret this as meaning my program is a windowed application, but alas, it still shows the console:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
					LPSTR lpCmdLine, int nCmdShow) {
	system("java -jar myjar.jar");
	return 0;
}




So how do I write this simple "launcher" program without opening a new console?
Advertisement
If you use VS you can right click on project and set the environment in settings from console to windows
-----"Master! Apprentice! Heartborne, 7th Seeker Warrior! Disciple! In me the Wishmaster..." Wishmaster - Nightwish
Quote:Original post by Red_falcon
If you use VS you can right click on project and set the environment in settings from console to windows

The project's subsystem has nothing to do with the call to system. You can use ShellExecute to do this.
An example with the command-prompt: "ShellExecute(NULL, NULL, "cmd", "/c echo dummy > Dump.txt", NULL, SW_HIDE);" -> Dump.txt will contain "dummy", and the console window will never be visible.
In your case, I guess you will need to specify SW_NORMAL, though and obviously replace the data with your own...
Hmmm. Well, it sorta worked. Now the main issue I'm having is that my application is written in jython, and so, takes about 10 seconds to load. My users are going to think the application is having troubles launching =-/

Oh well. I'll figure something out.

This topic is closed to new replies.

Advertisement