delphi如何调用dll函数

来源:百度知道 编辑:UC知道 时间:2024/06/25 07:22:35
Function OpenPrinter(pPrinterName:pchar): boolean;export;stdcall;external 'ZQPntCtrl.dll' name 'OpenPrinter';
如何调用以上dll函数?请给以指教!!!
我把打印名改过了,用了怎么还是不行啊,请指教?
ZQPntCtrl.dll 是打印机厂家发给我的打印链接库文件。
Function OpenPrinter(pPrinterName:pchar): boolean;export;stdcall;external 'ZQPntCtrl.dll' name 'OpenPrinter';是厂家给我的接口函数。
怎么调用呢?
OpenPrinter(PChar('参数'));中的参数应是什么?
我已把ZQPntCtrl.dll 拷到目标目录上了。
可还是不行?求求了。

OpenPrinter(Pchar('打印机名')):

打印机名改成你的就行了
打印机名就是电脑生成的打印机名呀,在控制面板---打印机中有显示呀

首先声明函数
就是你写的这样
Function OpenPrinter(pPrinterName:pchar): boolean;export;stdcall;external 'ZQPntCtrl.dll' name 'OpenPrinter';
然后使用
OpenPrinter(PChar('参数'));
注意 ZQPntCtrl.dll 一定要和exe 一起带上.

静态调用:
unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
procedure showform;External 'Project1.dll';{静态调用}
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
showform;
end;