[programmare] C e DLL
Posted by cato on 22-02-2005 11:31
mi sto avventurando nel magico mondo delle DLL.

il mio scopo รจ madare un array di char da un programma C a una funzione di una DLL (in delphi)

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



qui la dll

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.


chiaramente non funziona.... :roll:
Powered by: vbHome (lite) v3.8 and vBulletin v2.3.1
Copyright © 2000 - 2002 Jelsoft Enterprises Limited