首页  编辑  

在另外的桌面运行程序

Tags: /超级猛料/OS.操作系统/桌面/   Date Created:

runs the *entire application* in the other desktop

program Project1;

uses

 Forms,

 Windows,

 Unit1 in 'Unit1.pas' {Form1};

{$R *.RES}

var

 NewDesktop, thisdesktop : HDESK;

begin

 thisdesktop := GetThreadDesktop(GetCurrentThreadId);

 Application.Free;

 NewDesktop := CreateDesktop( 'MyDeskTop', nil, nil, 0,

                               GENERIC_ALL, nil );

 SetThreadDesktop( NewDesktop );

 Application := TApplication.Create(nil);

 SwitchDesktop( NewDesktop );

 Application.Initialize;

 Application.CreateForm(TForm1, Form1);

 Application.Run;

 SetThreadDesktop( thisDesktop );

 SwitchDesktop( thisDesktop );

 CloseDesktop( NewDesktop );

end.

Only tested on NT4 using Delphi 3 - no an Application uses restrictions.