叶子的离开 发表于 2014-11-17 13:06:55

【叶子出品】根据文本信息动态调用API【提供源码】

#Include Once "windows.bi"


Function CallAPI Cdecl (ByVal LibPath As ZString Ptr,ByVal FuncName As ZString Ptr,ByVal ParamNum As Integer,...) As Integer
        Dim As Any Ptr hins,LibFuncCall
        Dim As Integer RetInt
        hins = LoadLibrary(LibPath)
        If hins Then
                LibFuncCall = GetProcAddress(hins,FuncName)
                If LibFuncCall Then
                        If ParamNum Then
                                Dim ARG As Any Ptr
                                Dim i As Integer
                                ARG = va_first()
                                For i = 1 To ParamNum
                                        Dim TL As Any Ptr = va_arg(ARG,Any Ptr)
                                        Asm
                                                push
                                        End Asm
                                        ARG = va_next(ARG,Any Ptr)
                                Next
                                Asm
                                        Call
                                        Mov ,Eax
                                End Asm
                        Else
                                Asm
                                        Call
                                        Mov ,Eax
                                End Asm
                        EndIf
                Else
                        MessageBox(0,"导出函数加载失败!","",MB_OK)
                EndIf
        Else
                MessageBox(0,"找不到DLL文件!","",MB_OK)
        EndIf
        CallAPI = RetInt
End Function


CallAPI("user32.dll","MessageBoxA",4,0,"大家好","我是叶飞",0)
CallAPI("kernel32.dll","Sleep",1,1000)
页: [1]
查看完整版本: 【叶子出品】根据文本信息动态调用API【提供源码】