Results 1 to 5 of 5

Thread: What does err.lastdllerror 87 mean after OpenProcess(PROCESS_QUERY_LIMITED_INFORMATIO

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2017
    Posts
    344

    Question What does err.lastdllerror 87 mean after OpenProcess(PROCESS_QUERY_LIMITED_INFORMATIO

    Hello!

    I am running the following code to find out the name of a process from a process ID.

    However, hProcess is always 0, and Err.LastDLLError is 87.

    Code:
    Public Function GetExePathFromProcessID(ByVal idProc As Long) As String
    
        Dim sBuf As String
        Dim sChar As Long, l As Long, hProcess As Long
        hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, idProc)  ' Or PROCESS_VM_READ or would only work if admin!
        If hProcess Then
            sBuf = VBA.String(260, vbNullChar)
            sChar = GetProcessImageFileName(hProcess, sBuf, 260)
            
            Debug.Assert False 'todo
          
            CloseHandle hProcess
        Else
            Dim lErr&
            lErr = Err.LastDLLError
            Debug.Print lErr
        End If
        
    End Function
    What does this error code mean?

    Thank you!

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: What does err.lastdllerror 87 mean after OpenProcess(PROCESS_QUERY_LIMITED_INFORM

    87 The parameter is incorrect. ERROR_INVALID_PARAMETER

  3. #3
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: What does err.lastdllerror 87 mean after OpenProcess(PROCESS_QUERY_LIMITED_INFORM

    Start Command Prompt and type “net helpmsg 87” without the quotes.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2017
    Posts
    344

    Re: What does err.lastdllerror 87 mean after OpenProcess(PROCESS_QUERY_LIMITED_INFORM

    Thank you. It seems to occur if idProc does not point to an existing process id.

  5. #5
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,057

    Re: What does err.lastdllerror 87 mean after OpenProcess(PROCESS_QUERY_LIMITED_INFORM

    This one has been running fine for me

    https://github.com/dzzie/libs/blob/b...sInfo.cls#L833

Tags for this Thread

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