home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Microsoft Programmer's Library 1.3
/
Microsoft-Programers-Library-v1.3.iso
/
sampcode
/
win_lrn
/
comm
/
opencomm.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-08-10
|
1KB
|
38 lines
/*
* OpenComm
*
* This program demonstrates the use of the function OpenComm.
* It opens a communication device and assign a handle to it. The
* communication device is initialized to a default configuration.
* Spaces are allocated for the "recieve" and "transmit" queues.
* The communication port must be close before it can be open again with
* OpenComm.
*
*/
#include "windows.h"
int PASCAL WinMain (hInstance, hPrevInstance, lpszCmdLine, cmdShow)
HANDLE hInstance, hPrevInstance;
LPSTR lpszCmdLine;
int cmdShow;
{
short nCid; /* short integer identifying the opened
* communication device */
nCid = OpenComm ( (LPSTR)"COM1", 20, 20);
if (nCid >= 0)
MessageBox (GetFocus (), (LPSTR)"Com port opened!!", (LPSTR)"OK", MB_OK);
else
{
MessageBox (GetFocus (), (LPSTR)"Com port not opened!!",
(LPSTR)"FAIL!", MB_OK);
return 0;
}
CloseComm (nCid);
return 0;
}