.net DLL 注册 regasm

regasm

regasm myTest.dll

regasm.exe

打开vs2005自带的工具“Visual Studio 2005命令提示”,输入上述命令

在没有安装vs开发环境的电脑上,必须安装。net framwork环境2.0以上,或根据项目要求安装合适的framwork版本。

不能再普通的cmd命令下执行,找不到命令。

进入普通的cmd窗口

cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

进入这个目录下,再执行regasm命令就可以识别了。

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm  d:\app\mytest.dll

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm MyEnCrypt.dll /tlb:MyEncrypt.tlb

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\regasm   test.dll /tlb:test.tlb

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\regasm   IMComInterface.dll  /tlb:IMComInterface.tlb

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\regasm   IMComInterface.dll

32位系统

C:\Windows\Microsoft.NET\v2.0.50727\regasm.exe  IMComInterface.dll

C:\Windows\Microsoft.NET\v4.0.30319\regasm.exe  IMComInterface.dll

64位系统

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\regasm.exe  IMComInterface.dll

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe  IMComInterface.dll

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\regasm.exe /u IMComInterface.dll

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /u IMComInterface.dll

有的dll只能用4.0注册,2.0注册失败。

RegAsm : error RA0000 : “E:\MYDEV\test.dll”不是有效的 .NET 程序集,因 此未能加载它

delphi调用

方法一

打开vs2005自带的工具“Visual Studio 2005命令提示”,输入 TlbExp  路径/TestClass.dll 得到一个TestClass.tlb 文件。

打开Delphi,选择“Project”--“import type library”找到刚才的TestClass.tlb,点击 CreateUnit,生成生成的TLB的pas文件

  var aClass: TestClass; 
  begin
    aClass : =  CoTestClass.Create;
    aClass. YourProcedure ('参数'); 
  end;

方法二、不需生成tlb文件,仿照调用Excel的方式。代码如下:
 var aClass: Variant;
begin
  aClass:= CreateOleObject('TestDll.TestClass');
  aClass.YourProcedure ('参数');
end;

vs2015 c#封装com文件

Properties\AssemblyInfo.cs

[assembly: ComVisible(true)];//从fasel改为true

也可以在工程里改

右键单击工程--》属性--》应用程序--》点击程序集信息--》最下面的复选框(使程序集Com可见)

TlbExp  路径/TestClass.dll 得到一个TestClass.tlb 文件

regasm MyEnCrypt.dll /tlb:MyEncrypt.tlb

TlbExp  TestClass.dll

查找delphi生成的TLb文件里的

Co*** = class
    class function Create: **ComInterface;
    class function CreateRemote(const MachineName: string): **ComInterface;
  end;

imcom:IMComInterface_TLB._CIMComInterface;

imcom := IMComInterface_TLB.CoCIMComInterface.Create;

C++

IMComInterface_TLB.cpp

const GUID CLSID_CIMComInterface =

_CIMComInterface *imcom = CoCIMComInterface::Create();

不用看TLB.h文件了。根据TLB.cpp就可以知道名称进行定义和create了。

IMComInterface_TLB.h

_CIMComInterface *imcom = CoCIMComInterface::Create();

typedef TCoClassCreatorT<TCOM_CIMComInterface, _CIMComInterface, &CLSID_CIMComInterface, &IID__CIMComInterface> CoCIMComInterface;

{F6240F08-CBDB-3E72-87E9-7A9FBD39B554}

IMComInterface.CIMComInterface

