兄弟!!怎么说你好呢?实在是。。。不会变通。你在Create传入参数的时候,传string类型,在Execute里面执行ShellExecute的时候,再把保存从Create传入的参数的那个变量利用我写的TranslateStringToPChar来转换就可以了!
TMyThread = class (TThread)
private
Oper, Dir, App, Params: string;
protected
procedure Execute;
public
constructor Create(const AOper, ADir, AApp, AParams: string);
end;
constructor TMyThread.Create(const AOper, ADir, AApp, AParams: string);
begin
Oper := AOper;
Dir := ADir;
App := AApp;
Params := AParams;
inherited Create(False);
end;
procedure OpenFile(hWnd: HWND; AOperation, AFileName,
AParameters, ADirectory: String; ShowCmd: Integer);
function TranslateStringToPChar(const S: string): PChar;
begin
if S <> '' then Result := PChar(S)
else Result := nil;
end;
begin
ShellExecute(hWnd, TranslateStringToPChar(AOperation),
TranslateStringToPChar(AFileName),
TranslateStringToPChar(AParameters),
TranslateStringToPChar(ADirectory), ShowCmd);
end;
procedure TMyThread.Execute;
begin
OpenFile(0, Oper, App, Params, Dir, SW_SHOWNORMAL);
end;