c# 调用c++api 参数类型? (在线等) 函数类型、类定义等关键信息缺失,无法判断还有什么问题,但是&rect是传指针啊,你调用的时候传值是什么意思? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 返回值,我用的。stringbulder 指针参数,我实验过 sb 类型不行rect 结构 也不行 传指针的话是ref而且你确定Barcodematrix_rect的大小够大么? [DllImport("Barcode.dll", CharSet = CharSet.Unicode)] public static extern uint DrawBarcode( IntPtr hdc, StringBuilder Text, // 如果这WCHAR*参数是In类型,请用StringBuilder代替 StringBuilder StartStopChar, StringBuilder FaceName, StringBuilder Buffer, ref RECT Bounds, ref RECT BarcodeMatrix, int TextWidth, int TextHeight, int TextToBarcode, int TextQuietZone, int BarInflate, uint Color,//这个用。Net的Color.ToArgb();方法获取,或者自己做位移都行 uint Params); //高度怀疑这个参数可能是32位指针类型,可用IntPtr代替。IntPtr rec_IntPtr = new IntPtr(); StringBuilder sb_text = new StringBuilder(1024); sb_text.Append("23432432432"); StringBuilder sb_starcode = new StringBuilder(1024); sb_starcode.Append(">"); StringBuilder sb_facename = new StringBuilder(1024); sb_facename.Append("Arial"); StringBuilder sb_buffer = new StringBuilder(1024); RECT matrix_dc = new RECT(); matrix_dc.Bottom = 0; matrix_dc.Left = 0; matrix_dc.Right = 0; matrix_dc.Top = 0; RECT bound_dc = new RECT(); bound_dc.Bottom = 0; bound_dc.Left = 0; bound_dc.Right = 0; bound_dc.Top = 0; int textwidth = 8; int texheight = 24; int textbobarcode = 4; int textquiezone = 24; int barinflate = 0; uint _Color = 754353; uint _Params = 754353; try { uint r; r = DrawBarcode( rec_IntPtr, sb_text, sb_starcode, sb_facename, sb_buffer, ref bound_dc, ref matrix_dc, textwidth, texheight, textbobarcode, textquiezone, barinflate, _Color, _Params); } catch (Exception ex) { throw ex; } ----------------------------闪退。 去掉ref 则报错 读写保护的内存..................... [DllImport("Barcode.dll", CharSet = CharSet.Unicode)] public static extern uint DrawBarcode( IntPtr hdc, StringBuilder Text, // 如果这WCHAR*参数是In类型,请用StringBuilder代替 StringBuilder StartStopChar, StringBuilder FaceName, StringBuilder Buffer, ref RECT Bounds, IntPtr BarcodeMatrix, int TextWidth, int TextHeight, int TextToBarcode, int TextQuietZone, int BarInflate, uint Color,//这个用。Net的Color.ToArgb();方法获取,或者自己做位移都行 uint Params); //高度怀疑这个参数可能是32位指针类型,可用IntPtr代替。IntPtr rec_IntPtr = new IntPtr(); StringBuilder sb_text = new StringBuilder(1024); sb_text.Append("6923450656185"); StringBuilder sb_starcode = new StringBuilder(1024); sb_starcode.Append(">"); StringBuilder sb_facename = new StringBuilder(1024); sb_facename.Append("Arial"); StringBuilder sb_buffer = new StringBuilder(1024); IntPtr matrix_dc = new IntPtr(); RECT bound_dc = new RECT(); bound_dc.Bottom = 20; bound_dc.Left = 10; bound_dc.Right = 50; bound_dc.Top = 20; int textwidth = 8; int texheight = 24; int textbobarcode = 4; int textquiezone = 24; int barinflate = 0; uint _Color = (uint)Color.Black.ToArgb(); uint _Params = TranslateStrTo16(0); try { uint r; r = DrawBarcode( this.Handle, sb_text, sb_starcode, sb_facename, sb_buffer, ref bound_dc, matrix_dc, textwidth, texheight, textbobarcode, textquiezone, barinflate, _Color, _Params); } catch (Exception ex) { throw ex; } 已经不异常 不报错了返回13但参数matrix_dc 应该返回ilist<>这样的结构数据,因为参数无法使用ilist<> 所以无法获取实际返回的数据!!!!该如何?? 怎么屏蔽ctrl+alt+del alt+tab热键 webbrowser控件的问题 急,TAB的使用 有关操作符号! 腾讯微博API add_pic 签名错误 求助webBrowser1控件的问题。谢谢! 范类列表List<T>如何以xml文件格式保存到硬盘 求助:ADO.NET如何有条件地执行UPDATE或INSERT语句 使用regasm注册.net程序集 vs.net2005之支持jmail组件吗? fckeditor能保留文本的修改痕迹吗 MDI窗口程序中,如何实现多个窗口共用状态栏
指针参数,我实验过 sb 类型不行
rect 结构 也不行
而且你确定Barcodematrix_rect的大小够大么?
public static extern uint DrawBarcode(
IntPtr hdc,
StringBuilder Text, // 如果这WCHAR*参数是In类型,请用StringBuilder代替
StringBuilder StartStopChar,
StringBuilder FaceName,
StringBuilder Buffer,
ref RECT Bounds,
ref RECT BarcodeMatrix,
int TextWidth,
int TextHeight,
int TextToBarcode,
int TextQuietZone,
int BarInflate,
uint Color,//这个用。Net的Color.ToArgb();方法获取,或者自己做位移都行
uint Params); //高度怀疑这个参数可能是32位指针类型,可用IntPtr代替。IntPtr rec_IntPtr = new IntPtr();
StringBuilder sb_text = new StringBuilder(1024);
sb_text.Append("23432432432");
StringBuilder sb_starcode = new StringBuilder(1024);
sb_starcode.Append(">");
StringBuilder sb_facename = new StringBuilder(1024);
sb_facename.Append("Arial");
StringBuilder sb_buffer = new StringBuilder(1024);
RECT matrix_dc = new RECT();
matrix_dc.Bottom = 0; matrix_dc.Left = 0; matrix_dc.Right = 0; matrix_dc.Top = 0;
RECT bound_dc = new RECT();
bound_dc.Bottom = 0; bound_dc.Left = 0; bound_dc.Right = 0; bound_dc.Top = 0;
int textwidth = 8; int texheight = 24; int textbobarcode = 4;
int textquiezone = 24; int barinflate = 0;
uint _Color = 754353;
uint _Params = 754353; try
{
uint r;
r = DrawBarcode(
rec_IntPtr,
sb_text,
sb_starcode,
sb_facename,
sb_buffer,
ref bound_dc,
ref matrix_dc,
textwidth, texheight, textbobarcode, textquiezone, barinflate,
_Color,
_Params);
}
catch (Exception ex)
{ throw ex; }
----------------------------
闪退。 去掉ref 则报错 读写保护的内存.....................
public static extern uint DrawBarcode(
IntPtr hdc,
StringBuilder Text, // 如果这WCHAR*参数是In类型,请用StringBuilder代替
StringBuilder StartStopChar,
StringBuilder FaceName,
StringBuilder Buffer,
ref RECT Bounds,
IntPtr BarcodeMatrix,
int TextWidth,
int TextHeight,
int TextToBarcode,
int TextQuietZone,
int BarInflate,
uint Color,//这个用。Net的Color.ToArgb();方法获取,或者自己做位移都行
uint Params); //高度怀疑这个参数可能是32位指针类型,可用IntPtr代替。IntPtr rec_IntPtr = new IntPtr();
StringBuilder sb_text = new StringBuilder(1024);
sb_text.Append("6923450656185");
StringBuilder sb_starcode = new StringBuilder(1024);
sb_starcode.Append(">");
StringBuilder sb_facename = new StringBuilder(1024);
sb_facename.Append("Arial");
StringBuilder sb_buffer = new StringBuilder(1024);
IntPtr matrix_dc = new IntPtr();
RECT bound_dc = new RECT();
bound_dc.Bottom = 20; bound_dc.Left = 10; bound_dc.Right = 50; bound_dc.Top = 20;
int textwidth = 8; int texheight = 24; int textbobarcode = 4;
int textquiezone = 24; int barinflate = 0;
uint _Color = (uint)Color.Black.ToArgb();
uint _Params = TranslateStrTo16(0);
try
{
uint r;
r = DrawBarcode(
this.Handle,
sb_text,
sb_starcode,
sb_facename,
sb_buffer,
ref bound_dc,
matrix_dc,
textwidth, texheight, textbobarcode, textquiezone, barinflate,
_Color,
_Params);
}
catch (Exception ex)
{ throw ex; }
已经不异常 不报错了
返回13
但参数matrix_dc 应该返回ilist<>这样的结构数据,因为参数无法使用ilist<> 所以无法获取实际返回的数据!!!!
该如何??