高手请进,如何得到字符串的首地址,加急!!!!!!!!!!!!!!!!
是这样的,调用一个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
请各位帮忙
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
请各位帮忙
...全文
相关推荐
c代码-9、有5个字符串,首先将它们按照字符串中的字符个数由小到大排列, 再分别取出每个字符串的第三个字母合并成一个新的字符串输出(若少于三个字符的输出空格)。要求:利用字符串指针和指针数组实现。
首先,我们需要定义一个字符串指针数组来存储这5个字符串的首地址。
求字符串长度几种方法
方法三:用指向数组首地址的指针访问数组元素方法三使用了指向数组首地址的指针来访问数组元素。
如何在c++中实现字符串分割函数split详解
函数返回处理完毕后的字符串数组的首地址。2.
请用指针数组的方法将字符串排序
### 实现过程详解#### 定义与初始化首先,我们需要定义一个指针数组,用于存储字符串数组中每个字符串的首地址。
实验方法比较字符串sample.asm
然后,在代码段(.text)中,我们可以设置一个主程序,它从两个字符串的首地址开始进行比较:```asm.codemain: mov si, string1 ; 设置si指向string1的首地址 mov


