int DLL_DECLARE ReadResult(int * pnResult, double * pRisk, int nNum, int * pnFlag, int nFlagLength,
int * pYRange, int nYRangeLength,
int * pXRange, int nXRangeLength, double * plfAngle);
上面是动态连接库中函数的原型
下面是bcb中的调用 int g_nRecogResult[5], g_nRecogFlag[6];
int g_nRecogYRange[2], g_nRecogXRange[10];
double g_lfRecogRisk[5], g_lfRecogAngle; ReadResult(g_nRecogResult, g_lfRecogRisk, 5,
g_nRecogFlag, 6,
g_nRecogYRange, 2,
g_nRecogXRange, 10,
&g_lfRecogAngle);现在我想在delphi中调用这个函数,请问函数如何申明?如何调用?
int * pYRange, int nYRangeLength,
int * pXRange, int nXRangeLength, double * plfAngle);
上面是动态连接库中函数的原型
下面是bcb中的调用 int g_nRecogResult[5], g_nRecogFlag[6];
int g_nRecogYRange[2], g_nRecogXRange[10];
double g_lfRecogRisk[5], g_lfRecogAngle; ReadResult(g_nRecogResult, g_lfRecogRisk, 5,
g_nRecogFlag, 6,
g_nRecogYRange, 2,
g_nRecogXRange, 10,
&g_lfRecogAngle);现在我想在delphi中调用这个函数,请问函数如何申明?如何调用?
解决方案 »
- delphi中在整个form运行期间,有没有事件,只要出现那个事件的条件就能执行
- DataSnap 2010教材撰写计划(有兴趣的请加群:67803772)
- 用Delphi完成(急急急!)
- 怎么样使系统适应不同的分辩率?
- 关于线程占用cpu100%的问题
- 关于水晶报表(调用子报表)打印问题(急急急急)
- 求深思洛克加密狗 精锐E delphi 开文文档
- 一般的数据库一行显示的内容,像姓名,性别等,有好几列,如果我只设两列,那么我如何做
- delphi中如何取得系统日期?
- SOS???学delphi用哪本书好?
- 如何设置delphi2009 toolbar 背景
- 向大家推荐好东东:数据库结构文档生成器
g_nRecogResult: array [0..4] of integer;
g_nRecogFlag: array [0..5] of integer;
g_nRecogYRange: array [0..1] of integer;
g_nRecogXRange: array [0..9] of integer;
g_lfRecogRisk: array [0..4] of Double;
g_lfRecogAngle: Double; ReadResult(g_nRecogResult, g_lfRecogRisk, 5,
g_nRecogFlag, 6,
g_nRecogYRange, 2,
g_nRecogXRange, 10,
@g_lfRecogAngle);
在delphi中这个函数怎么申明呢?
function ReadResult(var pnResult:array of integer; var pRisk:array of ouble;
nNum:LongInt;var pnFlag:array of Integer;nFlagLength:LongInt;
var pYRange:array of Integer;nYRangeLength:longint;
var pXRange:array of integer;nXRangeLength:LongInt;
var plfAngle:double):LongInt;stdcall;
external 'Dll.dll' name '_ReadResult@40';调用如下:
var
mY:array[0..1] of Integer;
mX:array[0..9] of Integer;
nRisk:array[0..4] of double;
nRecogResult:array[0..4] of Integer;
nRecogFlag:array[0..5] of Integer;
lfAngle:Double; ReadResult(nRecogResult,nRisk,5,nRecogFlag,6,mY,2,mX,10,lfAngle);可调用是出现这个错误提示,不知道哪有问题?
Access violation at address 00000000.Read of address 00000000
var
...
2楼的var
...
function ReadResult(...2楼的函数声明...):integer:Stdcall;
//然后在
implementation
function ReadResult; External abc.dll{这里写DLL文件名} name 'ReadResult';
就可以用了
procedure (var X: array of Integer); stdcall;
实际上传了两个参数,相当于
void __stdcall (int *, int)
第一个参数是数组首地址,第二个参数是High(X),也就是Length(X)-1
int DLL_DECLARE ReadResult(int * pnResult, double * pRisk, int nNum, int * pnFlag, int nFlagLength,
int * pYRange, int nYRangeLength,
int * pXRange, int nXRangeLength, double * plfAngle); pRisk和plfAngle在声明中有区别么?
都只传了一个指针,谁说传了多个值的
请问starluck: 如果不管BCB是怎么整的,光看原型,在delphi中应该怎么申明和调用啊?谢谢!
nFlagLength:LongInt;pYRange:pInteger;nYRangeLength:longint;
pXRange:pInteger;nXRangeLength:LongInt;plfAngle:double):LongInt;stdcall;
external 'Dll.dll' name '_ReadResult@40';
调用:
var
mY:array[0..1] of Integer;
mX:array[0..9] of Integer;
nRisk:array[0..4] of double;
nRecogResult:array[0..4] of Integer;
nRecogFlag:array[0..5] of Integer;
lfAngle:Double; ReadResult(@nRecogResult,@nRisk,5,@nRecogFlag,6,@mY,2,@mX,10,lfAngle);运行时,出现这个提示:
Access violation at address 00481933 in module 'xxx.dll'.Write of address 00000000.
麻烦你看看哪里还有问题,不好意思,一个小问题给你添麻烦了。
function ReadResult(pnResult: PInteger; pRisk: PDouble; nNum: LongInt;
pnFlag: PInteger; nFlagLength: LongInt;
pYRange: PInteger; nYRangeLength: Longint;
pXRange: PInteger; nXRangeLength: LongInt;
var plfAngle: Double): LongInt; stdcall;
external 'Dll.dll' name '_ReadResult@40';
var X: Double 和 PX: PDouble 传的东西是一样的。X: array of Double 和 var X: array of Double 传的东西是一样的
非常感谢您!问题已经解决了,按照 jadeluo 的提示,把申明改成function ReadResult(pnResult: PInteger; pRisk: PDouble; nNum: LongInt;
pnFlag: PInteger; nFlagLength: LongInt;
pYRange: PInteger; nYRangeLength: Longint;
pXRange: PInteger; nXRangeLength: LongInt;
var plfAngle: Double): LongInt; stdcall;
external 'Dll.dll' name '_ReadResult@40'; 就可以了。var plfAngle: Double 这里加了var 就通过了。
int DLL_DECLARE ProcessMain(int * m_RESULTHIS, int * m_RISKHIS, int * m_FLAGHIS,
int * m_result, int* m_risk, int m_num,
int * m_flag, int m_flag_length,
unsigned char * image, int m_wide,int m_height,
int * m_y, int m_lengthy, int * m_x, int m_lengthx,
float * m_vangle, unsigned char * m_SHOW);delphi里我是这么申明的procedure ProcessMain(m_RESULTHIS,m_RISKHIS,m_FLAGHIS,m_result,m_risk:pInteger;m_num:LongInt;
m_flag:pInteger;m_flag_length:LongInt;image:pchar;
m_wide,m_height:longint;m_y:pInteger;m_lengthy:LongInt;m_x:pInteger;
m_lengthx:LongInt;m_vangle:pdouble;var m_SHOW:pchar);Stdcall; external 'Dll.dll' name '_ProcessMain@68';然后这么调用的var
mResultThis,mRiskThis:array[0..14] of Integer;
mFlagThis:array[0..5] of Integer;
mVangle:array[0..3] of Double;
mY:array[0..1] of Integer;
mX:array[0..9] of Integer;
mShow:PChar;
nRisk:array[0..5] of Integer;
nRecogResult:array[0..4] of Integer;
nRecogFlag:array[0..5] of Integer;
g_ucPicture:pchar; getmem(g_ucPicture,size);
getmem(mShow,size); //这里size足够大的
ProcessMain(@mResultThis,@mRiskThis,@mFlagThis,@nRecogResult,@nRisk,5,@nRecogFlag,6,
g_ucPicture,PICTURE_WIDTH, PICTURE_HEIGHT,@mY,2,@mX,10,@mVangle,mShow);运行时出现如下提示:
Access violation at address 0038f10a in module 'xxx.dll'.Read of address fd002cfc.请各位帮我看看问题所在。谢谢各位了。
someFunDeclare( pc:pchar );//不要加var
//invoke
pc:array[0..MaxSize] of char;
someFun (pc);
按照你的改了,还是那个错误提示
//declare
procedure ProcessMain(m_RESULTHIS,m_RISKHIS,m_FLAGHIS,m_result,m_risk:pInteger;m_num:LongInt;m_flag:pInteger;m_flag_length:LongInt;image:pchar;m_wide,m_height:longint;
m_y:pInteger;m_lengthy:LongInt;m_x:pInteger;m_lengthx:LongInt;m_vangle:pdouble;m_SHOW:pchar);Stdcall; external 'RecogDll.dll' name '_ProcessMain@68';//invoke
g_ucPicture:array[0..size] of char;
mShow:array[0..size] of char; ProcessMain(@mResultThis,@mRiskThis,@mFlagThis,@nRecogResult,@nRisk,5,@nRecogFlag,6,g_ucPicture,PICTURE_WIDTH, PICTURE_HEIGHT,@mY,2,@mX,10,@mVangle,mShow);
procedure ProcessMain(m_RESULTHIS,m_RISKHIS,m_FLAGHIS,m_result,m_risk:pInteger;m_num:LongInt;
m_flag:pInteger;m_flag_length:LongInt;image:pchar;
m_wide,m_height:longint;m_y:pInteger;m_lengthy:LongInt;m_x:pInteger;
m_lengthx:LongInt;m_vangle:psingle;var m_SHOW:pchar);Stdcall; external 'Dll.dll' name '_ProcessMain@68';
var
mResultThis,mRiskThis:array[0..14] of Integer;
mFlagThis:array[0..5] of Integer;
mVangle:array[0..3] of single;
mY:array[0..1] of Integer;
mX:array[0..9] of Integer;
mShow:PChar;
nRisk:array[0..5] of Integer;
nRecogResult:array[0..4] of Integer;
nRecogFlag:array[0..5] of Integer;
g_ucPicture:pchar; getmem(g_ucPicture,size);
getmem(mShow,size); //这里size足够大的
ProcessMain(@mResultThis,@mRiskThis,@mFlagThis,@nRecogResult,@nRisk,5,@nRecogFlag,6,
g_ucPicture,PICTURE_WIDTH, PICTURE_HEIGHT,@mY,2,@mX,10,@mVangle,mShow);
终于可以结贴了,在此谢谢大家的帮助
特别要感谢的是Seamour、jadeluo