Como todo programador de VB6 debe saber al llamar un API externa desde VB se llama a DllFunctionCall para sacar el puntero... osea, las APIs declaradas directamente desde el codigo no se agregan a la IAT...
Y bueno, decidi aprovecharme de eso
Código
Option Explicit '--------------------------------------------------------------------------------------- ' Module : mGetAPIPtr ' Author : Karcrack ' Now$ : 11/08/2009 13:07 ' WebPage : http://www.advancevb.com.ar ' Used for? : Get API Pointer withouth calling any external API ' Thanks. : ' - Cobein: Support and Unicode-ANSI function (= '--------------------------------------------------------------------------------------- 'MSVBVM60 Private Declare Function DllFunctionCall Lib "MSVBVM60" (ByRef typeAPI As tAPICall) As Long Private Type tAPICall ptsLIB As Long ' Pointer to ANSI String that contains Library ptsProc As Long ' Pointer to ANSI String that contains Procedure lReserved As Long ' Just reserved... lPointer As Long ' Pointer to the buffer that will contain temp variables from DllFunctionCall lpBuffer(3) As Long ' Buffer that will contain temp variables End Type Public Function GetAPIPtr(ByVal sLib As String, ByVal sProc As String) As Long Dim tAPI As tAPICall Dim bvLib() As Byte Dim bvMod() As Byte Call Unicode2ANSI(sLib, bvLib) Call Unicode2ANSI(sProc, bvMod) With tAPI .ptsLIB = VarPtr(bvLib(0)) .ptsProc = VarPtr(bvMod(0)) .lReserved = &H40000 .lPointer = VarPtr(.lpBuffer(0)) End With GetAPIPtr = DllFunctionCall(tAPI) End Function 'COBEIN (= Private Sub Unicode2ANSI(ByVal sUNICODE As String, ByRef bvANSI() As Byte) Dim i As Long ReDim bvANSI(Len(sUNICODE)) For i = 1 To Len(sUNICODE) bvANSI(i - 1) = Asc(Mid$(sUNICODE, i, 1)) Next i End Sub
Con esto solo no podemos llamar a las APIs, asi que he modificado el codigo de Cobein del cInvoke
para que llama al puntero que le pases... Aqui hay un ejemplo bastante claro:
Código:
http://www.box.net/shared/tbbihznz6r
Ah! Si pretendeis llamar APIs que pidan Strings recordar usar la version UNICODE de esa API (*W)
Saludos