提示Incompatible types:'string'and 'Pchar',如何解决
编号:QA001824
建立日期: 1999年10月6日 最后修改日期:1999年10月6日
所属类别:
jjc:
Delphi
win98
非常感谢您上次给予的解答(QA001784 "在Delphi中用什么函数运行一个可执行文件")。我的使用shellexecute()函数时
var
Form1: TForm1;
s:string;
procedure TForm1.OutlookBtn7Click(Sender: TObject);
begin
s:=table1.fields[1].asString;
shellExecute(0,'open',s,nil,nil,0);
end;
我想用变量s替代原先的字符串,编译时出错,提示Incompatible types:'string'and 'Pchar',请问如何解决?
回答:
利用强制转换将String型转换为PChar型:
ShellExecute(0,'open', PChar(s), nil, nil, 0);
此问题由李海回答。
| |
|
|
| |
|
|