本地 IIS - Com 互操作 iTunes

发布于 2024-12-09 03:41:28 字数 419 浏览 0 评论 0原文

小问题,有人能够通过任何本地网络部署来控制 iTunes 吗? 最适合通过托管 IIS WCF 服务?

我在带有 IIS7.5 的 Windos 7 上尝试过,当我在包含 WCF 服务的 IIS 应用程序池上将进程模型 - 身份设置为“本地系统”时,我看到任务管理器中弹出 iTunes.exe。 但 iTunes 并没有“活跃”——没有可视外壳,即使 iTunesApp 对象在我的 WCF 服务代码中初始化,对其执行任何操作都将不起作用。

除此之外,通过 Visual Studio 2010 调试模式运行相同的服务,一切都运行得很好!

  • 更新 * 我试图通过我的 Windows 手机与 iTunes 进行通信,我想通过网站/服务来解决这个问题...但是通过新的 Mango 更新,我们可以在手机上进行本机 TCP 套接字!所以我会尝试这条路线。

Small question, was anyone able to control iTunes through any local webdeployment?
Most preferable through a hosted IIS WCF service?

I've tried on my Windos 7 with IIS7.5 and when I set the Process Model - Identity to 'Local System' on the IIS apppool containing the WCF service, I see the iTunes.exe popping up in the Task Manager.
But iTunes doesn't come 'alive' - no visual shell and even though the iTunesApp object is initialized in my WCF Service code, perfomring any actions on it won't work.

Side not, running the same service through Visual Studio 2010 debug mode, everything works just great!

  • UPDATE *
    I was trying to communicate to iTunes through my windows phone and I thought of going round that with a website/service... but with the new Mango update we can do TCP sockets native on the phone! SO I'll try that route.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陈独秀 2024-12-16 03:41:28

服务不显示任何 UI 窗口的原因是 会话隔离。您的服务(IIS 应用程序池进程)正在会话 0 中运行。您的桌面连接到会话 1(如果有多个用户登录到这台计算机,则连接到其他数字)。

有几种解决方法可以允许服务向用户显示 UI:
1. 您可以使用“允许服务与桌面交互”选项来标记服务。这仅适用于作为本地系统运行的服务。此选项已弃用,仅应用于与旧服务的兼容性。
2. 服务可以在用户会话中启动中间进程并与之通信。

如果您不想与 iTunes 交互,只想将其启动到用户会话中,您需要做的是:

  • 获取用户正在运行的 Windows Station 的名称。您可以使用 Windows 终端服务 API 为此。您必须发挥创意才能找出当前处于活动状态的用户会话(如果有多个)。您可能还想查询用户安全令牌,以便该进程作为用户运行,而不是作为本地系统运行。
  • 调用 CreateProcessAsUser 并传递 STARTUPINFO 结构。将 STARTUPINFO 中的 lpDesktop 字段设置为指向您识别的窗口站。

The reason service does not show any UI windows is becuase of Session Isolation. Your service (IIS application pool process) is running in session 0. Your desktop is attached to session 1 (or some other number if more than one user is logged on on this machine).

There are couple of workarounds to allow services to show UI to user:
1. You can mark service with option "Allow service to interact with desktop". This only works for services that are running as local system. This option is deprecated, should only be used for compatibility with legacy services.
2. Service can launch an intermediate process in user session and communicate to it.

If you don't want to interact with iTunes, and only want to lanch it in user session, what you need to do is:

  • Obtain name of windows station the user is running. You can use windows terminal services API for that. You will have to be creative to figure out which user session is currently active (if there is more than one). You probably also want to query user security token, so that process is run as a user, and not as a local system.
  • Call CreateProcessAsUser and pass STARTUPINFO structure. Set lpDesktop field in STARTUPINFO to point to window station you identified.
北风几吹夏 2024-12-16 03:41:28

在 Visual Studio 2010 中进行调试时,此方法有效的原因是您在登录名下运行 VS,并且您的登录名具有 iTunes 可以与之交互的可见桌面。

如果您从服务帐户下运行的进程启动,那么您会在任务管理器中看到可执行文件,但 iTunes 不会有可见的桌面可供交互。

The reason this works when debugging in Visual Studio 2010 is because you're running VS under your login and your login has a visible desktop that iTunes can interact with.

If you launch from a process running under a service account then yes you'll see the executable in task manager but the iTunes won't have a visible desktop to interact with.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文