Delphi下如何接受VCDLL函数中输出的数组?VC DLL函数代码
test05.cpp
----------------------------------------------------------------
// test05.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}int __declspec (dllexport) __stdcall MyAddMinus(int a, int b, int*c, int *d)
{
*c = a+b;
*d = a-b;
return 0;
}int __declspec (dllexport) __stdcall MyTest(int *a[30])
{
int i;
i = 0;
while(i < 30)
*a[i++] = i;
return 9;
}
----------------------------------------------------------------test05.def
----------------------------------------------------------------
LIBRARY "test05"
DESCRIPTION 'test Windows Dynamic Link Library'
EXPORTS
MyAddMinus @1
MyArray @2
----------------------------------------------------------------Delphi中声明为
----------------------------------------------------------------
function MyAddMinus(a, b: integer; var c,d: integer): integer; stdcall; external 'test05.dll' index 1;function MyArray(var a: array of integer): integer; stdcall; external 'test05.dll' index 2;
----------------------------------------------------------------
使用
----------------------------------------------------------------
var
i,j,p,q: integer;
ppt: array of integer;
begin
i := 3; j := 5; p := 0; q := 0;
MyAddMinus(i,j,p,q); //执行通过
SetLength(ppt,30);
MyArray(ppt); //执行失败
end;
test05.cpp
----------------------------------------------------------------
// test05.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}int __declspec (dllexport) __stdcall MyAddMinus(int a, int b, int*c, int *d)
{
*c = a+b;
*d = a-b;
return 0;
}int __declspec (dllexport) __stdcall MyTest(int *a[30])
{
int i;
i = 0;
while(i < 30)
*a[i++] = i;
return 9;
}
----------------------------------------------------------------test05.def
----------------------------------------------------------------
LIBRARY "test05"
DESCRIPTION 'test Windows Dynamic Link Library'
EXPORTS
MyAddMinus @1
MyArray @2
----------------------------------------------------------------Delphi中声明为
----------------------------------------------------------------
function MyAddMinus(a, b: integer; var c,d: integer): integer; stdcall; external 'test05.dll' index 1;function MyArray(var a: array of integer): integer; stdcall; external 'test05.dll' index 2;
----------------------------------------------------------------
使用
----------------------------------------------------------------
var
i,j,p,q: integer;
ppt: array of integer;
begin
i := 3; j := 5; p := 0; q := 0;
MyAddMinus(i,j,p,q); //执行通过
SetLength(ppt,30);
MyArray(ppt); //执行失败
end;
Delphi下如何接受VCDLL函数中输出的数组?VC DLL函数代码
test05.cpp
----------------------------------------------------------------
// test05.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}int __declspec (dllexport) __stdcall MyAddMinus(int a, int b, int*c, int *d)
{
*c = a+b;
*d = a-b;
return 0;
}int __declspec (dllexport) __stdcall MyTest(int a[30])
{
int i;
i = 0;
while(i < 30)
a[i++] = i;
return 9;
}
----------------------------------------------------------------test05.def
----------------------------------------------------------------
LIBRARY "test05"
DESCRIPTION 'test Windows Dynamic Link Library'
EXPORTS
MyAddMinus @1
MyArray @2
----------------------------------------------------------------Delphi中声明为
----------------------------------------------------------------
function MyAddMinus(a, b: integer; var c,d: integer): integer; stdcall; external 'test05.dll' index 1;function MyArray(var a: array of integer): integer; stdcall; external 'test05.dll' index 2;
----------------------------------------------------------------
使用
----------------------------------------------------------------
var
i,j,p,q: integer;
ppt: array of integer;
begin
i := 3; j := 5; p := 0; q := 0;
MyAddMinus(i,j,p,q); //执行通过
SetLength(ppt,30);
MyArray(ppt); //执行失败
end;