CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: why didnt work

  1. #1
    Join Date
    Mar 2001
    Posts
    13

    why didnt work

    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


  2. #2
    Join Date
    Sep 2000
    Posts
    153

    Re: why didnt work

    Without trying it, I would say you may need to declare your SECURITY_ATTRIBUTES as byval.

    Just a thought.

    --Joey


  3. #3
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: why didnt work

    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
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured