Article View: borland.public.cppbuilder.nativeapi
Article #7224Running app on another desktop
From: Daniel
Date: Sun, 06 Mar 2005 23:59
Date: Sun, 06 Mar 2005 23:59
99 lines
3474 bytes
3474 bytes
I am attempting to spawn an application on another desktop (with the new
desktop visible, thereby hiding the default desktop).
For reference, the launching of the application is performed in a worker
thread, where this thread waits for the launched application to close
before it terminates, closing the desktop etc.
I can see my launched program running in Task Manager but the new desktop
is not made visible.
I'm currently using all access options until I can sort out where I am
going wrong.
I'd appreciate someone pointing me where I am going wrong. TIA.
Here is the code:
// temporary until I get this to work
#define DESKTOP_ALL ( DESKTOP_READOBJECTS | DESKTOP_CREATEWINDOW | \
DESKTOP_CREATEMENU | DESKTOP_HOOKCONTROL | \
DESKTOP_JOURNALRECORD | DESKTOP_JOURNALPLAYBACK | \
DESKTOP_ENUMERATE | DESKTOP_WRITEOBJECTS | \
DESKTOP_SWITCHDESKTOP )
// temporary until I get this to work
#define WINSTA_ALL ( WINSTA_ACCESSCLIPBOARD | WINSTA_ACCESSGLOBALATOMS | \
WINSTA_CREATEDESKTOP | WINSTA_ENUMDESKTOPS |
WINSTA_ENUMERATE | \
WINSTA_EXITWINDOWS | WINSTA_READATTRIBUTES |
WINSTA_READSCREEN | \
WINSTA_WRITEATTRIBUTES )
void __fastcall TSecondaryDesktopThread::Execute()
{
HWINSTA AWindowStation = ::CreateWindowStation("NewStation", NULL,
WINSTA_ALL, NULL);
::SetProcessWindowStation(AWindowStation);
HDESK ADesktop = ::CreateDesktop("NewDesktop", NULL, NULL, 0,
DESKTOP_ALL, NULL);
::SetThreadDesktop(ADesktop);
::SwitchDesktop(ADesktop);
AnsiString AppExe = "SecondDesktopApp.exe";
STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD dwStatus;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
si.lpTitle = "NewDesktop";
si.lpDesktop = "NewStation\\NewDesktop";
::CreateProcess(NULL, AppExe.c_str(), NULL, NULL, false,
NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &pi);
do
{
::GetExitCodeProcess(pi.hProcess, &dwStatus);
::Sleep(1);
} while( dwStatus == STILL_ACTIVE );
::CloseHandle(pi.hProcess);
::CloseHandle(pi.hThread);
::CloseDesktop(ADesktop);
::CloseWindowStation(AWindowStation);
}
Daniel
--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Technical Details
Message-ID:
<opsm8p981moyenhq@development-ws2.comvision.intranet>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,a1b849e29d6cf9bc,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Mon, 07 Mar 2005 10:59:58 +1100 Subject: Running app on another desktop Reply-To: d.jimenez@comvision.net.au Newsgroups: borland.public.cppbuilder.nativeapi From: Daniel <d.jimenez@comvision.net.au> Organization: Comvision Pty Ltd Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable Message-ID: <opsm8p981moyenhq@development-ws2.comvision.intranet> User-Agent: Opera M2/7.54 (Win32, build 3929) NNTP-Posting-Host: 60.229.104.14 X-Trace: newsgroups.borland.com 1110153636 60.229.104.14 (6 Mar 2005 16:00:36 -0800) Lines: 99 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail