的ActiveX,安装不起作用 [英] ActiveX, installation doesn't work

查看:506
本文介绍了的ActiveX,安装不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建和部署一个ActiveX插件,somethign真的很小。我只是想显示一个消息框。

I want to create and deploy an ActiveX plugin, somethign really small. I just want to display a message box.

我已经创建了一个库项目,并将其编译为一个DLL。该插件时,我通过命令行注册DLL( regasm )的一体机。

I've created a library project for it and compile it to a DLL. The plugin works when I register the dll via command line (regasm) on one machine.

所以,我现在需要创建一个安装程序,将其放在一个CAB文件并签名。

So I now need to create an installer, put it inside a CAB file and sign it.

我已经安装了Visual Studio 2008中使用的安装项目的项目(但我可以使用InstallShield从2010+如果任何人都可以解释如何做到这一点)。我想补充我的DLL到应用程序文件夹并将其标记为注册= vsdrpCOM 和我建立它,我得到的.msi和.exe。

I've installed Visual Studio 2008 to use Setup Project project (but I can use the InstallShield from 2010+ if anyone can explain how to do it). I add my dll to the Application Folder and mark it as Register = vsdrpCOM and I build it and I get a .msi and .exe.

我想我只需要MSI文件,而不是exe文件。我创建了一个SETUP.INF文件与休耕内容:

I think I only need the msi file and not the exe. I created a setup.inf file with the fallowing content :

[version]
signature="$CHICAGO$"
AdvancedINF=2.0

[Setup Hooks]
hook1=hook1

[hook1]
run=msiexec.exe /i "%EXTRACT_DIR%\ActiveInstaller.msi" /qn

要建立我用命令makecab /˚Fbuild.ddf .cab文件。 这是我的.ddf文件:

To build the .cab file I use the command makecab /f build.ddf. Here is my .ddf file :

.Set DiskDirectoryTemplate=;
.Set CabinetNameTemplate=ActiveInstaller.cab
../ActiveInstaller.msi
../setup.inf

这生成的cab文件。现在我需要签字。目前,我用我生成,并安装在我的电脑自签名证书(当我检查就签收CAB文件,窗户说,这是安全的)。我使用的是 signtool signwizard (我也尝试手动签署从<一个又一个命令行href="http://stackoverflow.com/questions/84847/how-do-i-create-a-self-signed-certificate-for-$c$c-signing-on-windows">here).然后将文件进行签名,我把它上传到我的网站,我推出的网站,我提示安装插件,我安装它。

