API函数提问:Findwindow和Sendmessage
Private Declare Function FindWindow Lib "User " (ByVal lpClassName _
As String, ByVal lpWindowName As String) As Integer
Private Declare Function PostMessage Lib "User " (ByVal hwnd _
As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
lParam As Any) As Integer
Private Const WM_QUIT = &H12
Private Const WM_CLOSE = &H10
Private Sub Command1_Click()
Handle = FindWindow( "#32770 (对话框) ", "与 /dbBill★ 聊天中 ")
PostMessage Handle, WM_QUIT, 0, 0
End Sub
以上代码在VB6.0运行为什么总是出现如下错误提示:
实时错误 '53 '
文件未找到:User
句柄和主题我都用MC SPY++得到的.应该不会错啊!
如何才能正确的关闭一个正在运行的外部程序?
[解决办法]
API函数声明错误
user
改成USER32
后面加上函数别名Alias
Private Declare Function FindWindow Lib "User32 " Alias "FindWindowA "(ByVal lpClassName _
As String, ByVal lpWindowName As String) As Integer
Private Declare Function PostMessage Lib "User32 " Alias "PostMessageA "(ByVal hwnd _
As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
lParam As Any) As Integer
[解决办法]
Private Declare Function FindWindow Lib "User "
这里有问题,是说 User 这个DLL文件可能 你的系统被删除了,找不到
所以没法加载API