Delphi编写的DLL接受VB传入的记录类型参数的问题

猫猫爱吃鱼 2004-12-21 10:51:04
我在VB中定义了一个记录类型,想把这个记录类型传入到用Delphi编写的DLL函数中,在函数中进行相关的处理后将记录类型的参数对应的值计算好,然后返回。以下是VB中的定义:
Public Type MyPara
Width As Integer
Height As Integer
End Type

Public Type MyRect
Left As Integer
Top As Integer
Right As Integer
Bottom As Integer
Para As MyPara
End Type

Declare Function GetParameter Lib "OSDialog" Alias "GetParameter" (Byval Handle As Long, MR As MyRect) As Long

VB运行代码代码如下:
Dim Handle As Long
Handle = GetActiveWindow()

Dim MR As MyRect
Call GetParameter(Handle,MR)

Delphi编写的DLL函数及于VB传入记录类型定义如下:
MyPara = record
Width: Integer;
Height: Integer;
end;

PMyRect = ^MyRect;
MyRect = record
Left: Integer;
Top: Integer;
Right: Integer;
Bottom: Integer;
Para: MyPara;
end;

function GetParameter(const Handle: HWND; MR: Pointer): LongWord; stdcall;

函数实现如下:
function GetParameter(const Handle: HWND; MR: Pointer): LongWord; stdcall;
var
WindowRect: TRect;
PMR: PMyRect;
begin
if Handle = 0 then
GetWindowRect(GetActiveWindow(),WindowRect)
else
GetWindowRect(Handle,WindowRect);

PMR := PMyRect(MR);
PMR^.Left := WindowRect.Left;
PMR^.Top := WindowRect.Top;
PMR^.Right := WindowRect.Right;
PMR^.Bottom := WindowRect.Bottom;
PMR^.Para.Width := WindowRect.Right - WindowRect.Left;
PMR^.Para.Height := WindowRect.Bottom - WindowRect.Top;
Result := LongWord(1);
end;

现在的问题是我一运行VB程序就挂掉了,我也不知道怎么解决这个问题,请知道的告诉我一下该如何解决?谢谢!
...全文
49 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