| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3030 人关注过本帖
标题:VB如何LOADLIBRARY调用DLL文件
只看楼主 加入收藏
hai99
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2007-7-2
结帖率:50%
收藏
 问题点数:0 回复次数:4 
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

搜索更多相关主题的帖子: LOADLIBRARY 文件 DLL 
2010-03-19 19:50
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
收藏
得分:0 
这么看那代码都不像是 ms vb6 的代码。
2010-03-19 21:46
hai99
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2007-7-2
收藏
得分:0 
回复 2楼 bczgvip
这是PowerBasic的制作DLL文件的代码,只是不知道怎么调用制作好的DLL文件,刚刚搜索到一个LoadLibrary的声明,可以调用了,但是卸载的FreeLibrary怎么声明啊?
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
2010-03-19 22:09
hai99
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2007-7-2
收藏
得分:0 
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function CallWindowProc Lib "User32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpDest As Any, lpSource As Any, ByVal cBytes As Long)
原来早就找到了该找的
2010-03-19 22:20
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
收藏
得分:0 
恭喜问题解决。
2010-03-20 07:29
快速回复:VB如何LOADLIBRARY调用DLL文件
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015973 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved