My problem is that I want to create a handle til a com-port, in ordre to
query the status of the particular port, without taking control over the
port.
I order to query the port-status, I have to obtain a handle to the port
with the Cratefile function. According to the dokumentation on MSDN, the
code should be this:
retval = CreateFile("COM2", 0, 0, Null, OPEN_EXISTING, 0, Null)
This line results in error 94, 'Invalid use of Null'
What am I doing wrong?
Please help.
don't think this is quite the right newsgroup (really you want an api
group, methinks -- not sure of any offhand). unless of course you're
writing this for a driver. either way...
> I order to query the port-status, I have to obtain a handle to the
> port with the Cratefile function. According to the dokumentation on
> MSDN, the code should be this:
> retval = CreateFile("COM2", 0, 0, Null, OPEN_EXISTING, 0, Null)
> This line results in error 94, 'Invalid use of Null'
hmm. off the top of my head... is this a direct cut-n-paste from your
code??? if so, it's prolly the capitalisation of "Null"... change the
code so it reads
retval = CreateFile("COM2", 0, 0, NULL, OPEN_EXISTING, 0, NULL);
^^^^ ^^^^
of course, if this is already the case, and it wasn't a cut-n-paste,
then i have no idea what's wrong.
g'luck,
'bod
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
> retval = CreateFile("COM2", 0, 0, Null, OPEN_EXISTING, 0, Null)
Are you using VB? If so, "Null" probably means something other than "0".
When a Win32 API expects a pointer and you want to pass what C calls a
NULL pointer, you need a numeric zero.
--
Cheers,
Felix.
If you post a reply, kindly refrain from emailing it, too.
Note to spammers: fel...@mvps.org is my real email address.
No anti-spam address here. Just one comment: IN YOUR FACE!
You need
CreateFile("COM2", GENERIC_READ | GENERIC_WRITE, NULL, NULL, OPEN_EXISTING, 0,
NULL)
There is no way to query the port status except to try and open it for I/O.
> You need
> CreateFile("COM2", GENERIC_READ | GENERIC_WRITE, NULL, NULL,
> OPEN_EXISTING, 0, NULL)
> There is no way to query the port status except to try and open it
> for I/O.
not according to the api info (unless there's something in
MSDN/Knowledgebase that says otherwise). in the api info, it says of
setting the second parameter to '0'...
"Specifies device query access to the object. An application can
query device attributes without accessing the device."
so, according to this, querying is possible without read/write access
-- but then i haven't check the knowledgebase, so...
cheer,