Click here to Skip to main content
15,914,070 members
Home / Discussions / COM
   

COM

 
GeneralI can't get the body of the mail Pin
ting66820-Oct-04 21:19
ting66820-Oct-04 21:19 
GeneralGet Recipients of a mail inbox using mapi Pin
ting66820-Oct-04 21:09
ting66820-Oct-04 21:09 
GeneralExcel Project DLL's Pin
Jeremy Ouellette20-Oct-04 9:28
Jeremy Ouellette20-Oct-04 9:28 
GeneralMAPI thows Cannot change thread mode after it is set exception Pin
Gavin Jeffrey20-Oct-04 4:22
Gavin Jeffrey20-Oct-04 4:22 
GeneralWord Automation - set underline font Pin
onyx19-Oct-04 20:55
onyx19-Oct-04 20:55 
Generalshell extension dll not loaded for Win98. Pin
Abhi Lahare18-Oct-04 21:18
Abhi Lahare18-Oct-04 21:18 
Generalserial port communication Pin
Anonymous18-Oct-04 13:50
Anonymous18-Oct-04 13:50 
GeneralRe: serial port communication Pin
Cedric Moonen18-Oct-04 22:11
Cedric Moonen18-Oct-04 22:11 
Hi !

First, you are in the wrong forum. In fact this is not a forum about COM ports but about Component Object Modeling Wink | ;) . Try better the C++ forum, you'll have more chance to get a response there.

For your question: the code to use to open the port:

hCom = CreateFile(pszPortName,<br />
    GENERIC_READ | GENERIC_WRITE,<br />
    0,    /* comm devices must be opened w/exclusive-access */<br />
    NULL, /* no security attrs */<br />
    OPEN_EXISTING, /* comm devices must use OPEN_EXISTING */<br />
    0,    /* not overlapped I/O */<br />
    NULL  /* hTemplate must be NULL for comm devices */<br />
    );<br />


pszPortName is the name of your port ("COM1","COM2",...)

You can then set some parameters of your port (baudrate, partiy,...):

	DCB dcb;<br />
	BOOL fSuccess;<br />
	DWORD dwError;<br />
<br />
	// Get the current configuration.<br />
	fSuccess = GetCommState(hCom, &dcb);<br />
<br />
	if (!fSuccess) <br />
        {<br />
		dwError=GetLastError();<br />
		return dwError;<br />
	}<br />
<br />
	dcb.BaudRate=9600;<br />
	dcb.StopBits=1;<br />
	dcb.fParity=1;<br />
	dcb.fDtrControl=DTR_CONTROL_DISABLE;<br />
	dcb.fRtsControl=RTS_CONTROL_DISABLE;<br />
	<br />
	fSuccess = SetCommState(hCom, &dcb);


Then use the ReadFile and WriteFile functions...

Hope this helps
GeneralNtier app Pin
StephenMcAllister18-Oct-04 7:53
StephenMcAllister18-Oct-04 7:53 
GeneralScript hosting applicatrion has problem Pin
Anonymous17-Oct-04 21:30
Anonymous17-Oct-04 21:30 
GeneralClass not registered Pin
Minh17-Oct-04 15:44
Minh17-Oct-04 15:44 
GeneralRe: Class not registered Pin
vikramlinux26-Oct-04 20:13
vikramlinux26-Oct-04 20:13 
GeneralDOS client/server (C++)... Pin
porac6917-Oct-04 5:56
porac6917-Oct-04 5:56 
QuestionHow to Create Events Pin
ThatsAlok16-Oct-04 3:55
ThatsAlok16-Oct-04 3:55 
Questionhow to invoke com event Pin
ThatsAlok15-Oct-04 3:52
ThatsAlok15-Oct-04 3:52 
AnswerRe: how to invoke com event Pin
Lim Bio Liong16-Oct-04 19:23
Lim Bio Liong16-Oct-04 19:23 
GeneralRe: how to invoke com event Pin
ThatsAlok17-Oct-04 18:19
ThatsAlok17-Oct-04 18:19 
GeneralODBC, SQL Server, &quot;FOR XML&quot; &amp; Cursors error Pin
zoltanie14-Oct-04 6:04
zoltanie14-Oct-04 6:04 
Questionexe com server problem? Pin
G.Richard13-Oct-04 21:12
G.Richard13-Oct-04 21:12 
AnswerRe: exe com server problem? Pin
User 21559714-Oct-04 19:44
User 21559714-Oct-04 19:44 
GeneralRe: exe com server problem? Pin
G.Richard14-Oct-04 20:49
G.Richard14-Oct-04 20:49 
GeneralRe: exe com server problem? Pin
Lim Bio Liong15-Oct-04 1:52
Lim Bio Liong15-Oct-04 1:52 
AnswerRe: exe com server problem? Pin
darkbyte11-Nov-04 10:34
darkbyte11-Nov-04 10:34 
GeneralSaving message using MAPI Pin
Madmaximus13-Oct-04 7:02
Madmaximus13-Oct-04 7:02 
GeneralDecode HRESULT from URLDownloadToFile() (e.g.0x800C0005) Pin
Eugene Homyakov13-Oct-04 6:26
Eugene Homyakov13-Oct-04 6:26 

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.