This generated the cab file. Now I need to sign it. At the moment I used a self signed certificate that I generated and installed on my pc (when I check the sign cab file, windows says it's safe). I use another command line which is signtool signwizard (I also try to sign it manually from here). Then the file is signed and I upload it to my website, I launch the website, I'm prompted to install the plugin and I install it.

不过,它不工作,我不知道为什么。我试过这么多的东西,不同的安装程序,不同的选择,不同的inf文件,不同的签名方法,等等。

But then, it does not work, I have no idea why. I've tried so much stuff, with different installer, different options, different inf file, different signing method, etc.

这是我发现至少有三十岁了唯一的教程中,我不知道什么是改变,因为他们写道。 下面是我使用的主要环节:<一href="http://blogs.msdn.com/b/asiatech/archive/2011/12/05/how-to-develop-and-deploy-activex-control-in-c.aspx" rel="nofollow">http://blogs.msdn.com/b/asiatech/archive/2011/12/05/how-to-develop-and-deploy-activex-control-in-c.aspx另有一的http:// WWW 。codeproject.com /用品/ 24089 /创建-的ActiveX功能于NET-步骤分步

The only tutorial that I found are at least three years old, I don't know if anything as changed since they were wrote. Here are the main link that I used : http://blogs.msdn.com/b/asiatech/archive/2011/12/05/how-to-develop-and-deploy-activex-control-in-c.aspx and another one http://www.codeproject.com/Articles/24089/Create-ActiveX-in-NET-Step-by-Step

解决方法:

所以,一切西葫芦说的是真的,所以我标志着他的答案接受。 我还发现有人谁的全部源$ C ​​$ C(包括如何创建一个运行MSI .exe文件)的这里

So, everything Pepo said is true so I marked his answer as accepted. I also found someone who the whole source code (including how to create the .exe which runs the msi) here.

推荐答案

该问题可能是您尝试运行在msiexec.exe这个exe文件是不是在cab文件。请参阅<一href="http://social.msdn.microsoft.com/Forums/ie/en-US/3d355fb6-8d6a-4177-98c2-a25665510727/activex-control-deployment-on-vista-using-msi-and-cab-setup-hooks?forum=ieextensiondevelopment"相对=nofollow>这个问题(一定要向下滚动到难以置信的帮助样品code发表Roey 5 2009年8月)。 尝试可以创建一个Setup.exe将在驾驶室中运行msiexec.exe的过程和安装MSI或制作安装程序与引导setup.exe文件,包括两者。

The problem might be that you try to run msiexec.exe and this exe is not in the cab file. See this question (be sure to scroll down to the incredibly helpful sample code posted by Roey 5 Aug 2009). Try to either create a setup.exe that will run process msiexec.exe and install your msi or make an installer with a bootstrap setup.exe file and include both in the cab.

此外,您可能想阅读有关非管理员的ActiveX安装的。

Also, you might want to read about non-admin activex installations.

您的ActiveX DLL已被签署,您的ActiveX应该实现此接口

Your activex dll has to be signed and your activeX should implement this interface

/// <summary>
/// Options supported for the IObjectSafety interface 
/// </summary>
[Serializable]
[ComVisible(true)]
public enum ObjectSafetyOptions
{
    /// <summary>
    /// Indicates that the caller of the interface identified by riid might be untrusted.
    /// </summary>
    INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001,
    /// <summary>
    /// Indicates that the data passed into the interface identified by riid might be untrusted.
    /// </summary>
    INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002,
    /// <summary>
    /// Indicates that the caller of the interface identified by riid knows to use IDispatchEx.
    /// </summary>
    INTERFACE_USES_DISPEX = 0x00000004,
    /// <summary>
    /// Indicates that the data passed into the interface identified by riid knows to use IInternetHostSecurityManager.
    /// </summary>
    INTERFACE_USES_SECURITY_MANAGER = 0x00000008
};

/// <summary>
/// Provides methods to get and set safety options.
/// The IObjectSafety interface should be implemented by objects that have interfaces which support "untrusted" clients, such as scripts.
/// It allows the owner of the object to specify which interfaces must be protected from "untrusted" use.
/// </summary>
[ComImport()]
[Guid("CB5BDC81-93C1-11CF-8F20-00805F2CD064")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IObjectSafety
{
    /// <summary>
    /// Gets the safety options supported by an object and the safety options that are currently set for that object.
    /// </summary>
    /// <param name="iid">An interface identifier for a given object</param>
    /// <param name="pdwSupportedOptions">Receives the address of a DWORD representing all the options supported for the interface identified by riid.</param>
    /// <param name="pdwEnabledOptions">Receives the address of a DWORD representing all the options currently enabled for the interface identified by riid.</param>
    /// <returns>Returns one of the following values:
    /// S_OK - the object is safe for loading
    /// E_NOINTERFACE - the riid parameter specifies an interface that is unknown to the object</returns>
    [PreserveSig]
    long GetInterfaceSafetyOptions(ref Guid iid, out int pdwSupportedOptions, out int pdwEnabledOptions);

    /// <summary>
    /// Returns whether an object is safe for initialization or scripting, as specified.
    /// </summary>
    /// <param name="iid">An iInterface identifier for the object to be made safe.</param>
    /// <param name="dwOptionSetMask">A mask representing the options to be validated.</param>
    /// <param name="dwEnabledOptions">A DWORD representing all the options currently enabled for the interface identified by riid. </param>
    /// <returns>Returns one of the following values:
    /// S_OK - the object is safe for loading
    /// E_NOINTERFACE - the riid parameter specifies an interface that is unknown to the object
    /// E_FAIL - the dwOptionSetMask parameter specifies an option that is not supported by the object</returns>
    [PreserveSig]
    long SetInterfaceSafetyOptions(ref Guid iid, int dwOptionSetMask, int dwEnabledOptions);
};

我采用先进的安装程序创建的MSI安装程序,然后我把 DLL注册。先进的安装程序,然后生成的所有必要的注册表项。

I used advanced installer to create msi installer and I set dll registration. Advanced installer then generated all necessary registry keys.

在我的测试中最后的inf文件是

In my test the final inf file was

[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Deployment]
InstallScope=user|machine
[Setup Hooks]
install=install
[install]
run="""%EXTRACT_DIR%\runmsi.exe""" """%EXTRACT_DIR%\simpleactivex.msi"""

请注意,三重引号。它们是重要的。

Please note the triple quotes. They are important.

我用这个DDL

.Set DiskDirectoryTemplate=.
.Set CabinetNameTemplate=simpleactivex.cab
runmsi.exe
simpleactivex.msi
simpleactivex.inf

和我建立使用这个命令驾驶室

And I build cab using this commands

"c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\signtool.exe" sign /sha1 9A15DC8F51773C557BA2F75CF155F8CBD367A8E1 /tr http://tsa/tsa /d SimpleActiveX /du "http://yourcompany.com" /v runmsi.exe simpleactivex.msi

makecab /V3 /F make.ddl

"c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\signtool.exe" sign /sha1 9A15DC8F51773C557BA2F75CF155F8CBD367A8E1 /tr http://tsa/tsa /d simpleactivex /du "http://yourcompany.com" /v simpleactivex.cab

runmsi.exe是运行与给定参数MSIEXEC一个虚拟的exe文件。或者您可以使用的exe安装程序或引导程序的EXE和MSI安装程序。需要注意的最重要的部分是,IE浏览器将不允许运行cab文件以外的任何东西。因此,你需要做的这个技巧。

runmsi.exe is a dummy exe file that runs msiexec with given parameters. Alternatively you could use exe installer or bootstrap exe and msi installer. The important part to note is that IE will not allow to run anything outside the cab file. Therefore you have to do this hack.

在调试我用这个假的html页面

When debugging I used this dummy html page

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 

<html>
  <head>
    <title>WebForm1</title>
  </head>
  <body style="margin-top: 0px; margin-left: 0px;">
  <OBJECT id="SimpleActiveXCtrl" classid="clsid:C0082E22-8A19-4600-8332-D31C4055291A" codebase="SimpleActiveX.CAB"></OBJECT>    

<script language="javascript">
    // da sa volat z JS metody ActiveXu alebo nastavit property
function OpenActiveX()
{
    try
    {
        alert(document.SimpleActiveXCtrl.HelloWorld("hello"));
    }
    catch(Err)
    {
        alert(Err.description);
    }
}   


</script>

  </body>
</html>

这篇关于的ActiveX,安装不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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