"WinMain"

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
arfgh
Posts: 104
Joined: Sat Aug 26, 2006 6:15 am

Post by arfgh »

i removed the extern, and the same happends...
Avalanche
Posts: 18
Joined: Tue Sep 05, 2006 7:21 am

Post by Avalanche »

per4manz wrote:I just use a define to tie into whether I am compiling in DEBUG or RELEASE modes in VisualStudio. It's then "automatic" and I get the best of both worlds:

Code: Select all

#ifdef _DEBUG
int main()
#else
INT WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR strCmdLine,INT)
#endif
{
	HANDLE ExistingGameMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, "uniquegamenamehere"); 
	
	if(ExistingGameMutex) // Check to see if the game is currently running
	{
		CloseHandle(ExistingGameMutex);
		MessageBox(NULL, "\nPlease click OK to close this information box. Click on the running game in the task bar", "Game Already Running", MB_OK);
		return -1;
	}
	else
	{
		CreateMutex(NULL,0,"uniquegamenamehere");
		CloseHandle(ExistingGameMutex);
	}

..blah .. rest of (win)main code here as you need

}
Note the additional mutex code which is nothing to do with the methods mentioned but as I just cut and pasted from my project I thought I'd leave that in (it may be useful for someone) - basically it prevents you launching 2 or more versions of the same game at once (single instance). This is a good thing to do in case a user gets impatient and double clicks your icon 20 times or something ;)

rgds
hi, i also did something similar to your approch on console and windows
however i noticed my game runs slower in windows :( , and having a console popping up is not proffesional looking

i also tried
#pragma comment(linker, "/subsystem:windows /entry:main")
but my game will shutdown when it initialized
ck123
Posts: 5
Joined: Wed May 24, 2006 5:50 am

Post by ck123 »

how about this...
how about this...

int main()
{
// create irrlicht


HWND wnd = GetConsoleWindow();
ShowWindow(wnd, SW_HIDE);

// run irrlicht stuff
}


I think GetConsoleWindow was a part of windows.h but not sure off hand.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Hmmm, I'm using C::B and the only thing I change is the project type to "GUI application" and using the normal int main() or int main(int argc, char** argv), and it works with no problems (no need to use WinMain) !?!?!
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply