"WinMain"
hi, i also did something similar to your approch on console and windowsper4manz 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:
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 somethingCode: 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 }
rgds
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
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:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java