首页 > Windows开发 > 详细

C#调用Delphi Dll返回字符串的示例(使用Move才能拷贝字符串)

时间:2017-01-24 22:57:28      阅读:467      评论:0      收藏:0      [点我收藏+]
//----------------------Delphi-------------------
procedure GetSqlData(ASource: PChar; ADest: PChar; ADestSize: Integer); stdcall;
var
 S: string;
begin
 if ASource = nil then Exit;
 S := Format(‘%s 路过!,[ASource]);
 Move(S[1], ADest^, Min(ADestSize, Length(S)+1));
end;{ GetSqlData }
 
exports
 GetSqlData;
 
//----------------------C#-------------------
[DllImport(@"TempLib.dll")]
public static extern void GetSqlData(string ASourceStringBuilder ADest, int ADestSize);
 
private void button1_Click(object senderEventArgs e)
{
    StringBuilder vDest = new StringBuilder(1024);
    GetSqlData("Zswang", vDest, 1024);
    Text = vDest.ToString();
}
 
http://blog.csdn.net/zswang/article/details/1615264

C#调用Delphi Dll返回字符串的示例(使用Move才能拷贝字符串)

原文:http://www.cnblogs.com/findumars/p/6347933.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!