Jump to content

Recommended Posts

Posted (edited)

I searched the forums first but I found limited information concerning _WinAPI_CreateFileEx(). What's the difference between that and this one: _WinAPI_CreateFile()? There must be some difference between the two. If I feed them both the same arguments _WinAPI_CreateFile() will not work while _WinAPI_CreateFileEx() does work.

Local Const $FileName = $DevicePath ; Ex: G:\\
Local Const $DesiredAccess = $GENERIC_READ
Local Const $ShareMode = BitOR($FILE_SHARE_READ, $FILE_SHARE_WRITE)
Local Const $SecurityAttributes = 0
Local Const $CreationDisposition = $OPEN_EXISTING
Local Const $FlagsAndAttributes = BitOR($FILE_FLAG_BACKUP_SEMANTICS, $FILE_ATTRIBUTE_NORMAL)
Local Const $TemplateFile = 0

Local Const $DevHandle1 = _WinAPI_CreateFileEx($FileName, $CreationDisposition, $DesiredAccess, $ShareMode, $FlagsAndAttributes, $SecurityAttributes, $TemplateFile)
Local Const $DevHandle2 = _WinAPI_CreateFile($FileName, $CreationDisposition, $DesiredAccess, $ShareMode, $FlagsAndAttributes, $SecurityAttributes)

(WinAPIEx.au3)
DllCall('kernel32.dll', 'ptr', 'CreateFileW', 'wstr', $sFile, 'dword', $iAccess, 'dword', $iShare, 'ptr', DllStructGetPtr($tSecurity), 'dword', $iCreation, 'dword', $iFlagsAndAttributes, 'ptr', $hTemplate)

(WinAPI.au3)
DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sFileName, "dword", $iDA, "dword", $iSM, "ptr", $pSecurity, "dword", $iCD, "dword", $iFA, "ptr", 0)

I can see that there different types but they are essentially the same. WinAPI_CreateFile() works in other cases.

Ok, I'm probably going to add to this post a few thousand times, so if you're interested in this then keep checking back.

Edited by jaberwocky6669
Posted

For example, how do you set FILE_FLAG_WRITE_THROUGH or other FILLE_FLAG_* flags by using _WinAPI_CreateFile()? Unlike _WinAPI_CreateFile(), _WinAPI_CreateFileEx() works directly with WinAPI constants. Therein lies the difference.

Posted (edited)

The mouse runs underneath the cats nose.

Thanks for pointing that out for me, Yashied. I have been confused about that for quite a while.

Edited by jaberwocky6669

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...