Click to See Complete Forum and Search --> : why didnt work


gambit
March 26th, 2001, 08:06 PM
hi,

Is the following statement correct?

Declare Function CreateFile Lib "Kernel32" Alias "CreateFileA" (byval lpFileName as string, byval dwDesiredAccess as Long, byval dwShareMode as Long, lpSecurityAttributes as SECURITY_ATTRIBUTES, byval dwCreationDisposition as Long, byval dwFlagsAndAttributes as Long, byval hTemplateFile as Long) as Long

Type SECURITY_ATTRIBUTES
nLength as Long
lpSecurityDescriptor as Long
bInheritHandle as Long
End Type

Dim sec as SECURITY_ATTRIBUTES
Dim hDevice as Long

hDevice = CreateFile ("\\.\MyHook.vxd", 0, 0, sec, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE,0)





I do not understand why it is unable to get the handle of a VXD file which I created. But in VC++ using the same function, I am able to get it.

Hope someone can help.

Thanks

FiendSC
March 26th, 2001, 11:33 PM
Without trying it, I would say you may need to declare your SECURITY_ATTRIBUTES as byval.

Just a thought.

--Joey

Clearcode
March 27th, 2001, 02:09 AM
To find out why an API call failed use:

'\\ -- [ LastSystemError ]------------------------------------------------------------------
'\\ Returns the message from the system which describes the last dll error to occur, as
'\\ held in Err.LastDllError. This function should be called as soon after the API call
'\\ which might have errored, as this member can be reset to zero by subsequent API calls.
'\\ ----------------------------------------------------------------------------------------
'\\ You have a royalty free right to use, reproduce, modify, publish and mess with this code
'\\ I'd like you to visit http://www.merrioncomputing.com for updates, but won't force you
'\\ ----------------------------------------------------------------------------------------
public Function LastSystemError() as string

Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
Dim sError as string * 500 '\\ Preinitilise a string buffer to put any error message into
Dim lErrNum as Long
Dim lErrMsg as Long

lErrNum = Err.LastDllError

lErrMsg = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, byval 0&, lErrNum, 0, sError, len(sError), 0)

LastSystemError = Trim(sError)

End Function




HTH,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com