高手请进,如何得到字符串的首地址,加急!!!!!!!!!!!!!!!!

wuzy1229 wuzy1229 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
是这样的,调用一个ocx控件,他的函数定义如下
C语法 :BOOL ShowString(short bank, short XPos, short YPos, short Color, long lpString)

需要得到字符串的首地址在转化成long型传给参数lpString ;
如 :
delphi 是这样得到的
string s="你好,早上好!"
long w= integer(Pchar(s));

c#我查了一下资料程序这么写的
private void button3_Click(object sender, System.EventArgs e)
{
bool bnok =false;
int LedWidth = 384;

string s = "你好,早上好!";



bnok=axCL2005Ocx1.ComInitial(1,38400,1000);

if ( bnok ==true)
{
bnok=axCL2005Ocx1.ShowString(1,Convert.ToInt16(LedWidth-3*16),0,0,sendmessage(s));

}

//axCL2005Ocx1.CloseCL2005();
}
unsafe static int sendmessage(string s)
{


int w =0 ;
//s = "你好,早上好!";

fixed(char*p=s)
{

w = (int)p;
// axCL2005Ocx1ShowString(1,LedWidth-3*16,0,0,(int)*p);


}
return w;


}

调试bnok到 bnok=axCL2005Ocx1.ShowString(1,Convert.ToInt16(LedWidth-3*16),0,0,sendmessage(s));总是为false得不到true
请各位帮忙



...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
wuzy1229
C# 111,128 成员 642,537 内容