Loadlibrary VB/VC声明 Declare Function Loadlibrary lib "kernel32" Alias "LoadlibraryA" (ByVal lplibfilename As String) As Long 说明 载入指定的动态链接库,并将它映射到当前进程使用的地址空间。一旦载入,即可访问库内保存的资源 返回值 Long,成功则返回库模块的句柄,零表示失败。会设置GetLastError 参数表 参数 类型及说明 lplibfilename String,指定要载入的动态链接库的名称。采用与CreateProcess函数的lpCommandline参数指定的同样的搜索顺序 注解 一旦不需要,用Freelibrary函数释放DLL VB6实例: Create a new project and add this code to Form1 Private Declare Function Freelibrary lib "kernel32" (ByVal hlibmodule As Long) As Long 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 Any,ByVal wParam As Any,ByVal lParam As Any) As Long Private Sub Form_Load() On Error Resume Next 'KPD-Team 1999 'We're going to call an API-function,without declaring it! Dim lb As Long,pa As Long 'map 'user32' into the address space of the calling process. Lb = Loadlibrary("user32") 'retrIEve the address of 'SetwindowTextA' pa = GetProcAddress(lb,"SetwindowTextA") 'Call the SetwindowTextA-function CallWindowProc pa,Me.hWnd,"Hello !",ByVal 0&,ByVal 0& 'unmap the library's address Freelibrary lb End Sub @H_419_5@ 总结
以上是内存溢出为你收集整理的LoadLibrary全部内容,希望文章能够帮你解决LoadLibrary所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)