I’m attempting to code up a call to GetProcessImageFileName in a VB6 application, but an getting…
Run-time error '453':
Can't find DLL entry point GetProcessImageFileName in PSAPI.DLL
I am given to understand it is to be found in PSAPI.DLL from the documentation here.
My code looks like…
Public Declare Function GetProcessImageFileName Lib "PSAPI.DLL" _
(ByVal hProcess As Long, _
lpImageName As String, _
ByVal nSize As Long) As Long
Public Sub MySub()
Dim name_length As Long
Dim image_name As String
...fill in process handle...
name_length = GetProcessImageFileName(process_handle, image_name, 1024)
Does anyone know what I should be doing here?
I’m running on Windows XP.
EDIT As suggested by JosephH, I have changed the code to use GetProcessImageFileNameA, thus…
Public Declare Function GetProcessImageFileNameA Lib "PSAPI.DLL" _
(ByVal hProcess As Long, _
lpImageName As String, _
ByVal nSize As Long) As Long
and
name_length = GetProcessImageFileNameA(process_handle, image_name, 1024)
Doing this (it’s the same with the W version) causes the program and the VB6 development environment to crash, so there’s another problem hiding in here somewhere.
It should be either
GetProcessImageFileNameAorGetProcessImageFileNameW. Most Windows API function(exceptGetProcAddress) that accepts string as an argument has two prototypes, one with ANSI (withAsuffix) and one with unicode (withWsuffix)