如何在 Windows Server 2008 上使用 32 位 COM 对象(适用于 2008 R2 但非 2008) [英] How to use a 32 bit COM object on Windows Server 2008 (works on 2008 R2 but non 2008)

查看:12
本文介绍了如何在 Windows Server 2008 上使用 32 位 COM 对象(适用于 2008 R2 但非 2008)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用默认的 DllSurrogate 来启用 64 位 32 位 COM 对象的自动化.这在 Windows7 64 位和 Windows Server 2008 R2 中完美运行.然而;常规风味 Windows Server 2008(R2 之前)完全忽略注册表中的 DllSurrogate 条目.我已经研究了几天,发现经典 Windows Server 2008 具有注册表反射的文档,如果 DllSurrogate 值为空白,则忽略它.(我将注册表字符串的值留空以使用默认代理项.)要解决此未反映的问题(未在 32 位和 64 位注册表之间复制),我运行 regedit.exe*32 并设置密钥.然后我打开正常的注册表并设置密钥.仍然没有运气.我还尝试将 DllSurrogate 注册表值设置为 c:windowssyswow64dllhost.exe 以使该值不为空但根本不起作用(在任何操作系统上).我收到的错误是无法创建 activex 对象."

I am using the default DllSurrogate to enable automation of a 32bit COM object in 64bit. This works perfectly in Windows7 64 bit and Windows Server 2008 R2. However; regular flavor Windows Server 2008 (pre R2) completely ignores the DllSurrogate entry in the registry. I've researched this for days and found documentation that classic Windows Server 2008 had registry reflection which ignores the DllSurrogate value if its blank. (I leave the value of the registry string blank to use the default Surrogate.) To work around this not-reflected (not copied between 32bit and 64bit registries), I run the regedit.exe*32 and set the keys. Then I open normal regedit and set the keys. Still no luck. I have also tried setting the DllSurrogate registry value to c:windowssyswow64dllhost.exe so that the value isn't blank but that doesn't work at all (on any OS). The error I receive is "cannot create activex object."

我在 2 台不同的 Windows Server 2008 (Pre R2) 机器上重现了该问题.我还验证了从 32 位应用程序启动时,COM 对象可以在这些机器上使用.我使用 LINQPad 32 位和 64 位进行测试.作为 32 位运行的 LINQPad 可以创建 COM 对象.64 位 LINQPad 不能.

I have reproduced the problem on 2 different Windows Server 2008 (Pre R2) machines. I also verified that the COM object can be used on those machines when launched from a 32 bit app. I used LINQPad 32 bit and 64bit to test. LINQPad running as 32 bit can create the COM object. 64bit LINQPad cannot.

[link text][1] <-- 我正在使用的解决方案(适用于 R2)http://msdn.microsoft.com/en-us/library/aa384253(VS.85).aspx <-- DllSurrogate 注册表项未反映在 Windows Server 2008 上的文档,但我不知道如何规避此限制.我尝试使用 regedit.exe*32 直接编辑 32 位注册表.

[link text][1] <-- Solution I am using (works on R2) http://msdn.microsoft.com/en-us/library/aa384253(VS.85).aspx <-- Documentation that DllSurrogate registry entry is not reflected on Windows Server 2008, but I don't know how to circumvent this limitation. I tried using regedit.exe*32 to edit the 32bit registry directly.

任何想法我在这里缺少什么?在 pre-R2 上使用默认的 DllSurrogate (dllhost.exe) 是否有一些特殊的技巧?将我们的 COM 重写为 .NET 目前不是一种选择.我希望我只是遗漏了一些东西,因为这确实适用于最新的 Windows Server 2008 R2.

Any ideas what I am missing here? Is there some special trick to use the default DllSurrogate (dllhost.exe) on pre-R2? Rewriting our COM to .NET is not an option at the moment. I hope that I am just missing something as this does work on the latest Windows Server 2008 R2.

感谢您的观看!丹尼

推荐答案

问题解决了!感谢汉斯让我走上正轨!我不小心将系统配置为使用 64 位 DLLHost.exe 文件,因为它无法启动 32 位 COM 对象,所以它不起作用.

Problem solved! Thanks Hans for setting me on the right track! I accidentally configured the system to use a 64-bit DLLHost.exe file, which didn't work since it couldn't launch a 32-bit COM object.

从头到尾,以下是我如何在 64 位应用程序中使用我的 32 位 COM 对象.

Start-to-finish, here is how I was able to use my 32-bit COM object from a 64-bit application.

  1. 使用 regedit*32 注册 COM 对象 (c:windowssyswow64 egedit)

  1. Register COM object with regedit*32 (c:windowssyswow64 egedit)

进行以下注册表更改.请务必将其全部放在 Wow6432Node 下,以便使用 32 位 DLLHost.

Make the following registry changes. Be sure to put this all under Wow6432Node so the 32-bit DLLHost will be used.

通过在注册表中搜索类名来确定您的 COM 对象的 GUID.IE.Classname 将是您传递给 createobject 的值,例如 CreateObject("classname").

Determine your COM object's GUID by searching for registry for classname. ie. Classname would be the value you pass to createobject, like CreateObject("classname").

找到现有密钥 HKey_Classes_RootWow6432NodeCLSID[GUID].添加一个名为 AppID 的新 REG_SZ(字符串)值,并将 COM 对象 GUID 作为值.

Locate existing key HKey_Classes_RootWow6432NodeCLSID[GUID]. Add a new REG_SZ (string) Value called AppID with a the COM object GUID as the value.

添加新密钥HKey_Classes_RootWow6432NodeAppID[GUID].在这个新键下,添加一个名为 DllSurrogate 的新 REG_SZ(字符串)值.将该值留空.

Add a new key HKey_Classes_RootWow6432NodeAppID[GUID]. Under this new key, add a new REG_SZ (string) Value called DllSurrogate. Leave the value empty.

如果还没有,请在 HKey_Local_MachineSoftwareWow6432NodeClassesAppID[GUID] 下创建新密钥.如果还没有,请在此键下添加一个名为 DllSurrogate 的新 REG_SZ(字符串)值.将该值留空.

If not already there, create new Key under HKey_Local_MachineSoftwareWow6432NodeClassesAppID[GUID]. If not already there, add a new REG_SZ (string) Value called DllSurrogate under this key. Leave the value empty.

现在,当您创建 COM 对象时,您应该会在任务管理器中看到 DLLHost.exe*32.打开任务管理器的命令行栏,应该会看到C:windowssyswow64dllhost.exe/processid:{YourCOMGUIDHere}

Now when you create your COM object you should see DLLHost.exe*32 show up in task manager. Turn on the command-line column in task manager and you should see C:windowssyswow64dllhost.exe /processid:{YourCOMGUIDHere}

这篇关于如何在 Windows Server 2008 上使用 32 位 COM 对象(适用于 2008 R2 但非 2008)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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