我多年来一直在Delphi中使用ShellExecute启动(并可选择等待)其他应用程序。但是现在,我需要让其中一个应用程序出现在我的Delphi应用程序表单中。我尝试了下面的代码作为一个简单的测试来打开记事本(它确实可以),并在我的表单上的PAnel1中显示结果(但它没有)。有没有好心人能帮我找到正确的方向? 谢谢
var
Rec : TShellExecuteInfo;
wnd : HWnd;
const
AVerb = 'open';
AParams = '';
AFileName = 'Notepad.exe';
ADir = '';
begin
FillChar(Rec, SizeOf(Rec), #0);
Rec.cbSize := SizeOf(Rec);
Rec.fMask := SEE_MASK_NOCLOSEPROCESS;
Rec.lpVerb := PChar( AVerb );
Rec.lpFile := PChar( AfileName );
Rec.lpParameters := PChar( AParams );
Rec.lpDirectory := PChar( Adir );
Rec.nShow := sw_Show;
ShellExecuteEx(@Rec);
wnd := Windows.FindWindow( 'Notepad', nil );
Windows.SetParent( Wnd, PAnel1.Handle );
end;