为什么这个VB API程序在2000下运行会出错?
窗体和模块代码如下,直接copy到VB6环境下即可,我用VB6环境在xp和2000下调试时均没有问题,但是生成EXE可执行文件在2000下运行报错是怎么回事?
窗体代码:
Private Sub Command1_Click()
Dim hThread, lpThreadID As Long
Dim a As String
g_bDone = False
g_strTitle = "Set Option"
hThread = CreateThread(ByVal 0&, ByVal 0&, AddressOf HookInputBoxThread, ByVal 0&, 0, lpThreadID)
a = Trim(InputBox("Please input the correct Password!" + vbCrLf + "Operator can not close it!", g_strTitle))
If a <> "" Then
If a = "bmpadmin" Then
'***************************
isSetting = True
cmdSend.Visible = False
CmdClr.Visible = False
frmnetSend.Height = FrmSettingHeight
SettingFrame.Top = 480
SettingFrame.Visible = True
BgBottom.Top = 2280
back.Visible = True
'***************************
Else
MsgBox "The Password isn't correct!", 0 + 16, "Warning"
'Cancel = 1
End If
Else
' Cancel = 1
End If
End Sub
模块代码如下:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function GetDlgItem Lib "user32" (ByVal hDlg As Long, ByVal nIDDlgItem As Long) As Long
Public Declare Function CreateThread Lib "kernel32" (ByVal lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, ByVal lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
Public Declare Function SetFocus Lib "user32.dll" (ByVal hwnd As Long) As Long
Public Const EM_SETPASSWORDCHAR = &HCC
Public Const HWND_TOPMOST& = -1
Public Const SWP_NOSIZE& = &H1
Public Const SWP_NOMOVE& = &H2
Public g_bDone As Boolean
Public g_strTitle As String
Public Sub HookInputBoxThread()
Do Until g_bDone
Dim h As Long, hText As Long
h = FindWindow("#32770", g_strTitle)
If h <> 0 Then
hText = GetDlgItem(h, &H1324)
If hText <> 0 Then
SendMessage hText, EM_SETPASSWORDCHAR, Asc("*"), 0
g_bDone = True
End If
End If
Loop
End Sub
补充:
1,在其它2000系统一样有问题,不知道是不是API的问题?
2,没有提示任何ocx和dll文件缺少,有提示的话早就解决了.
3,我没有打包操作,我想知道问题的根本
4,提示信息:"工程1.exe has generated errors and will be closed by Windows.You will need to restart the program.
An error log is being created."