F
franchdream
DELPHI code:
unit test1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
RadioGroup1: TRadioGroup;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//procedure DrawToCanvas(Cav: Tcanvas;x,y:integer);Stdcall;external
'KwBarDll.dll';
procedure Epson_Text8d(M:Smallint;F:byte;S:string);stdcall; external
'Epson.dll';
procedure Epson_Text(M:Smallint;F:byte;S:string);stdcall;external
'Epson.dll';
procedure EpsonPrnLn(S:string);stdcall;external 'Epson.dll';
function GetDefaultPrinter:string;stdcall;external 'Epson.dll';
procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
for i:=0 to Memo1.Lines.Count-1 do
begin
if RadioGroup1.ItemIndex=0 then
Epson_Text8d(14,0,Memo1.Lines);
if RadioGroup1.ItemIndex=1 then
Epson_Text(18,0,Memo1.Lines);// print procedure
if RadioGroup1.ItemIndex=2 then
EpsonPrnLn(Memo1.Lines);
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Label1.Caption:='printer's name£º'+GetDefaultPrinter;
end;
end.
It can print Chinese character,but my C# code:
[DllImport("Epson.dll", EntryPoint = "Epson_Text", CallingConvention =
CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true,
ExactSpelling = true)]
public static extern void Epson_Text(Int16 M, byte F, string S);
.........
string st = "ÖÐÎÄÊDz»ÊDZàÂëÓÐʲôҪÇó";
Epson_Text(18, 0, st);
It can't work.
Anyone has suggest for me. Thanks!
unit test1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
RadioGroup1: TRadioGroup;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//procedure DrawToCanvas(Cav: Tcanvas;x,y:integer);Stdcall;external
'KwBarDll.dll';
procedure Epson_Text8d(M:Smallint;F:byte;S:string);stdcall; external
'Epson.dll';
procedure Epson_Text(M:Smallint;F:byte;S:string);stdcall;external
'Epson.dll';
procedure EpsonPrnLn(S:string);stdcall;external 'Epson.dll';
function GetDefaultPrinter:string;stdcall;external 'Epson.dll';
procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
for i:=0 to Memo1.Lines.Count-1 do
begin
if RadioGroup1.ItemIndex=0 then
Epson_Text8d(14,0,Memo1.Lines);
if RadioGroup1.ItemIndex=1 then
Epson_Text(18,0,Memo1.Lines);// print procedure
if RadioGroup1.ItemIndex=2 then
EpsonPrnLn(Memo1.Lines);
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Label1.Caption:='printer's name£º'+GetDefaultPrinter;
end;
end.
It can print Chinese character,but my C# code:
[DllImport("Epson.dll", EntryPoint = "Epson_Text", CallingConvention =
CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true,
ExactSpelling = true)]
public static extern void Epson_Text(Int16 M, byte F, string S);
.........
string st = "ÖÐÎÄÊDz»ÊDZàÂëÓÐʲôҪÇó";
Epson_Text(18, 0, st);
It can't work.
Anyone has suggest for me. Thanks!