473,800 Members | 2,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::WriteL ine(S"Forms Example");
Application::Ru n(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 1832
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:CONSO LE for CUI applications and
/SUBSYSTEM:WINDO WS 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
6144
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 file as folows. I need help to resolve them ASAP: cl /c /nologo /MDd /W3 /Od /GR /GM /Zi /GX /D "_DEBUG" /D " WIN32" /D "_W INDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /
11
454
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 as my app is a winmain app this wouldn't be nice. I could use DeleteFile, but you can not use wildcards in this one. How could I do this using Windows functions?
18
3188
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 you have your ".cpp" files all ready, without any "#include" or "#define" in them. Let's assume that there's 2 source files in this project, "a.cpp" and
2
8840
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 reference to `SDL_SetModuleHandle' undefined reference to `SDL_main' If I delete the SDL linker I get undefined reference to
1
7505
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 a bunch of "missing ;" errors. I did reinstall the whole thing a few times but it didn't work. Anyone have any idea? Thanks c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xutility(862) :
1
4573
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 <iostream.h> in some way examples to the error messages c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\streamb.h(90): error C2872: 'ios' : ambiguous symbo c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\streamb.h(90): error C2872:...
8
4806
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 that these are coming from the same header and refer to the same things instead of making two different copies?
12
17502
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 'char *' in this line if (__argv = 'file'){}; I am very lost with this error and any help would be apreaceated int WINAPI WinMain(HINSTANCE hInstance, //handle to current instance HINSTANCE hPrevInstance, //pointer to the previous instance...
0
9695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10514
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10287
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10260
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10042
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6826
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5616
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3770
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.