免注册COM / DLL? [英] Registration-free COM/DLL?

查看:279
本文介绍了免注册COM / DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序正在使用Skype4COM.dll(Skype API的包装器)。

My program is using the Skype4COM.dll (A wrapper for the Skype API).

我正在使用Delphi 2010 - 有没有办法确保我的程序总是使用我将发货的Skype4COM.dll?事实是,有不同版本的Skype4COM,如果我注册我的一个人,他们的应用程序可能不再工作。

I am using Delphi 2010 - is there a way to make sure that my program is ALWAYS using the Skype4COM.dll that I will ship it with? The thing is, there are different versions of Skype4COM, and if I register mine over someone elses, their app may not work anymore.

通常我使用RegSvr32注册DLL对于人民制度,但我听说有可能使其无注册(在C#中),所以我的问题是:我们可以在德尔福这样做吗?

Usually I use RegSvr32 to register the DLL on peoples system, but I heard its possible to make it registration-free (in C#), so my question is: Can we do that in Delp too?

谢谢!

推荐答案

在您甚至触摸免费注册之前,请确保您的应用程序在注册时注册。一旦你对此感到满意现在是尝试免费注册工作的时候了。第一步是取消注册你的dll。如果你现在尝试运行你的程序,你应该找不到ClassId。

Before you even touch registration free com make sure your application works when the dll is registered. Once you are happy with this. It's time to try and get it to work registration free. First step is to unregister your dll. If you try and run your program now you should get ClassId not found.

第一步是为你的应用程序创建一个清单文件。清单文件是一个xml文件,其中可以为应用程序设置依赖关系。您可能不知道,但自从关于Delphi 2007,如果您启用主题,您的应用程序一直有一个清单。这里是Delphi 2010:

First step is to create a manifest file for your application. A manifest file is an xml file which among other things can setup dependencies for your application. You may not know it, but since about Delphi 2007, if you have themes enabled, your application has had a manifest all along. Here it is from Delphi 2010 :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    type="win32"
    name="CodeGear RAD Studio"
    version="14.0.3615.26342" 
    processorArchitecture="*"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        publicKeyToken="6595b64144ccf1df"
        language="*"
        processorArchitecture="*"/>
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="asInvoker"
          uiAccess="false"/>
        </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

现在我不知道是否可以添加到此,您只能有一个清单文件应用程序,我只是通常更换它。因为我想要启用主题,我从这个文件开始,并添加我的依赖。在您的情况下,您需要为skype4com.dll添加依赖关系这是我需要添加的内容:

Now I'm not sure if you can add to this and you can only have one manifest file per application, I just usually replace it completely. Since I want themes enabled I start off with this file and add my dependency. In your case you need to add a dependency for the skype4com.dll Here's what I need to add :

<assemblyIdentity 
  name="Skype4COM.X" 
  version="1.0.36.0" 
  type="win32" 
  processorArchitecture="x86">
</assemblyIdentity>

注意我实际上在Assembly Skye4COM.X中添加了一个依赖关系,而不是dll本身。不要混淆2,虽然dll可以是一个程序集,但并不一定是1 dll。当我们设置装配清单/

Note I am actually adding a dependency to the Assembly Skye4COM.X and not the dll itself. Don't confuse the 2, although a dll can be an assembly an assembly is not necessarily 1 dll. This will become clear when we set up the assembly manifest/

现在,您的清单文件将变为:

Your manifest file now becomes :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    type="win32"
    name="CodeGear RAD Studio"
    version="14.0.3615.26342" 
    processorArchitecture="*"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        publicKeyToken="6595b64144ccf1df"
        language="*"
        processorArchitecture="*"/>
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity 
        name="Skype4COM.X" 
        version="1.0.36.0" 
        type="win32" 
        processorArchitecture="x86">
      </assemblyIdentity>
</dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="asInvoker"
          uiAccess="false"/>
        </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

保存与您的可执行文件相同名称的文件,但使用.manifest后缀。例如 SkypeClient.exe.manifest

Save this file with the same name as your executable, but with a .manifest suffix. For example SkypeClient.exe.manifest

下一步是将此清单嵌入到应用程序中。您需要使用以下文本创建一个资源文件(rc文件):

The next step is to embed this manifest in your application. You'll need to create an resource file (rc file) with the following text :

#define RT_MANIFEST 24 
#define APP_MANIFEST 1

APP_MANIFEST RT_MANIFEST SkypeClient.exe.manifest

添加此文件到您的应用程序并构建。如果您仍然启用主题,您将获得重复的资源警告,只需从您的dpr文件中删除{$ R * .res}。您也应该在项目文件中看到这一点:

Add this file to your application and build. If you still have themes enabled you will get a duplicate resource warning, just removed the {$R *.res} from your dpr file. You should also see this in the project file :

{$R 'SkypeClient.manifest.res' 'SkypeClient.manifest.rc'}

如果您现在尝试运行应用程序,您将收到以下错误消息: p>

If you try and run your application now, you will get the following error message :


无法创建过程:
应用程序无法启动
,因为它的并排配置
不正确请参阅
应用程序事件日志或使用
命令行sxstrace.exe工具
更多细节。

Unable to create process: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.

我们现在需要为程序集添加一个清单(Skype4COM.X)。创建一个名为Skype4COM.X.manifest的文件。我们需要在清单文件中描述程序集:

We now need to add a manifest for the assembly (Skype4COM.X). Create a file called Skype4COM.X.manifest. We need to describe the assembly in the manifest file :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

  <assemblyIdentity 
    name="Skype4COM.X" 
    version="1.0.36.0" 
    type="win32"
    processorArchitecture="x86">
  </assemblyIdentity>

  <file name="Skype4COM.dll">
    <typelib
      tlbid="{03282B5D-B38F-469D-849A-09B0A7F4881B}"
      version="1.0"
      helpdir=""
      flags="hasdiskimage"/>
  </file>
</assembly>

现在将应用程序的dll和程序集清单放在同一个文件夹中,运行!

Now place the Application the dll and the assembly manifest in the same folder and run!

如果您再收到错误,则需要使用SxSTrace进行调试。这在Vista上可用。首先开始跟踪:

If you get anymore errors you'll need to use SxSTrace to debug. This is available on Vista onwards. First start a trace :

SxSTrace trace -logfile:sxsTrace.etl

运行程序,然后按回车键进行完成。现在解析跟踪:

run your program, and then press enter on the trace to finish it. Now parse the trace :

SxSTrace parse -logfile:SxSTrace.etl -outfile:SxStrace.txt

您应该在SxSTrace.txt中有一个全面的日志记录

You should have a comprehensive log of the whole process in SxSTrace.txt

这篇关于免注册COM / DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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