"WinMain"
-
- Posts: 340
- Joined: Wed Sep 28, 2005 4:38 pm
- Location: Canada, Eh!
WinMain is as follows:
Remember to include windows.h
Code: Select all
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
}
Royal Hamilton Light Infantry - http://www.rhli.ca
Paris/Port Dover Pipes'n Drums - http://www.parisdover.ca
Paris/Port Dover Pipes'n Drums - http://www.parisdover.ca
OMG... did you trymepatuhoo wrote:Project\main.cpp #include expects "FILENAME" or <FILENAME>
Code: Select all
#include windows.h
Code: Select all
#include <windows.h>
Regards - Xaron
-
- Posts: 93
- Joined: Tue Feb 08, 2005 12:19 pm
there is another way to hide the console window. its a bit controversial for some reason?!?
but this is what i use, and got it from the msdn website.it works like a charm and no need to include any headers what so ever. the way it works it changes the system to windows (and uses winmain by default), then with "/entry:main" it tells the linker to use main() instead of winmain().
but this is what i use, and got it from the msdn website.
Code: Select all
#pragma comment(linker, "/subsystem:windows /entry:main")
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 something
rgds
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
}
rgds
-
- Posts: 93
- Joined: Tue Feb 08, 2005 12:19 pm
i basicly copyed the interface tutorial and then edited it so most of the programing i have just modifyed. i tryed the exe and its still showing the box.genesisrage wrote:@mepatuhoo
depends on the ide you are using. as in my example above Code::Blocks still shows the console window when executed through the ide, but when running the .exe file itself it does not show up.
-
- Posts: 93
- Joined: Tue Feb 08, 2005 12:19 pm
what part of the code do you need to figer it out. ill send you the main funtion. i gess thats where is would need to be fixed
int main()
{
video::E_DRIVER_TYPE driverType;
// printf("Please select the driver you want for this example:\n"\
// " (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
// " (d) Software Renderer\n (e) Apfelbaum Software Renderer\n"\
// " (f) NullDevice\n (otherKey) exit\n\n");
char i;
// std::cin >> i;
i='c';
switch(i)
{
case 'a': driverType = video::EDT_DIRECT3D9;break;
case 'b': driverType = video::EDT_DIRECT3D8;break;
case 'c': driverType = video::EDT_OPENGL; break;
case 'd': driverType = video::EDT_SOFTWARE; break;
case 'e': driverType = video::EDT_SOFTWARE2;break;
case 'f': driverType = video::EDT_NULL; break;
default: return 1;
}
// create device and exit if creation failed
device = createDevice(driverType, core::dimension2d<s32>(640, 480));
// device = createDevice(driverType, core::dimension2d<s32>(640, 480));
if (device == 0)
return 1; // could not create selected driver.
/* The creation was successful, now we set the event receiver and
store pointers to the driver and to the gui environment. */
MyEventReceiver receiver;
int main()
{
video::E_DRIVER_TYPE driverType;
// printf("Please select the driver you want for this example:\n"\
// " (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
// " (d) Software Renderer\n (e) Apfelbaum Software Renderer\n"\
// " (f) NullDevice\n (otherKey) exit\n\n");
char i;
// std::cin >> i;
i='c';
switch(i)
{
case 'a': driverType = video::EDT_DIRECT3D9;break;
case 'b': driverType = video::EDT_DIRECT3D8;break;
case 'c': driverType = video::EDT_OPENGL; break;
case 'd': driverType = video::EDT_SOFTWARE; break;
case 'e': driverType = video::EDT_SOFTWARE2;break;
case 'f': driverType = video::EDT_NULL; break;
default: return 1;
}
// create device and exit if creation failed
device = createDevice(driverType, core::dimension2d<s32>(640, 480));
// device = createDevice(driverType, core::dimension2d<s32>(640, 480));
if (device == 0)
return 1; // could not create selected driver.
/* The creation was successful, now we set the event receiver and
store pointers to the driver and to the gui environment. */
MyEventReceiver receiver;
tried all that forms you told and not got success.
#include <windows.h>
#pragma comment(linker, "/subsystem:windows /entry:main")
#pragma comment(lib, "Irrlicht.lib")
extern int main (int argc, char **argv) {
blabla...
}
i use visual studio c++ 6.0 and my irrlicht is irrlicht-0.10.0
I compiled as "win32 application" and not as usual "win32 console aplication"
when i execute the program "xxx.exe got a problem and must to close"
can someone help me to hide that cmd console ?
#include <windows.h>
#pragma comment(linker, "/subsystem:windows /entry:main")
#pragma comment(lib, "Irrlicht.lib")
extern int main (int argc, char **argv) {
blabla...
}
i use visual studio c++ 6.0 and my irrlicht is irrlicht-0.10.0
I compiled as "win32 application" and not as usual "win32 console aplication"
when i execute the program "xxx.exe got a problem and must to close"
can someone help me to hide that cmd console ?