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

查看:25
本文介绍了免注册 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# 中),所以我的问题是:我们也可以在 Delphi 中这样做吗?

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?

谢谢!

推荐答案

在您接触免费注册 com 之前,请确保您的应用程序在 dll 注册后可以正常工作.一旦你对此感到满意.是时候尝试让它免费注册工作了.第一步是注销您的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'}

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

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天全站免登陆