关于PB调用C#dll问题

ddd11326 2016-11-10 09:54:58
由于需要后台生成BMP文件,在PB里面没有找到好用的方法,就写了C#的DLL代码如下
public struct data
{
public string[] name;
public long[] x;
public long[] y;
}
public void createbmp(string ls_name1, long ll_x1, long ll_y1, string ls_name2, long ll_x2, long ll_y2, string ls_name3, long ll_x3, long ll_y3,
string ls_name4, long ll_x4, long ll_y4, string ls_name5, long ll_x5, long ll_y5)
{
Bitmap bmp = new Bitmap(800, 600);
Graphics g = Graphics.FromImage(bmp);
g.FillRectangle(Brushes.White, new Rectangle() { X = 0, Y = 0, Height = 800, Width = 600 });
Font font = new Font("宋体", 30, FontStyle.Bold);
g.DrawString(ls_name1, font, Brushes.Black, new PointF() { X = ll_x1, Y = ll_y1 });
g.DrawString(ls_name2, font, Brushes.Black, new PointF() { X = ll_x2, Y = ll_y2 });
bmp.Save("c:/1.bmp");
bmp.Dispose();
}
public void createbmp1(data ls_data)
{
Bitmap bmp = new Bitmap(800, 600);
Graphics g = Graphics.FromImage(bmp);
g.FillRectangle(Brushes.White, new Rectangle() { X = 0, Y = 0, Height = 800, Width = 600 });
Font font = new Font("宋体", 30, FontStyle.Bold);
string ls_name;
ls_name = ls_data.name[1];
if (ls_name != "")
{
g.DrawString(ls_data.name[1], font, Brushes.Black, new PointF() { X = ls_data.x[1], Y = ls_data.y[1] });
}
ls_name = ls_data.name[2];
if (ls_name != "")
{
g.DrawString(ls_data.name[2], font, Brushes.Black, new PointF() { X = ls_data.x[2], Y = ls_data.y[2] });
}
bmp.Save("c:/1.bmp");
bmp.Dispose();
}

但是在pb里面调用的时候,结构体的参数调用不成功,是数据类型转换有问题吗,请大神指正一下。
st_crcs.name[1] = "姓名"
st_crcs.x[1] = 100
st_crcs.y[1] = 50
st_crcs.name[2] = "性别"
st_crcs.x[2] = 200
st_crcs.y[2] = 50
//objole.createbmp1(st_crcs)
objole.createbmp("姓名",100,50,"性别",200,50)
...全文
1003 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
WorldMobile 2016-11-16
  • 打赏
  • 举报
回复
1、尽量不要用结构,直接用字符串,声明里增加;ansi 2、把程序直接编译成exe,然后再运行试试
ddd11326 2016-11-15
  • 打赏
  • 举报
回复
编译成exe? 你的意思是变成成exe把参数传进去用exe直接生成?
xiaozhe_song 2016-11-10
  • 打赏
  • 举报
回复
你把程序编译成exe试一下~ 没准会有惊喜哦~

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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