T
taizhi
Unregistered / Unconfirmed
GUEST, unregistred user!
//有下面一自定义结构<br>type<br> PDevInfo=^TDevInfo;<br> TDevInfo=packed record<br> PortHandle : Integer;<br> CardPwdType : Integer; //卡密码类型<br> DevicePwd : Pchar; //设备密码<br> CardPwd : Pchar; //卡密码<br> end;<br>//有一对自定义结构赋值的函数<br>function TfrmDevMain.InitDevInfo(MyDevInfo:TDevInfo):Boolean;<br>var<br> CommuPort:String;<br>begin<br> Result:=False;<br> if Aq_DevDetail.RecordCount>0 then<br> With Aq_DevDetail do<br> begin <br> MyDevInfo.PortHandle :=-1;<br> MyDevInfo.CardPwdType :=FieldByName('CardPwdType').AsInteger;<br> if MyDevInfo.CardPwdType =0 then<br> MyDevInfo.CardPwd :=Pchar(FieldByName('APwd').AsString)<br> else<br> MyDevInfo.CardPwd :=Pchar(FieldByName('BPwd').AsString);<br> MyDevInfo.DevicePwd :=Pchar(FieldByName('DevicePwd').AsString);<br> Result:=True;<br> end;<br>end;<br><br>//下面是调用函数代码<br>procedure TfrmDevMain.dxBarBtnRefreshClick(Sender: TObject);<br>var<br> MyDev:TDevInfo;<br>begin<br> InitDevInfo(MyDev);<br> Edit1.Text:=MyDev.CardPwd //此时的Edit1.Text并不是Aq_DevDetail对应字段的值,是乱码为什么?<br>end;<br><br>请各位高手帮帮忙,是否在调用 InitDevInfo之前,必须对MyDev分配内存?如果是,又该如何分配呢?