delphi 编写的dll函数
Function GetStationData(DoWith:Integer;FSavePath:Pchar;Var Buffer:Integer):Integer; stdcall;
var i:Integer;
TmpPath:String;
TmpList:TStrings;
begin
//0:直接输出,1:输出保存为文件,2:xml,3:数据库;4:自定义数据结构
Result:=Integer(ProcessDataOk);
SetLength(TStringDynArray(Buffer),High(DataBuffer)+1);
if Result=1 then
try
case DoWith of
0:for i:=Low(DataBuffer) to High(DataBuffer) do
begin
TStringDynArray(Buffer)[i]:=DataBuffer[i];
end;
1:;
else
Result:=-2;
2:;
4:;
end;
Except
Result:=-1;
end;
end;vb申明
Private Declare Function GetStationData Lib "dll文件名" (ByVal DoWith As Integer, ByVal FSavePath As String, ByVal Buffer As Long) As Long
这样申明对不对,还有改如何提出函数中的字符串数组,delphi下没问题
Function GetStationData(DoWith:Integer;FSavePath:Pchar;Var Buffer:Integer):Integer; stdcall;
var i:Integer;
TmpPath:String;
TmpList:TStrings;
begin
//0:直接输出,1:输出保存为文件,2:xml,3:数据库;4:自定义数据结构
Result:=Integer(ProcessDataOk);
SetLength(TStringDynArray(Buffer),High(DataBuffer)+1);
if Result=1 then
try
case DoWith of
0:for i:=Low(DataBuffer) to High(DataBuffer) do
begin
TStringDynArray(Buffer)[i]:=DataBuffer[i];
end;
1:;
else
Result:=-2;
2:;
4:;
end;
Except
Result:=-1;
end;
end;vb申明
Private Declare Function GetStationData Lib "dll文件名" (ByVal DoWith As Integer, ByVal FSavePath As String, ByVal Buffer As Long) As Long
这样申明对不对,还有改如何提出函数中的字符串数组,delphi下没问题
Private Declare Function GetStationData Lib "dll文件名" (ByVal DoWith As Integer, ByVal FSavePath As String, byref Buffer As Long) As Long
Dim strA() As String, point As Long
ReDim strA(1)
strA(0) = "a"
point = VarPtr(strA(0))
MsgBox point
GetStationData 0, "", point
MsgBox point
point这个地址指针已经变了,如何取得stra这个数组的值?
'初始化缓冲区
sBuffer=Space$(255) GetStationData 0, "", sBuffer
Function GetStationData(DoWith:Integer;FSavePath:Pchar;Var Buffer:Integer):Integer; stdcall;
Function GetStationData(DoWith:Integer;FSavePath:Pchar;Var Buffer:Integer):Integer; stdcall;
var i:Integer;
TmpPath:String;
TmpList:TStrings;
begin
//0:直接输出,1:输出保存为文件,2:xml,3:数据库;4:自定义数据结构
Result:=Integer(ProcessDataOk);
if Result=1 then
begin
SetLength(TPCharDynArray(Buffer),High(DataBuffer)+1);
try
case DoWith of
0:for i:=Low(DataBuffer) to High(DataBuffer) do
begin
TPCharDynArray(Buffer)[i]:=PChar(DataBuffer[i]);
end;
1:if High(DataBuffer)=High(PathBuffer) then
begin
TmpList:=TStringList.Create;
for i:=Low(DataBuffer) to High(DataBuffer) do
begin
if FSavePath='' then
TmpPath:=DllPath+PathBuffer[i]
else
if FSavePath[Length(FSavePath)]='\' then
TmpPath:=FSavePath+PathBuffer[i]
else
TmpPath:=FSavePath+'\'+PathBuffer[i];
if Not DirectoryExists(ExtractFilePath(TmpPath)) then
ForceDirectories(ExtractFilePath(TmpPath));
if DirectoryExists(ExtractFilePath(TmpPath)) then
begin
TmpList.Text:=DataBuffer[i];
TmpList.SaveToFile(TmpPath);
end;
end;
TmpList.Free;
end
else
Result:=-2;
2:;
4:;
end;
Except
Result:=-1;
end;
end;
end;
vb声明
Private Declare Function GetStationData Lib "User_Check_Data.dll" (ByVal DoWith As Integer, ByVal FSavePath As String, ByRef Buffer As Long) As Long
vb调用
Private Sub Command2_Click()
Dim strA() As String, PoInt As Long
ReDim strA(1)
strA(0) = "1"
PoInt = VarPtr(strA(0))
MsgBox PoInt
GetStationData 0, "", PoInt
CopyMemory VarPtr(strA(0)), ByVal PoInt, 100
MsgBox strA(0)
End Sub
SysUtils,
Classes;
type
TPCharDynArray =Array of Pchar;
type
MyData=record
Name:Pchar;
ID:Integer;
end;
PMyData=^MyData;
{$R *.res}
Function GetStationData(DoWith:Integer;Var Buffer:Integer):Integer; stdcall;
var i:Integer;
DataBuffer:TPcharDynArray;
begin SetLength(DataBuffer,2);
DataBuffer[0]:='数据1';
DataBuffer[1]:='2';
Result:=High(DataBuffer)+1;
SetLength(TPCharDynArray(Buffer),High(DataBuffer)+1);
for i:=Low(DataBuffer) to High(DataBuffer) do
begin
TPCharDynArray(Buffer)[i]:=PChar(DataBuffer[i]);
end;
end;Function GetMyData(var Point:Integer):Integer;stdcall;
var aa:MyData;
begin
aa.Name:='Test';
aa.ID:=1;
Point:=Integer(@aa);
Result:=1;
end;
Exports
GetStationData name 'GetStationData',
GetMyData name 'GetMyData';
begin
end.
这是delphi源码,dll文件怎么上传啊
dll下载地址,请帮忙提供vb代码