当前位置:主页>销售管理软件> 列表

菜鸟提问。。。调用DLL的问题 找免费家庭记账软件

记账软件版1楼: 求高手来指点指点啊。。。。小弟把我的源代码贴上来,错误繁多请大家指点指点
我在调用的过程中老是说找不到DLL库,或者就是它根本就不按照我指定的去查找。DLL放在当前目录的。。。。。。
调用声明部分:
unit Test;

interface
Type
tagPCDOPENDATA=class //自定义类型
Port:Integer;
Device:Integer;
bPguMode:Longint;
SbusMode:Longint;
Protocol:Longint;
Baudrate:Longint;
TsDelay: Longint;
TnDelay:Longint;
Timeout:Longint;
BreakLen:Longint;
UartFifoLen:Longint;
bDontClose:Longint;
bPortOpen:Longint;
bConnected:Longint;
dwType:Longint;
channel:array[1..64]of byte;
Section:array[1..64]of Byte;
ModeToTry:Longint;
cpu:Longint;
Station:Longint;
bAutoStn:Longint;
Retry:Longint;
DeviceName:array[1..64]of Byte;

bUseModem:Longint;
bAutoAnswer:Longint;
PhoneNumber:array[1..64]of Byte;
CountryCode:Longint;
AreaCode:Longint;


Location:array[1..64]of Byte;
bUseDialing:Longint;
DialRetry:Longint;
bBues:Longint;
hPWDlgParentWnd:Longint;
Reserved:array[1..90]of Byte;
end;
//调用DLL库的声明
Function PcdConnectionDialog ( hWnd:Longint; OPENDATA:tagPCDOPENDATA):Integer;stdcall;
Function PcdRdChanSetupFromIni (INI_Name:String;INI_Sek:String;OPENDATA:tagPCDOPENDATA):Integer;stdcall;
Function PcdWrChanSetupToIni (INI_Name:String; INI_Sek :String; OPENDATA : tagPCDOPENDATA):Integer;stdcall;
Function PcdConnectChannel(PCDCONN : Longint ;OPENDATA : tagPCDOPENDATA;WORD : Longint ;hHWND:Longint ):Integer;stdcall;
Function PcdDisconnectChannel (PCDCONN :Longint ; WORD :Longint ; hHWND : Longint ):Integer;stdcall;
Function PcdStatusDialog ( hHWND : Longint ;OPENDATA :tagPCDOPENDATA):integer;stdcall;
Function PcdRdRTC (PCDCONN : Longint ; Typ :Longint ; Address:Longint ; count:Longint ; lpData : Longint ):Integer;stdcall;
Function PcdRdIOF(PCDCONN: Longint ; Typ :Longint ; Address:Longint ; count: Longint ; lpData: String):Integer;stdcall;

Function PcdWrRTC( PCDCONN : Longint ; Typ:Longint ; Address:Longint ; count:Longint ;lpData:Longint ):Integer;stdcall;
Function PcdWrOF( PCDCONN:Longint ; Typ : Longint ;Address:Longint ;count:Longint ;lpData:String):Integer;stdcall;
Function PcdRun (PCDCONN:Longint ;cpu:Longint ):Integer;stdcall;
Function PcdRdStatus(PCDCONN:Longint ;cpu:Longint ;lpStatus : Longint ):Integer;stdcall;
implementation
function PcdConnectionDialog;external ''SCommUsr.dll'' name ''PcdConnectionDialog'';
function PcdRdChanSetupFromIni;external ''SCommDll.dll'' name ''PcdRdChanSetupFromIni'';
Function PcdWrChanSetupToIni;external''SCommDll.dll''name''PcdWrChanSetupToIni'';
Function PcdConnectChannel;external''SCommDll.dll''name''PcdConnectChannel'';
Function PcdDisconnectChannel;external''SCommDll.dll''name''PcdDisconnectChannel'';
Function PcdStatusDialog;external''SCommUsr.dll''name''PcdStatusDialog'';
Function PcdRdRTC;external''SCommDll.dll''name''PcdRdRTC'';
Function PcdRdIOF;external''SCommDll.dll''name''PcdRdIOF'';
Function PcdWrRTC;external''SCommDll.dll''name''PcdWrRTC'';
Function PcdWrOF;external''SCommDll.dll''name''PcdWrOF'';
Function PcdRun;external''SCommDll.dll''name''PcdRun'';
Function PcdRdStatus;external''SCommDll.dll''name''PcdRdStatus'';


end.
想实现的部分:
unit Main;

interface

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

type
TTestVcDLLForm = class(Tform)
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
Edit1: TEdit;
Button1: TButton;
Edit2: TEdit;
Edit3: TEdit;
Button3: TButton;
Edit4: TEdit;
Button4: TButton;
Label1: TLabel;
Button5: TButton;
Button6: TButton;
Button7: TButton;
GroupBox4: TGroupBox;
Button8: TButton;
Label2: TLabel;
Button9: TButton;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Button2: TButton;
procedure Button9Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
TestVcDLLForm: TTestVcDLLForm;

implementation

{$R *.dfm}
uses
Test ;
var
PCDCONN:Longint;
hHWND:Longint; //窗体句柄
LPOPENDATA:tagPCDOPENDATA;
lpStatus:Longint; //PLC状态
cpu:tagPCDOPENDATA;

ret_int:integer; //函数调用的返回值
PIDBASE:Integer;

procedure TTestVcDLLForm.Button9Click(Sender: TObject);
begin
close
end;

procedure TTestVcDLLForm.Button6Click(Sender: TObject);
begin
ret_int := PcdRdChanSetupFromIni(''E:\DELPHI调用DLL测试\Spg5'', ''GoOnline'', LPOPENDATA)
end;

procedure TTestVcDLLForm.Button7Click(Sender: TObject);
begin
ret_int := PcdConnectionDialog(hHWND, LPOPENDATA);
If ret_int <> 0 Then
showmessage(''DOnot call DLOGform'' )
else
ret_int := PcdWrChanSetupToIni(''E:\DELPHI调用DLL测试\Spg5'', ''GoOnline'', LPOPENDATA);
end;

procedure TTestVcDLLForm.Button5Click(Sender: TObject);
begin
ret_int := PcdConnectChannel(PCDCONN, LPOPENDATA, 0, hHWND);
If ret_int = 0 Then
ret_int := PcdStatusDialog(hHWND, LPOPENDATA) ;
label1.Color := clLime

end;

procedure TTestVcDLLForm.Button3Click(Sender: TObject);

var
REG:array[0..10] of Longint ;
//i : Integer;
begin //读取从100开始的数据,并把数组1和2的值分别显示出来
ret_int := PcdRdRTC(PCDCONN, integer(''R''), 100, 10, REG[0]);

Edit3.Text := inttostr(REG[0]);
Edit4.Text:=IntToStr(REG[1]);

end;

procedure TTestVcDLLForm.Button4Click(Sender: TObject);
var
REG:array[0..10] of Longint ;
begin //把数组1和2的值分别写入
REG[0]:=strtoint(Edit4.Text);
REG[1]:=strtoint(Edit5.Text);
ret_int := PcdWrRTC(PCDCONN, integer(''R''), 100, 10, REG[0])
end;

procedure TTestVcDLLForm.FormCreate(Sender: TObject);
begin
//chdir''E:\DELPHI调用DLL测试''; //想指定工作路径到当前文件夹的
end;

procedure TTestVcDLLForm.Button1Click(Sender: TObject);
var
Flags :String[16] ; //定义字符型
i: Integer; //定义整数型
bFlag:array[0..16]of Boolean ; //定义布尔型数组
TmpFlag:String ; //定义字符型
begin
ret_int := PcdRdIOF(PCDCONN, integer(''F''), 16, 2, Flags); //从地址16开始读两个上来放到数组里
For i := 0 To 15 do
begin
TmpFlag:= chr(Flags, i + 1, 1) ; //把字符组里面的指定的传递给函数

bFlag[i] := VarAsType(TmpFlag) of boolean; //把字符型转化为布尔型
end;
i:=0; //重新开始记数
For i:= 0 To 2 do //把数组里的1和2数据分别显示出来
edit(i).Text := bFlag[i];
readln;
end;
procedure TTestVcDLLForm.Button2Click(Sender: TObject);
var
Flags:array[0..16]of String;
i:Integer;
begin
i:=0;
For i := 7 To 8 do //把从16开始的两个数据写入
begin
Flags[i] := CStr(Edit(i).Text); //想实现控件的数组,但是这样不行。
ret_int := PcdWrOF(PCDCONN, integer(''F''), 16 + i, 1, Flags[i]);
end;
end;
end.

初学DELPHI,还望大家帮帮忙。。。。。

2楼: //调用DLL库的声明
Function PcdConnectionDialog ( hWnd:Longint; OPENDATA:tagPCDOPENDATA):Integer;stdcall;
Function PcdRdChanSetupFromIni (INI_Name:String;INI_Sek:String;OPENDATA:tagPCDOPENDATA):Integer;stdcall;
Function PcdWrChanSetupToIni (INI_Name:String; INI_Sek :String; OPENDATA : tagPCDOPENDATA):Integer;stdcall;
Function PcdConnectChannel(PCDCONN : Longint ;OPENDATA : tagPCDOPENDATA;WORD : Longint ;hHWND:Longint ):Integer;stdcall;


Function PcdDisconnectChannel (PCDCONN :Longint ; WORD :Longint ; hHWND : Longint ):Integer;stdcall;
Function PcdStatusDialog ( hHWND : Longint ;OPENDATA :tagPCDOPENDATA):integer;stdcall;
Function PcdRdRTC (PCDCONN : Longint ; Typ :Longint ; Address:Longint ; count:Longint ; lpData : Longint ):Integer;stdcall;
Function PcdRdIOF(PCDCONN: Longint ; Typ :Longint ; Address:Longint ; count: Longint ; lpData: String):Integer;stdcall;
Function PcdWrRTC( PCDCONN : Longint ; Typ:Longint ; Address:Longint ; count:Longint ;lpData:Longint ):Integer;stdcall;
Function PcdWrOF( PCDCONN:Longint ; Typ : Longint ;Address:Longint ;count:Longint ;lpData:String):Integer;stdcall;
Function PcdRun (PCDCONN:Longint ;cpu:Longint ):Integer;stdcall;
Function PcdRdStatus(PCDCONN:Longint ;cpu:Longint ;lpStatus : Longint ):Integer;stdcall;
implementation

以上这些什么意思? 如免费家庭记账软件

3楼: 这么写试试,我习惯这样,虽然一样吧,呵呵


Function PcdConnectionDialog ( hWnd:Longint; OPENDATA:tagPCDOPENDATA):Integer;stdcall external ''SCommUsr.dll'';
Function PcdRdChanSetupFromIni (INI_Name:String;INI_Sek:String;OPENDATA:tagPCDOPENDATA):Integer;stdcall external ''SCommUsr.dll'';
Function PcdWrChanSetupToIni (INI_Name:String; INI_Sek :String; OPENDATA : tagPCDOPENDATA):Integer;stdcall external ''SCommUsr.dll'';
Function PcdConnectChannel(PCDCONN : Longint ;OPENDATA : tagPCDOPENDATA;WORD : Longint ;hHWND:Longint ):Integer;stdcall external ''SCommUsr.dll'';
Function PcdDisconnectChannel (PCDCONN :Longint ; WORD :Longint ; hHWND : Longint ):Integer;stdcall external ''SCommUsr.dll'';
Function PcdStatusDialog ( hHWND : Longint ;OPENDATA :tagPCDOPENDATA):integer;stdcall external ''SCommUsr.dll'';
Function PcdRdRTC (PCDCONN : Longint ; Typ :Longint ; Address:Longint ; count:Longint ; lpData : Longint ):Integer;stdcall external ''SCommUsr.dll'';
Function PcdRdIOF(PCDCONN: Longint ; Typ :Longint ; Address:Longint ; count: Longint ; lpData: String):Integer;stdcall external ''SCommUsr.dll'';


Function PcdWrRTC( PCDCONN : Longint ; Typ:Longint ; Address:Longint ; count:Longint ;lpData:Longint ):Integer;stdcall external ''SCommUsr.dll'';
Function PcdWrOF( PCDCONN:Longint ; Typ : Longint ;Address:Longint ;count:Longint ;lpData:String):Integer;stdcall external ''SCommUsr.dll'';
Function PcdRun (PCDCONN:Longint ;cpu:Longint ):Integer;stdcall external ''SCommUsr.dll'';
Function PcdRdStatus(PCDCONN:Longint ;cpu:Longint ;lpStatus : Longint ):Integer;stdcall external ''SCommUsr.dll'';

4楼: 你的dll部分有沒問題啊。

5楼: 我的DLL是绝对没有问题的,是一个软件的DLL库,我用VB调用一点问题都没有。我想该用DELPHI 做用同样的原理做就是做不通,调用怎么都不成功。
royal1442: 你的那种方法我也做过了,我还指定了路径都报同样的错误。。。老是说:路径下面没有DLL库,明明是放在路径下面的啊。。。。

6楼: 这样试试看:
Function PcdConnectionDialog ( hWnd:Longint; OPENDATA:tagPCDOPENDATA):Integer;stdcall;far;external ''SCommUsr.dll'' name ''PcdConnectionDialog'';

记账软件版7楼: 是不是它有调了别的DLL你没有啊

8楼: 没有吧~!我在vb里面能调用,DELPHI里面就不能调用了。。。要是调用了什么DLL的话vb也不能调用啊。。。这个DLL是用vc做的,底层的函数我都有看见。。。。

9楼: 怎么没有高手近来指点指点啊???????


上面的几个哥们说的我都试过了,报的是同样的错误啊。。。就是找不到DLL库。。。
有没有从vb转DELPHI的大侠,我这里有vb的程序,就只这个DLL库的原程序。能不能帮我转成DELPHI的,小弟急啊。。。。。
小弟的邮箱:vipa_star@163.com qq:295936573

10楼: 多谢大家~!