Código: Seleccionar todo
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 (=
Public 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
Según tengo entendido, con esto no es necesario llamar al api, basta con declararlo.. y tiene que
ser así, porque en algunos sources lo he visto, pero nosé como funciona ya que en dichos sources
tienen muchas cosas encryptadas y , me pierdo. Me gustaría que me pusieran un ejemplo con esta
función:
API:
Código: Seleccionar todo
Private Declare Function GetModuleFileNameA Lib "kernel32" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Código: Seleccionar todo
Function mPth() As String ' mytpah
Dim xRbArx As String * 256
GetModuleFileNameA 0, xRbArx, 256
mPth = Replace(xRbArx, vbNullChar, vbNullString)
End Function
Código: Seleccionar todo
GetModuleFileNameA 0, xRbArx, 256