The window of a project needs to shut off but I didnt know how to do. any help ?
Regards~
Printable View
The window of a project needs to shut off but I didnt know how to do. any help ?
Regards~
what do u mean by needs to be closed??????????
Uhhhmm.. you mean return 0;?
Do you mean you want to have a console program that dosent create a console window?
If so then write it as a window app :
just put your console code in a WinMain function.Code:#include <windows.h>
#include <stdio.h>
int WinMain( HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode )
{
FILE *fp;
if( ( fp = fopen( "temp.txt", "wt" ) ) != NULL )
fprintf( fp, "NO CONSOLE!!!" );
return 0;
}
woh~ I coulnt understand it this time. is there any simply way ? :confused:Quote:
Originally posted by C_Coder
Do you mean you want to have a console program that dosent create a console window?
If so then write it as a window app :
just put your console code in a WinMain function.Code:#include <windows.h>
#include <stdio.h>
int WinMain( HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode )
{
FILE *fp;
if( ( fp = fopen( "temp.txt", "wt" ) ) != NULL )
fprintf( fp, "NO CONSOLE!!!" );
return 0;
}
That code doesn't compile on MSVC6. Haven't programmed windows much in C++, but didn't work as a source file or win32 application.
I believe that's 'cos it's missing WINAPIQuote:
Originally posted by salvelinus
That code doesn't compile on MSVC6. Haven't programmed windows much in C++, but didn't work as a source file or win32 application.
Code:int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode)
....
>> I believe that's 'cos it's missing WINAPI
DOH, how did I leave that out!!!!
>> woh~ I coulnt understand it this time. is there any simply way
That is simple, your just putting your console code in a windows app. All you need do is have a WinMain() instead of a main(), not forgetting the WINAPI of course ;)
Still didn't work. Compiled but didn't link
I cut and pasted the code above, adding the winapi. Running MSVC 6 Enterprise.PHP Code:
inking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Cpp2.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Cpp2.exe - 2 error(s), 0 warning(s)
It didn't compile because there are some precompiler linking settings that need to be set up. If you are using VC++, just create a new project as Win32 project and not a Win32 console project.
Guys, Winapi should be mentioned anyway ? I know nothing about it. I'm used to programming under console, that's all. :rolleyes:
Hmm, I'll look into that. Thought I did that, but will try again.Quote:
Originally posted by Hershlag
It didn't compile because there are some precompiler linking settings that need to be set up. If you are using VC++, just create a new project as Win32 project and not a Win32 console project.
>> Guys, Winapi should be mentioned anyway ? I know nothing about it.
Geez its not hard, WINAPI WinMain() is just a windows version of main() for the console.
>> Still didn't work. Compiled but didn't link
>> unresolved external symbol _main
You must have created a console project as it is look for main()