我也没有做过,以下供参考。
还有,使用Ole的方式可能不满足你的需求,打印比较麻烦。
那种方式适合可以Ole的对象。
建立桌面
CreateDesktop(
'name of desktop',
Nil, Nil, 0,
DESKTOP_CREATEMENU or
DESKTOP_CREATEWINDOW or
DESKTOP_SWITCHDESKTOP or
DESKTOP_READOBJECTS or
DESKTOP_WRITEOBJECTS or
STANDARD_RIGHTS_REQUIRED,
Nil );
切换桌面:
HDESK OpenDesktop(
LPTSTR lpszDesktop, // desktop name
DWORD dwFlags, // interaction option
BOOL fInherit, // inheritance option
ACCESS_MASK dwDesiredAccess // handle access
);
BOOL SwitchDesktop(
HDESK hDesktop // handle to desktop to activate
);
关闭桌面:
BOOL CloseDesktop(
HDESK hDesktop // handle to desktop
);
在特定的桌面上运行程序:
procedure RunProgramOnDesktop(filename:string;desktop:string);
Var
si : StartUpInfo;
pi : PROCESS_INFORMATION;
bStarted : Boolean;
dw : DWord;
lr : LResult;
szCurDir : Array[0..MAX_PATH] Of Char;
szAppToRun : Array[0..MAX_PATH] Of Char;
begin
ZeroMemory(@si, SizeOf(StartUpInfo));
ZeroMemory(@pi, SizeOf(PROCESS_INFORMATION));
si.cb := SizeOf(StartUpInfo);
SI.lpDesktop := pchar(desktop);
//si.lpDesktop := Nil;
si.dwFlags := STARTF_USESHOWWINDOW;
si.wShowWindow := SW_SHOWDEFAULT;
bStarted := CreateProcess(Nil, //lpApplicationName: PChar;
pchar(filename), //lpCommandLine: PChar;
Nil, //PSecurityAttributes,
Nil, //PSecurityAttributes
false, //bInheritHandles
NORMAL_PRIORITY_CLASS,//dwCreationFlags
Nil, //lpEnvironment
nil, //lpCurrentDirectory
si, //TStartupInfo
pi); //TProcessInformation
//ShowMessage(SysErrorMessage(GetLastError));
end;