.net DLL 注册 regasm delphi调用的更多相关文章

  1. CommMonitor8.0 串口过滤驱动 SDK DLL版本 C#/Delphi调用DEMO

    CommMonitor8.0 SDK DLL 版本,此版本是直接调用DLL. Delphi调用定义: constCommMOnitor8x = ‘CommMOnitor8x.dll’; typeTOn ...

  2. Delphi 调用C# DLL(包含委托)

    例子 C# Dll: using System; using System.Collections.Generic; using System.Text; using System.Diagnosti ...

  3. Delphi调用C# 编写dll动态库

    Delphi调用C# 编写dll动态库 编写C#dll的方法都一样,首先在vs2005中创建一个“类库”项目WZPayDll, using System.Runtime.InteropServices ...

  4. Delphi 调用C# 编写的DLL方法

    近来,因工作需要,必须解决Delphi写的主程序调用C#写的dll的问题.在网上一番搜索,又经过种种试验,最终证明有以下两种方法可行:    编写C#dll的方法都一样,首先在vs2005中创建一个“ ...

  5. Delphi XE3写DLL,用Delphi7调用,报错!

    http://bbs.csdn.net/topics/390870532 用delphi xe3写的DLL,delphi7调用,参数都是PAnsiChar,DLL里的函数接收delphi7传的入参,没 ...

  6. 发现个delphi调用vc写的Dll中包括pchar參数报错奇怪现象

    发现个delphi调用vc写的Dll中包括pchar參数奇怪现象 procedure中的第一行语句不能直接调用DLL的函数,否则会执行报错,在之前随意加上条语句就不报错了奇怪! vc的DLL源代码地址 ...

  7. Delphi 调用C/C++的Dll(stdcall关键字, 会导致函数名分裂. 此时函数名变成_stdadd@8)

    delphi调用C++写的Dll, 当然这个Dll要求是非MFC的Dll, 这样子才能被delphi调用. 根据C++定义函数的情况, Delphi有不同的相对应的处理方法.1. 声明中不加__std ...

  8. Delphi - Windows系统下,Delphi调用API函数和7z.dll动态库,自动把文件压缩成.tar.gz格式的文件

    项目背景 应欧美客户需求,需要将文件压缩成.tar.gz格式的文件,并上传给客户端SFTP服务器. 你懂的,7-Zip软件的显著特点是文件越大压缩比越高,在Linux系统上相当于我们Windows系统 ...

  9. 【转】Delphi调用webservice总结

    原文:http://www.cnblogs.com/zhangzhifeng/archive/2013/08/15/3259084.html Delphi调用C#写的webservice 用delph ...

随机推荐

  1. Android keystore相关

    一.生成keystorekeytool -genkey -alias test.keystore -keyalg RSA -validity -keystore test.keystore 二.查看 ...

  2. Ubuntu 14.10 下Hadoop代码编译问题总结

    问题1  protoc (compile-protoc) on project hadoop-common: org.apache.maven.plugin.MojoExecutionExceptio ...

  3. “Hello world! ”

    12.1第一篇笔记 Python  方向:1.web全栈    2.人工智能 (java基础)   3. 爬虫开发   4.数据分析(金融) 6个月学习:需完成8-10万行代码的目标 下一步学习方向 ...

  4. .NET使用HttpRuntime.Cache设置程序定时缓存

    第一步:判断读取缓存数据 #region 缓存读取 if (HttpRuntime.Cache["App"] != null) { return HttpRuntime.Cache ...

  5. mongodb 的一些基本命令以及 导入、导出,待更新

    基本命令参考: https://blog.csdn.net/cckevincyh/article/details/78702674 导入导出参考:https://blog.csdn.net/djy37 ...

  6. [UE4]宏

    宏和函数的区别 “展开”就是直接将宏代码直接复制粘贴替换到所有使用当前宏的地方.这个跟C++中的宏是一样的. 1.宏可以有多个入口,多个出口,函数只有一个入口,一个出口 2.宏的参数可以使用“Exec ...

  7. [UE4]判断UI动画播放方向

    使用一个变量来记录播放的方向.

  8. sqlserver 模糊查询,连表,聚合函数,分组

    use StudentManageDB go select StudentName,StudentAddress from Students where StudentAddress like '天津 ...

  9. Postgres安装

    yum install zlib-devel gcc make #创建用户和组groupadd postgresuseradd -g postgres postgres mkdir -p /usr/l ...

  10. centos7安装zookeeper3.4.12集群

    zookeeper的三要素: 1.一致,能够保证数据的一致性 2.有头,始终有一个leader,node/2+1个节点有效,就能正常工作 3.数据树,树状结构且每个树必须有数据 1. 环境准备 操作系 ...