About CreateFile on vista?

  • Thread starter =?gb2312?B?wO66o7H1?=
  • Start date
?

=?gb2312?B?wO66o7H1?=

My code :
hHandle = CreateFile( pSpDevIntfsDetData->DevicePath,
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
and i run this code in vista ,it return the lasterror 5. tell me no
Privileges. why i can get the Privileges to run creatfile?
 
G

Guest

What does pSpDevIntfsDetData->DevicePath point to?

There are two reasons this might fail. First, you could be trying to open a
file that you do not have read or write permissions to. Second, you could be
trying to open a file that already exists.

Try modifying the flags to see what happens. Change CREATE_NEW to
OPEN_EXISTING and see what happens. If that works the file exists and you
need to use OPEN_ALWAYS instead. Also, change the dwDesiredAccess to
MAXIMUM_ALLOWED and check the permissions you get back on the handle to see
what perms you have (or, easier still, just look at the permissions on the
file). You don't want to use MAXIMUM_ALLOWED in production code, but it is
useful for testing like this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top