PC Review


Reply
Thread Tools Rate Thread

About CreateFile on vista?

 
 
=?gb2312?B?wO66o7H1?=
Guest
Posts: n/a
 
      7th Nov 2007
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?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmVzcGVy?=
Guest
Posts: n/a
 
      10th Nov 2007
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.
---
Your question may already be answered in Windows Vista Security:
http://www.amazon.com/gp/product/047...otectyourwi-20


"李海滨" wrote:

> 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?
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with CreateFile API function Jim Flanagan Microsoft VB .NET 2 26th Nov 2006 10:54 PM
CreateFile() and usb mike Windows XP Drivers 0 16th Sep 2006 06:14 PM
CreateFile JLW Microsoft C# .NET 4 9th Jun 2004 04:43 PM
vb.net's CreateFile Stephen Remde Microsoft VB .NET 8 10th Nov 2003 12:24 PM
Re: USB and CreateFile Rob Microsoft Windows 2000 0 3rd Sep 2003 11:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:43 AM.