Several key technical points:
1, C # to the unmanaged way to call the DLL;
2, C # to tidy up the drawing data generated in advance defined the format of the XML file, passed to the DLL;
3, DLL parsing XML file, according to the corresponding format, requirements, drawing;
4, DLL output GIF file (after comparison GIF image distortion rate is small, and the smallest file size);
5, C # loading GIF files, to the front desk display.
Library Icdll;
Uses
Sysutils;
function Check22:pchar;stdcall;
Begin
Result:= ' OK ';
End
Exports
Check22;
Begin
End.
2. Make a call in C #.
Using System.Runtime.InteropServices;//must reference
namespace Testdll
{
public Partial class Form1:form
{
[DllImport (" Icdll.dll ")]
public static extern StringBuilder Check22 ();
& nbsp; public Form1 ()
{
InitializeComponent ();
}
private void Form1_Load (object sender, EventArgs e)
& nbsp; {
StringBuilder result= Check22 (); Result here is the return value.
}
}
Instance after
May 22, 2007, Tuesday 05:46
----------------------Delphi-------------------
procedure Getsqldata (Asource:pchar; Adest:pchar; Adestsize:integer); stdcall;
Var
s:string;
Begin
If Asource = nil then Exit;
S: = Format ('%s passed by! ', [Asource]);
Move (S[1], adest^, Min (Adestsize, Length (S) +1));
End {Getsqldata}
Exports
Getsqldata;
----------------------C #-------------------
[DllImport (@ "TempLib.dll")]
public static extern void Getsqldata (string asource, StringBuilder adest, int adestsize);
private void Button1_Click (object sender, EventArgs e)
{
StringBuilder vdest = new StringBuilder (1024);
Getsqldata ("Zswang", vdest, 1024);
Text = Vdest.tostring ();
}
Summary: To return the string, 1. In Delphi return is Pchar type, receive with StringBuilder in C #, there is no special notice, and other DLL basically same, Note that string can be replaced with Pchar