VB如何LOADLIBRARY调用DLL文件
主要是屏蔽网页所有类型的弹出对话框。网上找了个代码,就是不会用啊,请高手指点,查了几天资料了,都没弄明白。http://
#COMPILE DLL
#DIM ALL
%USEMACROS = 1
#INCLUDE "Win32API.inc"
#INCLUDE "HookApi.Inc"
TYPE MSGBOXPARAMS
cbSize AS LONG
hWndOwner AS LONG
hInstance AS LONG
lpszText AS ASCIIZ PTR
lpszCaption AS ASCIIZ PTR
dwStyle AS LONG
lpszIcon AS ASCIIZ PTR
dwContextHelpId AS LONG
lpfnMsgBoxCallback AS LONG
dwLanguageId AS LONG
END TYPE
DECLARE FUNCTION MessageBoxIndirectW LIB "USER32.DLL" ALIAS "MessageBoxIndirectW" (lpMsgBoxParams AS MSGBOXPARAMS) AS LONG
GLOBAL ghInstance AS DWORD
GLOBAL MyMsgBoxNextHook AS DWORD
'-------------------------------------------------------------------------------
' Main DLL entry point called by Windows...
'
FUNCTION LIBMAIN (BYVAL hInstance AS LONG, _
BYVAL fwdReason AS LONG, _
BYVAL lpvReserved AS LONG) AS LONG
SELECT CASE fwdReason
CASE %DLL_PROCESS_ATTACH
ghInstance = hInstance
CALL HookAPI("user32.dll","MessageBoxIndirectW",CODEPTR(MyMsgBox),MyMsgBoxNextHook) '就是这个API MessageBoxIndirectW
FUNCTION = 1 'success!
CASE %DLL_PROCESS_DETACH
FUNCTION = 1 'success!
CASE %DLL_THREAD_ATTACH
FUNCTION = 1 'success!
CASE %DLL_THREAD_DETACH
FUNCTION = 1 'success!
END SELECT
END FUNCTION
FUNCTION MyMsgBox(lpMsgBoxParams AS MSGBOXPARAMS) AS LONG '自己重写的这个API
DIM lResult AS LONG
MSGBOX ASCToStr(lpMsgBoxParams.@lpszText),,"拦截到弹窗的内容"
MSGBOX ASCToStr(lpMsgBoxParams.@lpszCaption),,"拦截到弹窗的标题"
MSGBOX STR$(lpMsgBoxParams.dwStyle),,"拦截到弹窗的类型" '多弹了几下 大家看看就明白了
CALL DWORD MyMsgBoxNextHook USING MessageBoxIndirectW(lpMsgBoxParams) TO lResult '调用
FUNCTION = lResult '如果想要做掉这个函数 就直接写Function=0 并且把上面的注释掉就是了
END FUNCTION
FUNCTION ASCToStr(lpASC AS ASCIIZ) AS STRING '一个转换字符串的函数 大家不用管了
LOCAL TmpStr AS STRING
LOCAL lng AS LONG
lng=lstrlenW(lpASC) * 2
TmpStr=SPACE$(lng)
MoveMemory BYVAL STRPTR(TmpStr),BYVAL VARPTR(lpASC),lng
FUNCTION = ACODE$(TmpStr)
END FUNCTION