R rovedream Unregistered / Unconfirmed GUEST, unregistred user! 2006-05-10 #1 因为要向Dll调用函数传递字符,<br>但为什么用PChar(s)将字符串转为字符指针时,s为 '0'~'9'就会出错呢?
F ffhello Unregistered / Unconfirmed GUEST, unregistred user! 2006-05-10 #2 如果传的是字符的话,用pchar将delphi的字符串转为c格式的肯定是没问题的,有可能是动态库内部处理的时候出错了!
R rovedream Unregistered / Unconfirmed GUEST, unregistred user! 2006-05-10 #3 我直接用Pchar('0')这条语句,不调用函数,也会出错<br>不信试试,很奇怪
W wp231957 Unregistered / Unconfirmed GUEST, unregistred user! 2006-05-10 #4 因为用PCHAR强制转换时,后面要跟字符串<br>单独的字母或数字是一个CHAR 不是STRING
F ffhello Unregistered / Unconfirmed GUEST, unregistred user! 2006-05-10 #5 var<br> f: pchar;<br>begin<br> f := Pchar('0');//delphi没有为'0'分配地址,直接将48负值f<br>end;
F ffhello Unregistered / Unconfirmed GUEST, unregistred user! 2006-05-10 #6 var<br> f: pchar;<br> s: string;<br>begin<br> s := '0';<br> f := Pchar(s);<br> messagebox(0,f,'dd',mb_iconinformation);<br>end;
var<br> f: pchar;<br> s: string;<br>begin<br> s := '0';<br> f := Pchar(s);<br> messagebox(0,f,'dd',mb_iconinformation);<br>end;
网 网中戏 Unregistered / Unconfirmed GUEST, unregistred user! 2006-05-10 #7 s为 '0'~'9'在前面加个 ' '就行了<br>showmessage(pchar('9'));//错<br>showmessage(pchar(' '+'9')); //ok
R rovedream Unregistered / Unconfirmed GUEST, unregistred user! 2006-05-10 #9 var<br> f: pchar;<br>begin<br> f := Pchar('0');<br> strpas(f); //执行出错<br>end;<br>呵呵,PChar('0')果然没错,问题出在strpas(f)这句上面,是什么原因呢?
var<br> f: pchar;<br>begin<br> f := Pchar('0');<br> strpas(f); //执行出错<br>end;<br>呵呵,PChar('0')果然没错,问题出在strpas(f)这句上面,是什么原因呢?
R rovedream Unregistered / Unconfirmed GUEST, unregistred user! 2006-05-10 #10 呵呵,分不多,在前面加个''果然可以了<br>谢谢各位的解答