我正在尝试在VB6应用程序中编写对GetProcessImageFileName的调用,但是得到了......
Run-time error '453':
Can't find DLL entry point GetProcessImageFileName in PSAPI.DLL
我理解它可以在文档here中的PSAPI.DLL中找到。
我的代码看起来像......
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)
有谁知道我应该在这做什么? 我在Windows XP上运行。
编辑正如JosephH所建议,我已将代码更改为使用GetProcessImageFileNameA
,因此......
Public Declare Function GetProcessImageFileNameA Lib "PSAPI.DLL" _
(ByVal hProcess As Long, _
lpImageName As String, _
ByVal nSize As Long) As Long
和
name_length = GetProcessImageFileNameA(process_handle, image_name, 1024)
执行此操作(与W版本相同)会导致程序和VB6开发环境崩溃,因此在某处隐藏了另一个问题。
答案 0 :(得分:4)
应该是GetProcessImageFileNameA
或GetProcessImageFileNameW
。接受字符串作为参数的大多数Windows API函数(除了GetProcAddress
)都有两个原型,一个带有ANSI(带有A
后缀),另一个带有unicode(带有W
后缀)
Public Declare Function GetProcessImageFileName Lib "PSAPI.DLL" Alias "GetProcessImageFileNameA" _
(hProcess As Long, _
ByVal lpImageName As String, _
nSize As Long) As Long
name_length = GetProcessImageFileNameA(process_handle, image_name, 1024)