Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
roxaz
Posts: 575 Joined: Tue Jan 23, 2007 8:35 pm
Location: LT
Post
by roxaz » Fri Mar 30, 2007 3:51 pm
I gues most of you know that but it might be useful for newbies. So to disable console window simply use this function instead of your main() and dont forget to include header
Code: Select all
#include <Windows.h>
int WINAPI WinMain( HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
}
Sylence
Posts: 725 Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:
Post
by Sylence » Fri Mar 30, 2007 5:27 pm
And if you want to use argc and argv you can use this code:
Code: Select all
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int)
{
char *apppath = new char [256];
strcpy_s(apppath, 256, GetCommandLine());
if (apppath[0] == '\"')
{
apppath = (apppath+1);
char *lastdit = strchr(apppath, '\"');
*lastdit = '\x0';
}
char **argv = NULL;
int argc = 1;
if ( *lpCmdLine != '\x0' )
{
char *cmdLineCopy = new char [strlen(lpCmdLine)+1];
strcpy ( cmdLineCopy, lpCmdLine );
char *c = cmdLineCopy;
while(c)
{
++argc;
c = strchr ( (c+1),' ');
}
argv = new char *[argc];
argv[0] = apppath;
if(argc > 1)
{
argv [1] = cmdLineCopy;
char *c = strchr(cmdLineCopy, ' ');
int n = 2;
while(c)
{
*c = '\x0';
argv [n] = (c+1);
++n;
c = strchr((c+1), ' ');
}
}
}
else
{
argv = new char *[1];
argv[0] = apppath;
}
return 0;
}
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
olivehehe_03
Posts: 157 Joined: Tue Mar 20, 2007 8:30 am
Post
by olivehehe_03 » Sat Mar 31, 2007 1:58 am
There's another way to do it, just put this code somewhere (I put it before int main() and it works fine)
Code: Select all
//#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
Virion
Competition winner
Posts: 2148 Joined: Mon Dec 18, 2006 5:04 am
Post
by Virion » Fri Apr 20, 2007 2:06 pm
this is only for window right? how about hiding console in linux?..
hybrid
Admin
Posts: 14143 Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:
Post
by hybrid » Fri Apr 20, 2007 3:11 pm
You don't have the problem under Linux. There is no default console.
dawasw
Posts: 357 Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland
Post
by dawasw » Fri Apr 20, 2007 3:25 pm
Maybe I forgot something, but in Dev-C++ you can simply select Windows Application when making a new project instead of using console application.
monkeycracks
Posts: 1029 Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:
Post
by monkeycracks » Fri Apr 20, 2007 4:02 pm
You don't even need to select windows application in dev-cpp.
Project Options->Compiler->Linker->Do not create console window.
Turn that to yes.
L1zb3th
Posts: 15 Joined: Thu Jul 26, 2007 1:27 am
Post
by L1zb3th » Tue Sep 18, 2007 10:52 pm
passing to the linker -mwindows library ...
or using the function FreeConsole() of the win api ...
respect of doing that in linux, i dont remember xDD
but, if you want your console clean, use pipes ...
Au Revoir !
Last edited by
L1zb3th on Mon Nov 19, 2007 4:16 pm, edited 1 time in total.
My Gramathicalz horrorz are precalkulated, zo Zhut Up !
_______
Bah, actually my english is poor, but...
forget it xDDDD
Virion
Competition winner
Posts: 2148 Joined: Mon Dec 18, 2006 5:04 am
Post
by Virion » Wed Sep 19, 2007 5:41 am
In linux it is very simple. I am using code::blocks, select project type as "GUI" then ta'da' no console coming out.