Hi,
In windows Server 2008 R2,call createFile failed.
…
char strCom[20] = {0},
sprintf(strCom,“\\.\COM1”);
hDevice = CreateFile(
strCOM,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL
);
…
In other windows such as windows 7 X64,i can get device handle.
But in windows server 2008 R2 createFile failed.
Err code is ERROR_ACCESS_DENIED.
I found after
sprintf(strCom,“\\.\COM1”);
//strCom is \\.\COM1 in Windows server 2008 R2,but it is \.\COM1 in other windows.
The same code ,why have different chat input.
Any help is appreciated.Thanks.
Best Regards
xxxxx@yahoo.com.cn wrote:
In windows Server 2008 R2,call createFile failed.
…
char strCom[20] = {0},
sprintf(strCom,“\\.\COM1”);
hDevice = CreateFile(
strCOM,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL
);
…
In other windows such as windows 7 X64,i can get device handle.
But in windows server 2008 R2 createFile failed.
Err code is ERROR_ACCESS_DENIED.
Does your Server 2008 R2 system actually have a physical COM port? Many
systems these days do not.
I found after
sprintf(strCom,“\\.\COM1”);
//strCom is \\.\COM1 in Windows server 2008 R2,but it is \.\COM1 in other windows.
No, it’s not. This is a fundamental C issue. That string in memory is
9 bytes long:
\ \ . \ C O M 1 0x00
In order to express that string in C, you have to spell it
“\\.\COM1”. The operating system is utterly irrelevant.
The same code ,why have different chat input.
Any help is appreciated.Thanks.
Best Regards
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
xxxxx@yahoo.com.cn wrote:
Hi,
In windows Server 2008 R2,call createFile failed.
…
char strCom[20] = {0},
sprintf(strCom,“\\.\COM1”);
hDevice = CreateFile(
strCOM,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL
);
…
In other windows such as windows 7 X64,i can get device handle.
But in windows server 2008 R2 createFile failed.
Err code is ERROR_ACCESS_DENIED.
Your parameters here say that you are unwilling to share the device. Is
it possible some other application already has the COM port open?
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
COM ports are exclusive devices, it doesn’t matter if you ask for shared access, the driver enforces exclusive.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Monday, May 11, 2015 11:03 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] windows server 2008 R2 createFile failed
xxxxx@yahoo.com.cn wrote:
Hi,
In windows Server 2008 R2,call createFile failed.
…
char strCom[20] = {0},
sprintf(strCom,“\\.\COM1”);
hDevice = CreateFile(
strCOM,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL
);
…
In other windows such as windows 7 X64,i can get device handle.
But in windows server 2008 R2 createFile failed.
Err code is ERROR_ACCESS_DENIED.
Your parameters here say that you are unwilling to share the device. Is it possible some other application already has the COM port open?
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
hDevice = CreateFile(
strCOM,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
0,
CREATE_ALWAYS,
0,
NULL
);
First App createFile success, not close handle.Second App try createFile,but failed.
How can I realize two app createFile meantime ?
Thanks.
The second create fails because the closehandle did not finish. Do you hav e any pending you when you close the handle?
d
Bent from my phone
From: xxxxx@yahoo.com.cnmailto:xxxxx
Sent: ?5/?11/?2015 8:40 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] windows server 2008 R2 createFile failed
hDevice = CreateFile(
strCOM,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
0,
CREATE_ALWAYS,
0,
NULL
);
First App createFile success, not close handle.Second App try createFile,but failed.
How can I realize two app createFile meantime ?
Thanks.
—
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>
Thanks,Doron.
If I close the handle,the second app createfile is Ok.
I want to realize that the second app createfile is Ok when the first app has not close the handle?
Com ports are exclusive open devices, only one handle can be opened at any given time. End of story.
d
Bent from my phone
From: xxxxx@yahoo.com.cnmailto:xxxxx
Sent: ?5/?11/?2015 10:38 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] windows server 2008 R2 createFile failed
Thanks,Doron.
If I close the handle,the second app createfile is Ok.
I want to realize that the second app createfile is Ok when the first app has not close the handle?
—
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>
I just wonder where Chris is - he seems to love posts like that…
Anton Bassov
anton bassov wrote:
I just wonder where Chris is - he seems to love posts like
that…
I’m more impressed that the guy tried to open a stateful file handle more than once.
Let me guess the title of the next post: “windows server 2008 R2 readFile failed”…
> I’m more impressed that the guy tried to open a stateful file handle more than once.
Vow!!! Actually, I overlooked this one…
To be honest, I got so impressed with the OP’s “knowledge” of C that I did not even read his subsequent “masterpieces”…
Let me guess the title of the next post: “windows server 2008 R2 readFile failed”…
Well, it’s hard to say how it all goes. For example, once we take the piss out of him he may get “offended” and decide to look for help elsewhere. At this point we may see “don’t send me any more replies.every patience has its limits” posts all over the NTDEV for few weeks…
Anton Bassov