Jump to content
  • Advertisement
Sign in to follow this  
JohnHurt

consoleless app

This topic is 4992 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
If you're talking about writing an app that doesn't open a console, then you need to move into 'proper' windows programming, which has a different entry point - use WinMain(blah) instead of main(void). If you don't need any kind of user interface then it should be no problem, but if you need anything more complex than a Message Box, then you may need to get your hands dirty with real windows programming.

If it's just a case of running an existing console app without it popping up a console window, if you run it from a shortcut you can specify startup options, like run minimized etc. This doesn't actually stop it opening a console window, but it does keep it out the way a bit.

Share this post


Link to post
Share on other sites
The reason I ask is because SDL can be started from a main() instead of a WinMain(), so that your main program can be platform independent. I want this support in the engine i'm working on, and i wonder how it is possible.

Share this post


Link to post
Share on other sites
You can use conditional compilation to choose the entry point depending on what platform you're compiling on:


#ifdef _WIN32

// included only on Windows
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int cmdShow)

#else

int main(int argc, char** argv, char** envp)

#endif

{
// the rest of your program
return 0;
}


Share this post


Link to post
Share on other sites
figured it out by digging around in the SDL source:

goes something like this...

[main.cpp]
#include "main.h"
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
{
return(main());
}

[main.h]
extern int main();

then in the prog just call main() as normal.

Share this post


Link to post
Share on other sites
Quote:
Original post by JohnHurt
The reason I ask is because SDL can be started from a main() instead of a WinMain(), so that your main program can be platform independent. I want this support in the engine i'm working on, and i wonder how it is possible.

i assume it works with preprocessor magic

something similar to
#define main(a,b) WinMain(bar,a,b)

Edit: You found it faster, i haven't had the source right now...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!