macos Mac 上的 Pywin32(com 对象)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9233461/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:51:17  来源:igfitidea点击:

Pywin32 (com objects) on Mac

pythoniosmacoswinapicom

提问by Wuzseen

I've got a quick question that I hope someone can help me with.

我有一个简单的问题,希望有人可以帮助我。

I'm in the process of creating/planning an app that needs to run cross platform and use a com library from Windows. In the past I've used win32py to run these com objects in a python app, I've been doing a bunch of research finding a solution on Mac but I've had no luck. Ideally I'd like to stay in Python as I already have working code for Python 2.7 working with this library. If there is a solution in another language however, I would like to hear it.

我正在创建/规划一个需要跨平台运行并使用来自 Windows 的 com 库的应用程序。过去我使用 win32py 在 python 应用程序中运行这些 com 对象,我一直在做大量的研究,在 Mac 上找到解决方案,但我没有运气。理想情况下,我想留在 Python 中,因为我已经有了使用这个库的 Python 2.7 的工作代码。但是,如果有另一种语言的解决方案,我想听听。

I realize that this sounds almost sort of backwards, but to make a long story short I have to make this com library work on Mac. I'm going to be doing some automated testing of some iOS stuff with the iOS SDK simulator.

我意识到这听起来有点倒退,但长话短说,我必须让这个 com 库在 Mac 上运行。我将使用 iOS SDK 模拟器对一些 iOS 内容进行一些自动化测试。

回答by Jordan Parmer

COM is Windows only. COM requires extensive use of the Windows registry and WinAPI. I've seen some frameworks emulate or mock COM behavior on other operating systems (e.g. MainWin on Linux/Solaris), but I don't know of one for Mac.

COM 仅适用于 Windows。COM 需要大量使用 Windows 注册表和 WinAPI。我见过一些框架在其他操作系统(例如 Linux/Solaris 上的 MainWin)上模拟或模拟 COM 行为,但我不知道 Mac 上的框架。

The win32py module is just a wrapper around WinAPI calls. So if the WinAPI isn't available, win32py won't work.

win32py 模块只是 WinAPI 调用的包装器。因此,如果 WinAPI 不可用,则 win32py 将无法工作。

Is the logic you need something you can wrap a service around? In other words, can you host a service on a Windows box and have the Mac application invoke the service?

您需要的逻辑是可以包装服务的东西吗?换句话说,您能否在 Windows 机器上托管服务并让 Mac 应用程序调用该服务?