hola buenas pues si mi vb se cuelga en un codigo de API guide que es el ejemplo de loadlibrary:
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
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'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
se cuelga cuando llega a esta linea:
CallWindowProc pa, Me.hWnd, "Hello !", ByVal 0&, ByVal 0&
alguien sabe porq? y como arreglarlo? :P
quizas porque a la funcion SetWindowTextA se le esta pasando 4 parametros (Me.hWnd, "Hello !", ByVal 0&, ByVal 0&) en lugar de 2 (HWND + titulo), cambie el codigo, en vez de llamar a SetWindowTextA llama a MessageBoxA y funciona (este si tiene 4 parametros):
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
Dim Icono As Long
Icono = 48
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'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, "MessageBoxA")
'Call the SetWindowTextA-function
CallWindowProc pa, Me.hWnd, "Hello !", "titulo", Icono
'unmap the library's address
FreeLibrary lb
End Sub
gracias! :D es cierto lo que dices ahora sol hay que saber como usar cualquier api con cualquier numero de parametros con este metodo :P
@Raul100
Nesesitas ejecutar ASM Inline... para insertar los punteros de las variables...
http://foro.elhacker.net/programacion_visual_basic/asm_en_vb6_respuesta_a_myserik-t330062.0.html
NOTA: APICallByName.
Dulces Lunas!¡.
aki en el foro tambien karcrack hizo algo parecido a lo de blackzero, el titulo del post era "llamar apis sin declararlos", tambien puede servirte.
sisisis lo ce aqui hay varias modulos de apicallbyname yo queria saber porq salia error en ese codigo ;D