我从网上下载了一个修改类名的程序
发现在IDE环境下可以正常运行,并改变了窗口类名
但生成EXE后就行了,经过调试后发再问题出现在 GetClassInfoLong 上
IDE环境中返回正常,生成EXE后就返回0了
百度上一条相关信息也没有,只得求助大家了
先谢了!就是 Module1 模块中的这句出错!
If GetClassInfoLong(App.hInstance, (.lpClassName And &HFFFF0000), wc2) Then '此处有错误源码下载: http://www.520wife.com/chageclassname.rar
发现在IDE环境下可以正常运行,并改变了窗口类名
但生成EXE后就行了,经过调试后发再问题出现在 GetClassInfoLong 上
IDE环境中返回正常,生成EXE后就返回0了
百度上一条相关信息也没有,只得求助大家了
先谢了!就是 Module1 模块中的这句出错!
If GetClassInfoLong(App.hInstance, (.lpClassName And &HFFFF0000), wc2) Then '此处有错误源码下载: http://www.520wife.com/chageclassname.rar
Public Sub WndHookProc_BeforeCreation(lpCWStruct As tCWSTRUCT)
With g_oWCHooker
With lpCWStruct
'如果不目标窗口则退出此过程
If InStr(StrFromPtr(.lpWindowName), TARGET_WINDOW_CAPTION) = 0 Then Exit Sub
'----------------- 更改窗体类名 -----------------
Dim wc As WNDCLASS
Dim wc2 As WNDCLASS2
Dim lClassAtom As Long
If GetClassInfoLong(App.hInstance, (.lpClassName And &HFFFF0000), wc2) Then '此处生成EXE后就始终返回0
If GetClassInfo(App.hInstance, MY_CLASS_NAME, wc) Then
Call UnRegClass
End If
With wc2
wc.cbClsextra = .cbClsextra
wc.cbWndExtra2 = .cbWndExtra2
wc.hbrBackground = .hbrBackground
wc.hCursor = .hCursor
wc.hIcon = .hIcon
wc.hInstance = .hInstance
wc.lpfnwndproc = .lpfnwndproc
wc.lpszMenuName = .lpszMenuName
wc.style = .style
wc.lpszClassName = MY_CLASS_NAME
End With
lClassAtom = RegisterClass(wc)
lClassAtom = (lClassAtom And &HFFFF&)
MsgBox "a"
If lClassAtom Then
.lpClassName = lClassAtom
End If
End If
End With
End With
End Sub
If GetClassInfoLong(App.hInstance, (.lpClassName And &HFFFF&), wc2) Then
'此处生成EXE后就始终返回0
Private Declare Function FindAtom Lib "kernel32" Alias "FindAtomA" (ByVal lpString As String) As IntegerPrivate Declare Function RegisterClass Lib "user32" Alias "RegisterClassA" (Class As WNDCLASS) As Long
Private Declare Function UnregisterClass Lib "user32" Alias "UnregisterClassA" (ByVal lpClassName As String, ByVal hInstance As Long) As Long
Private Declare Function GetClassInfo Lib "user32" Alias "GetClassInfoA" (ByVal hInstance As Long, ByVal lpClassName As String, lpWndClass As WNDCLASS) As Long
Private Declare Function GetClassInfoLong Lib "user32" Alias "GetClassInfoA" (ByVal hInstance As Long, ByVal hAtom As Long, lpWndClass As WNDCLASS2) As LongPrivate Type WNDCLASS2
style As Long
lpfnwndproc As Long
cbClsextra As Long
cbWndExtra2 As Long
hInstance As Long
hIcon As Long
hCursor As Long
hbrBackground As Long
lpszMenuName As Long
lpszClassName As Long
End Type
Private Type WNDCLASS
style As Long
lpfnwndproc As Long
cbClsextra As Long
cbWndExtra2 As Long
hInstance As Long
hIcon As Long
hCursor As Long
hbrBackground As Long
lpszMenuName As Long
lpszClassName As String
End TypePublic Type tCWSTRUCT
dwExStyle As Long
lpClassName As Long
lpWindowName As Long
dwStyle As Long
x As Long
y As Long
nWidth As Long
nHeight As Long
hWndParent As Long
hMenu As Long
hInstance As Long
lpParam As Long
End Type
Public Const MY_CLASS_NAME As String = "我的类名"
还有你察看下.lpClassName值是多少
生成EXE后 LastDllError 返回是 1411,.lpClassName 是 49585