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;
}