Jan*_*tze 2 delphi variables shellexecute
我尝试通过delphi在shell中执行命令,但它不起作用.我用这个脚本:
var
shellexecommand:string;
begin
ShellExecute(0, nil, 'cmd.exe', '/C ' + shellexecommand + ' > output.txt', nil, SW_HIDE);
end;
Run Code Online (Sandbox Code Playgroud)
但我得到错误:
[dcc32错误] Unit1.pas(329):E2010不兼容的类型:'PWideChar'和'AnsiString'
此外,如果我将字符串更改为pwidechar是不起作用.我怎样才能解决这个问题?
试试这个:
var
shellexecommand:string;
begin
// shellexecommand := ....
shellexecommand := '/C ' + shellexecommand + ' > output.txt';
ShellExecute(0, nil, 'cmd.exe', PChar(shellexecommand), nil, SW_HIDE);
end;
Run Code Online (Sandbox Code Playgroud)