在其他桌面、Python、Windows 上启动进程 [英] Start process on the other desktop, Python, Windows

查看:59
本文介绍了在其他桌面、Python、Windows 上启动进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了第二个桌面

I have created second desktop

import win32api, win32con, win32gui, win32service, win32process
import pywintypes
import traceback, thread, time, cStringIO


k = win32service.CreateDesktop("ABCD2", 0, win32con.MAXIMUM_ALLOWED, None)

如何在桌面ABCD2"上启动一个进程,比如 calc.exe?

How can I start a process, say, calc.exe on the desktop "ABCD2"?

推荐答案

您可以将 STARTUPINFO.lpDesktop 设置为该桌面的名称:

You can set the STARTUPINFO.lpDesktop to the name of that desktop:

import win32api, win32con, win32gui, win32service, win32process
#import pywintypes
#import traceback, thread, time, cStringIO


hDesktop = win32service.CreateDesktop("ABCD2",
                                      0,
                                      win32con.GENERIC_ALL,
                                      None)

win32api.Sleep(500)
StartInfo = win32process.STARTUPINFO()
StartInfo.lpDesktop = "ABCD2"

ProcInfo = win32process.CreateProcess(
    None,
    "mspaint.exe",
    None,
    None,
    True,
    win32con.NORMAL_PRIORITY_CLASS | win32con.CREATE_NEW_CONSOLE,
    None,
    None,
    StartInfo)

这篇关于在其他桌面、Python、Windows 上启动进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