我需要调用C++写的一个DLL如下:
BOOL __stdcall GetCamList(DWORD dwAddr);
dwAddr 为目前系统注册的IPCam数组。数组大小为目前注册的IPCam数目
在C++中的代码如下:
************************************
STRUCTDEVSHOW_* pDevice = new STRUCTDEVSHOW_[lCount];
GetCamList((DWORD)pDevice);其中STRUCTDEVSHOW_定义如下:
struct STRUCTDEVSHOW_
{
char strDevName[128];
char strDevIP[32];
char strMAC[32];
};
************************************我在delphi中的定义和声明依次如下:
TStructDevShow = record
strDevName:array [1..128] of char;
strDevIP:array [1..32] of char;
strMAC:array [1..32] of char;
end;
type TStructDevShowS=array of TStructDevShow;
……
……
function GetCamList(dwAddr:DWORD):LongBool;stdcall;external 'CreatePlatform.dll';下面是执行这个调用的实现,请大家帮我看看,应该怎么做,才能完成这个函数调用!!!
procedure TForm1.Button3Click(Sender: TObject);
var
lcount:Integer;
structDevShowS:TStructDevShowS;
dwAddr:DWORD;
begin
lcount:=0;
GetCamListCount(lcount);
if (lcount>0) then begin
setLength(structDevShowS,lcount);
dwAddr:=Cardinal(@structDevShowS);
GetCamList(dwAddr); //执行到这里的时候,出现内存出错!!
Memo1.Lines.Add(structDevShowS[0].strDevIP);
end else begin end;
end;
我对delphi中实现指针方面不是很懂,请大家帮忙看看!
BOOL __stdcall GetCamList(DWORD dwAddr);
dwAddr 为目前系统注册的IPCam数组。数组大小为目前注册的IPCam数目
在C++中的代码如下:
************************************
STRUCTDEVSHOW_* pDevice = new STRUCTDEVSHOW_[lCount];
GetCamList((DWORD)pDevice);其中STRUCTDEVSHOW_定义如下:
struct STRUCTDEVSHOW_
{
char strDevName[128];
char strDevIP[32];
char strMAC[32];
};
************************************我在delphi中的定义和声明依次如下:
TStructDevShow = record
strDevName:array [1..128] of char;
strDevIP:array [1..32] of char;
strMAC:array [1..32] of char;
end;
type TStructDevShowS=array of TStructDevShow;
……
……
function GetCamList(dwAddr:DWORD):LongBool;stdcall;external 'CreatePlatform.dll';下面是执行这个调用的实现,请大家帮我看看,应该怎么做,才能完成这个函数调用!!!
procedure TForm1.Button3Click(Sender: TObject);
var
lcount:Integer;
structDevShowS:TStructDevShowS;
dwAddr:DWORD;
begin
lcount:=0;
GetCamListCount(lcount);
if (lcount>0) then begin
setLength(structDevShowS,lcount);
dwAddr:=Cardinal(@structDevShowS);
GetCamList(dwAddr); //执行到这里的时候,出现内存出错!!
Memo1.Lines.Add(structDevShowS[0].strDevIP);
end else begin end;
end;
我对delphi中实现指针方面不是很懂,请大家帮忙看看!
解决方案 »
- 用Pascal语言加载文件
- parameter BegDate not found
- delphi如何让窗体颜色随机闪烁呢
- 动态添加listview节点问题
- 在一个主从表的中,从表的关联COL这么取的主表的关联COL?
- 初学delphi,几个题目高手帮我看下
- ******如何把文件存入oracle数据库中******
- 如何用treeview来做界面的切换啊
- 新建文本文件跟保存
- (100分)谁有加密算法?不需要太复杂,但是一定要PASCAL描述的,急用,没工夫细细琢磨,拜托给为大虾。
- DELPHI的窗口类都是“T”打头的,怎样将其修改为非“T”的?
- 我的可用分 怎么全在缓存可用分里面啊? 1873 都好几个星期了 不涨也不减 哈哈 郁闷
试一下PStructDevShow = ^TStructDevShow;
TStructDevShow = record
strDevName:array [1..128] of char;
strDevIP:array [1..32] of char;
strMAC:array [1..32] of char;
end; PStructDevShowS = ^TStructDevShowS;
TStructDevShowS = record
aStructDevShowS: array[0..0] of TStructDevShow;
end;
tagStructDevShow = record
strDevName:array [1..128] of char;
strDevIP:array [1..32] of char;
strMAC:array [1..32] of char;
end; //此类型只为逃避编译器对于下标溢出的检查,请勿直接使用
TStructDevShowArray = array [0..(MaxLongint div sizeof(tagStructDevShow))-1 ] of tagStructDevShow;
PStructDevShowArray = ^TStructDevShowArray;
var
MyData: PStructDevShowArray ;
begin
GetMem(MyData,lCount * sizeof(tagStructDevShow));
GetCamList(LongWord(MyData));
end;