473,322 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

include files for WinMain

I am working from the C++ .net step by step book ...

my project compiles and runs as a console application:

#include "stdafx.h"
#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>

int wmain(void)
{
Console::WriteLine(S"Forms Example");
Application::Run(new CppForm());
return 0;
}

Now I would like to get rid of the console part of the appl, so I
replace
int wmain( void )

with:
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow )

and the compiler does not know what HINSTANCE is.

so I add an include stmt:
#include <windef.h>

and all hell breaks loose. undefined this, what is that, ...

1st question: is it "wmain" that makes a console application? and
WinMain makes a window application?

2nd question: what include files are needed to use "WinMain" as the
program entry point?

3rd question: is there a good MS document that explains all the
different include files in C++ .NET and when to use them?
thanks,

Steve Richter
Nov 16 '05 #1
1 1798
Hi Steve,

Thanks for posting in the group!

"When you use Microsoft Visual C++ to create an application project, the
integrated environment sets up various linker switches so that the linker
embeds the proper type of subsystem in the resulting executable. This
linker switch is /SUBSYSTEM:CONSOLE for CUI applications and
/SUBSYSTEM:WINDOWS for GUI applications. When the user runs an application,
the operating system's loader looks inside the executable image's header
and grabs this subsystem value. If the value indicates a CUI-based
application, the loader automatically ensures that a text console window is
created for the application. If the value indicates a GUI-based
application, the loader doesn't create the console window and just loads
the application. Once the application starts running, the operating system
doesn't care what type of UI your application has." (from <<Programming
Applications for Microsoft Windows>> by Jeffrey Richter)

And the wmain is an entry-point function for CUI application that wants
Unicode characters and strings,
the WinMain for GUI application that wants ANSI characters and strings, the
specific type application needs its corresponding entry-point function.

For what include files are needed to build a windows form application in
VC.NET, I think you can create a test project in VC.NET, you can find them
in stdafx.h and Form1.cpp:

// in stdafx.h
#define WIN32_LEAN_AND_MEAN

#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

//in Form1.cpp
#include <windows.h>
Hopte that helps!
Best regards,
Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
|

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
11
by: Viviana Vc | last post by:
Hi all, I would like to delete from a directory all the files that match: bar*.* I know that I could do for instance: system("del bar*.*"), but this will bring up the command prompt window and...
18
by: JKop | last post by:
Here's what I know so far: You have a C++ project. You have source files in it. When you go to compile it, first thing the preprocessor sticks the header files into each source file. So now...
2
by: Michael Sgier | last post by:
Hi While trying to compile the follwoing example with devC++ I get errors: D:\SDL-1.2.7MingW\lib\libSDLmain.a(SDL_win32_main.o.b) (.text+0x34b) In function `console_main': undefined...
1
by: Minh | last post by:
I've just installed VS.NET 2003 on my Athlon XP 1800+. However I couldn't get any project with STL includes to compile even if I create a new empty project (and added #include <string>). It gave me...
1
by: ya man | last post by:
when i use #include <iostream.h> in some files i get lots of error messages of the kind 'ambiguous symbol this is solved when i use #include <iostream why is that ? and can i use #include...
8
by: ewpatton | last post by:
I have a header that is shared among different CPP files for constants. When Microsoft Visual C++ links the .obj files, it complains that these names are all duplicates. How can I get it to realize...
12
by: eric dexter | last post by:
I want to compare what I get on the command line in winmain with an if statement.. I am getting a beginers error but I don't have an example to use to fix it.. cannot convert from 'const int' to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.