🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12751

Re: WriteFile(to COM1)

#12751
From: Nicholas Gessler
Date: Thu, 20 Nov 2003 01:52
36 lines
2017 bytes
"Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> wrote:

>        DWORD dwWritten = 0;
>        WriteFile(hComm, "w01", 3, &dwWritten, NULL);

Great!  Thanks...  This works...

But I forgot that the "w" should be ASCII,
and the "0" and "1" should be the ASCII equivalents
("NUL" and "SOH") of the binary codes for "0" and "1"." 

This code snippet works, but I'm sure there's a better way:
      char zero = 0;
      char one = 1;
      WriteFile(hComm, "w", 1, &dwWritten, NULL);
      WriteFile(hComm, &zero, 1, &dwWritten, NULL);
      WriteFile(hComm, &one, 1, &dwWritten, NULL);

This also works:
      char zero = 0;
      char one = 1;
      for (char i = 0; i < 10; i++) {
         WriteFile(hComm, "w", 1, &dwWritten, NULL);
         WriteFile(hComm, &i, 1, &dwWritten, NULL);
         WriteFile(hComm, &one, 1, &dwWritten, NULL);
      }

I would like to use a syntax like this, but it does NOT work:
      WriteFile(hComm, "w", 1, &dwWritten, NULL);
      WriteFile(hComm, 0, 1, &dwWritten, NULL);
      WriteFile(hComm, 1, 1, &dwWritten, NULL);

Is there a way to do something similar to this?

Nick
Technical Details
Message-ID: <3fbc2c5f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fbc160d$1@newsgroups.borland.com> <3fbc1f3c@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,bcf3c83168a0fa3a
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-11-19 19:09:25 PST
From: "Nicholas Gessler" <gessler@ucla.edu>
Sender: "Nicholas Gessler" <gessler@ucla.edu>
Reply-To: "Nicholas Gessler" <gessler@ucla.edu>
Subject: Re: WriteFile(to COM1)
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 4.60.102.178     
References: <3fbc160d$1@newsgroups.borland.com> <3fbc1f3c@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <3fbc2c5f$1@newsgroups.borland.com>
Date: 19 Nov 2003 18:52:15 -0700
X-Trace: newsgroups.borland.com 1069296735 207.105.83.66 (19 Nov 2003 18:52:15 -0700)
Lines: 36
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail