大家看看这个DLL怎么调用?(100分)

  • 主题发起人 主题发起人 wukui
  • 开始时间 开始时间
W

wukui

Unregistered / Unconfirmed
GUEST, unregistred user!
[:(!]
有个DLL
在VC中的定义为
VARIANT _stdcall GetDgx(double *x,do
uble *y,
double *z, int DataPointNum,do
uble * LineValue,
int LineValueNum,do
uble Grid)
在VB中函数声明
Private Declare Function GetDgx Lib "TestDLL.dll"
(x Asdo
uble, y Asdo
uble, z Asdo
uble, ByVal DataPointNum As Integer,
LineValue Asdo
uble, ByVal LineValueNum As Integer, ByVal Grid Asdo
uble) As Variant
Private Sub Command1_Click()
Dim x() Asdo
uble
Dim y() Asdo
uble
Dim z() Asdo
uble
Dim DataPointNum As Integer
Dim LineValue(0 To 3) Asdo
uble
Dim LineValueNum As Integer
Dim Grid Asdo
uble
Dim c As Variant
LineValueNum = 4
LineValue(0) = 10
LineValue(1) = 20
LineValue(2) = 30
LineValue(3) = 40
Grid = 1
ReDim x(0 To 279)
ReDim y(0 To 279)
ReDim z(0 To 279)
Dim i As Integer
For i = 0 To 279
x(i) = X1(i)
y(i) = Y1(i)
z(i) = Z1(i)
Next

DataPointNum = 280

c = GetDgx(x(0), y(0), z(0), DataPointNum, LineValue(0), LineValueNum, Grid)
MsgBox c(1, 0)
End Sub
可以正确使用
请问Delphi中如何使用这个DLL呢?
能将以上程序改写为Delphi版本吗?
谢谢
 
Private Declare Function GetDgx Lib "TestDLL.dll"
(x Asdo
uble, y Asdo
uble, z Asdo
uble, ByVal DataPointNum As Integer,
LineValue Asdo
uble, ByVal LineValueNum As Integer, ByVal Grid Asdo
uble) As Variant
to delphi:
Function GetDgx:(x,y,z,LineValue,Grid:double;DataPointNum,LineValueNum:integer;)Variant;stdcall;external'TestDLL.dll';
 
大哥呢试过吗?
这里的x y z是数组
 
VARIANT _stdcall GetDgx(double *x,do
uble *y,
double *z, int DataPointNum,do
uble * LineValue,
int LineValueNum,do
uble Grid)
function GetDgx(var x, y, z:do
uble;
DataPointNum: Integer;
var LineValue:do
uble;
LineValueNum: Integer;
Grid:do
uble) : Variant;
stdcall;
external 'TestDLL.dll';
如果是x, y, z and LineValue是数组,则应该这样写:
type
PDouble = ^Double;
function GetDgx(x, y, z: PDouble;
DataPointNum: Integer;
LineValue: PDouble;
LineValueNum: Integer;
Grid:do
uble) : Variant;
stdcall;
external 'TestDLL.dll';
 
多人接受答案了。
 
后退
顶部