找回密码
 加入
搜索
查看: 3750|回复: 9

Dllcall怎么转化

[复制链接]
发表于 2009-1-12 11:24:11 | 显示全部楼层 |阅读模式
这是一个Dll在delphi下的用法
function SerialPrint(uart:integer;Data:string):boolean;stdcall external 'ZebraPrint.dll'
 function ParallelPrint(Data:string):boolean;stdcall external 'ZebraPrint.dll'
调用时
 if (icom=3) then
        begin
          ParallelPrint(a[i]);
        end
        else
        begin
          SerialPrint(icom,a[i]);
        end;
end;
请问在au3下怎么写?
谢谢!

[ 本帖最后由 ken0137 于 2009-1-24 16:43 编辑 ]
发表于 2009-1-12 18:21:43 | 显示全部楼层
Dllcall ("ZebraPrint.dll","bool","SerialPrint","int","uart","str","Data")
DllCall ("ZebraPrint.dll","bool","ParallelPrint","str","Data")
 楼主| 发表于 2009-1-13 15:09:54 | 显示全部楼层
试过了,好像没反应诶,
code

$dll = DllOpen("ZebraPrint.dll")
;$result1=Dllcall ("ZebraPrint.dll","bool","SerialPrint","int","1","str","bggb vb")
$Data="^XA"
$Data=$Data&"^LH0,0"
$Data=$Data&"^BY3^FO70,137^BCN,40,N,N,N^FD>;{SnBar}^FS"
$Data=$Data&"^AFN,26,14^FO100,180^CI0^FDSN:{Sn}^FS"
$Data=$Data&"^PQ{Sheet}"
$Data=$Data&"^XZ"
$result2=DllCall ("ZebraPrint.dll","bool","ParallelPrint","str",$Data)
DllClose($dll)

打印机是斑马条码打印机
$data的内容是zebra的语言
若将$data的内容保存在一个1.txt文件里,是可以打印的
1.txt
^XA
^LH0,0
^BY3^FO70,137^BCN,40,N,N,N^FD>;{SnBar}^FS
^AFN,26,14^FO100,180^CI0^FDSN:{Sn}^FS
^PQ{Sheet}
^XZ
[ 本帖最后由 ken0137 于 2009-1-13 15:13 编辑 ]
 楼主| 发表于 2009-1-13 15:15:37 | 显示全部楼层
这里将相应的delphi源代码贴出来
我想知道转成AU3怎么写的
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Spin, inifiles, StrUtils;

type
  TForm1 = class(TForm)
    OpenDialog1: TOpenDialog;
    SelectBtn: TButton;
    TxtFileName: TEdit;
    PrintBtn: TButton;
    Label1: TLabel;
    Label2: TLabel;
    PrintNum: TSpinEdit;
    Label3: TLabel;
    ComSelect: TComboBox;
    procedure SelectBtnClick(Sender: TObject);
    procedure PrintBtnClick(Sender: TObject);
    procedure ComSelectChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

   //Declare The Functions From DLL:
  function SerialPrint(uart:integer;Data:string):boolean;stdcall external 'ZebraPrint.dll'
  function ParallelPrint(Data:string):boolean;stdcall external 'ZebraPrint.dll'


var
  Form1: TForm1;
  icom:integer;

implementation

{$R *.dfm}

procedure TForm1.SelectBtnClick(Sender: TObject);
begin
  if opendialog1.Execute then
  begin
    TxtFileName.Text :=opendialog1.FileName;
  end;
end;

procedure TForm1.PrintBtnClick(Sender: TObject);
var
  i,j,k:integer;
  F: TextFile;
  a:array[1..3000] of string;
begin
  icom:=StrToInt(ComSelect.Text);
  
  if TxtFileName.Text ='' then
  begin
    showmessage('请选择打印文件!');
  end
  else
  begin
    j:=1;
  //定位程序目录下的txt文件
    AssignFile(F,TxtFileName.Text);
    Reset(F);
    while not Eof(F) do
    begin
      Readln(F,a[j]);
      j:=j+1;
    end;
    //打印标签
    For k:=PrintNum.Value downto 1  DO
    Begin
      for  i:=1 to j do
      begin
        if (a='')  then
        begin
          a:='  '
        end;
        if (icom=3) then
        begin
          ParallelPrint(a);
        end
        else
        begin
          SerialPrint(icom,a);
        end;
      end;
      PrintNum.Value:=PrintNum.Value-1;
    end;
    showmessage('打印完毕!');
  end;
end;
procedure TForm1.ComSelectChange(Sender: TObject);
begin
  if (ComSelect.Items.IndexOf(ComSelect.Text)<0) then
  begin
    showmessage('端口号选择错误!');
    ComSelect.Text:='3';
    ComSelect.SetFocus;
  end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  TxtFileName.Text :=ExtractFilePath(Application.ExeName)+'print.txt';
end;
end.


[ 本帖最后由 ken0137 于 2009-1-13 15:18 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-1-13 15:49:41 | 显示全部楼层
原帖由 gogo023 于 2009-1-12 23:50 发表
SXD,还得向你学习怎么用DLL啊。


我只是初步认识了一下delphi 至于dll的用法 帮助里有
我也是个菜鸟而已啊
 楼主| 发表于 2009-1-24 16:43:04 | 显示全部楼层
sanhen的

$dll=DllOpen("ZebraPrint.dll")
DllCall($dll,"int","SerialPrint","int",$uart,"str",$Data)
DllCall($dll,"int","ParallelPrint","str",$Data)


经测试,是可以的,终于可以用AU3写打印程序了(是Zebra条码打印机)

[ 本帖最后由 ken0137 于 2009-2-4 22:11 编辑 ]
发表于 2009-1-24 17:20:05 | 显示全部楼层
嗯 是我的问题 没意识到 uart 个变量
发表于 2009-1-30 22:40:49 | 显示全部楼层
应该有用,做个记号。
发表于 2010-7-18 18:14:32 | 显示全部楼层
支持。学习,努力。我还不懂什么是dll
发表于 2010-7-18 18:23:47 | 显示全部楼层
把条码打印的分享一下吧!?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-3 14:21 , Processed in 0.091990 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表