Click here to Skip to main content
15,913,722 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Can anyone help me understand this code better? Pin
Christian Graus18-May-04 11:29
protectorChristian Graus18-May-04 11:29 
GeneralRe: Can anyone help me understand this code better? Pin
Ryan Binns18-May-04 18:39
Ryan Binns18-May-04 18:39 
Generali need to get the chat text of msm messanger Pin
Member 96792618-May-04 9:28
Member 96792618-May-04 9:28 
GeneralRe: i need to get the chat text of msm messanger Pin
Member 42102519-May-04 10:35
Member 42102519-May-04 10:35 
GeneralSerial Port Communication in WinXP (or NT/2000) Pin
AnotherProgrammer18-May-04 8:52
AnotherProgrammer18-May-04 8:52 
GeneralRe: Serial Port Communication in WinXP (or NT/2000) Pin
Antti Keskinen18-May-04 9:07
Antti Keskinen18-May-04 9:07 
GeneralRe: Serial Port Communication in WinXP (or NT/2000) Pin
AnotherProgrammer18-May-04 9:56
AnotherProgrammer18-May-04 9:56 
GeneralRe: Serial Port Communication in WinXP (or NT/2000) Pin
Antti Keskinen18-May-04 20:40
Antti Keskinen18-May-04 20:40 
The sample program is written for a console application. Thus, the main function takes two parameters. The first one is a count of arguments, and is always equal or greater to 1. Having 1 there means that there are no actual arguments. The second is a pointer to a character string that specifies these arguments.

These parameters are filled in by the OS when you execute this program. There is no need for you to use them, if you don't want to, but they offer a change for run-time control of the program. The parameter variables are not used: the program, although it offers the use of parameters, doesn't support them. They do nothing, so to speak.

The data types DCB, HANDLE and BOOL are Windows Data Types. They are (mostly) defined in Windows.h, but you can find explanations from MSDN Library as well. DCB is a structure that depicts the format of a serial port. You fill this structure with relevant data (it has members for that), and send it to a serial port. Thus, the serial port gets configured to match your needs. You can set things like baud rate, parity bit, stop bit etc through this structure.

HANDLE, on the other hand, represents the HAL (Hardware Abstraction Layer) -provided symbol of the data or a device requested. In english, everything in Windows is handles. You have a handle to a file, a handle to a brush or pen, a handle to a window (critical) and a handle to a program instance. You can consider it as a "tree of classes". HANDLE is the parent class, representing a handle of an object. HINSTANCE is a derived one, representing a specialized handle, a handle to a program instance. In real, none of these are actual classes. But thinking them like such makes things a bit easier to understand. Because there are no "a handle to a port", the general HANDLE is used instead.

BOOL represents a boolean value in Windows: < 1 = false, > 1 = true. It exists because old Windows programming platform (3.1 or something) didn't have support for the actual C++ 'boolean' value, bool. This variable (BOOL) is made to emulate a boolean value in Windows environment. But basically, this and the C++ boolean are one and a same thing nowadays. The variable is provided for backward-compatibility.

All these questions (and many more) about Windows-programming are answered in Charles Peltzoid's excellent book 'Programming Windows'. It is _the_ bible of every Windows-developer. I suggest you to grab it from a local bookstore or a library and read it through. It will clarify many issues to you, giving exact knowledge of what the handles really are, how they work, and how to use them.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: Serial Port Communication in WinXP (or NT/2000) Pin
closecall18-May-04 15:07
closecall18-May-04 15:07 
GeneralRe: Serial Port Communication in WinXP (or NT/2000) Pin
valikac18-May-04 16:51
valikac18-May-04 16:51 
GeneralHelp needed urgent! Pin
ben218-May-04 7:13
ben218-May-04 7:13 
GeneralRe: Help needed urgent! Pin
David Crow18-May-04 7:17
David Crow18-May-04 7:17 
GeneralRe: Help needed urgent! Pin
ben218-May-04 7:32
ben218-May-04 7:32 
GeneralRe: Help needed urgent! Pin
David Crow18-May-04 7:45
David Crow18-May-04 7:45 
Questionhow to change window icon Pin
vividtang18-May-04 7:01
vividtang18-May-04 7:01 
AnswerRe: how to change window icon Pin
David Crow18-May-04 7:15
David Crow18-May-04 7:15 
GeneralRe: how to change window icon Pin
vividtang18-May-04 7:19
vividtang18-May-04 7:19 
GeneralRe: how to change window icon Pin
David Crow18-May-04 7:21
David Crow18-May-04 7:21 
AnswerRe: how to change window icon Pin
sps-itsec4618-May-04 8:20
sps-itsec4618-May-04 8:20 
GeneralRe: how to change window icon Pin
vividtang18-May-04 8:27
vividtang18-May-04 8:27 
Generalabout path Pin
vividtang18-May-04 6:56
vividtang18-May-04 6:56 
GeneralRe: about path Pin
David Crow18-May-04 7:09
David Crow18-May-04 7:09 
GeneralRe: about path Pin
Maximilien18-May-04 7:15
Maximilien18-May-04 7:15 
Generalabout SetWindowText() and change window default style Pin
vividtang18-May-04 6:44
vividtang18-May-04 6:44 
GeneralRe: about SetWindowText() and change window default style Pin
Anonymous18-May-04 7:37
Anonymous18-May-04 7:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.