code:
#include <stdio.h>
#include <windows.h>
#include <string.h>
typedef int (CALLBACK* LPFNDLLFUNC1)(char*);
//CALLBACK* LPFNDLLFUNC1();
HINSTANCE hDLL; // Handle to DLL
LPFNDLLFUNC1 lpfnDllFunc1; // Function pointer
int
main (){
int a;
char stringa[32];
char *s;
hDLL = LoadLibrary("test.dll");
if (hDLL != NULL){
lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL,"hello");
if (!lpfnDllFunc1)
{
// handle the error
FreeLibrary(hDLL);
return 1;
}
else
{
stringa[0]='a';
stringa[1]='b';
stringa[2]='a';
stringa[3]='c';
stringa[4]='o';
a=lpfnDllFunc1(stringa);
printf("->%d",a);
}
}
}
code:
library test;
{prima prova di DLL}
uses
SysUtils,
Classes,
finestra in 'finestra.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
function hello(stringa:array of pchar):integer;
begin
result:=100;
writeln(stringa[1]);
end;
exports
hello;
{$R *.RES}
var
Form1: TForm1;
begin
writeln('prova');
//form1 := Tform1.Create(Nil);
//form1.ShowModal;
//form1.Free;
end.