Ver Mensaje Individual
  #2  
Antiguo 30-07-2006
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Reputación: 24
seoane Va por buen camino
A lo mejor te puedo ayudar con un ejemplo:

Si tenemos en una librería hecha en Delphi esta función:
Código Delphi [-]
procedure Mensaje(Str: ShortString); stdcall;
var
  s: string;
begin
  s:= 'El mensaje es: ' + Str;
  MessageBox(0,PChar(S),'Hola',0);
end;

Podemos hacer un pequeño programa en C que la utilice de la siguiente manera:
Código:
#include <stdio.h>
#include <windows.h>

typedef int (*MYPROC)(char *str);

int main(int argc, char *argv[])
{
 HINSTANCE hinstLib; 
 MYPROC ProcAdd; 
 char s[256];
 
 strcpy(&s[1], "Hola mundo");
 s[0] = strlen(&s[1]);
 
 hinstLib = LoadLibrary("libreria.dll"); 
 if (hinstLib != NULL) 
 { 
  ProcAdd = (MYPROC) GetProcAddress(hinstLib, "Mensaje"); 
  if (ProcAdd != NULL) 
    (ProcAdd) (s); 
  else
    printf("No puedo cargar la libreria\n");
    FreeLibrary(hinstLib); 
 } 
 return 0;
}
Responder Con Cita