高手请进,如何得到字符串的首地址,加急!!!!!!!!!!!!!!!!
是这样的,调用一个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
请各位帮忙