先通过vs2017 编写c#代码 主要主要程序集com可见属性开启 注意点看下面代码以及图片,附上c#和e代码
demo.zip
(189.14 KB, 下载次数: 159)
这个是易语言调用的代码
窗口程序集名 | 保 留 | 保 留 | 备 注 | 窗口程序集_启动窗口 | | | | 变量名 | 类 型 | 数组 | 备 注 | RegAsm目录 | 文本型 | |
RegAsm目录 = 取文本zc项 ( #本地机器, “SOFTWARE\Microsoft\.NETFramework\InstallRoot”, )RegAsm目录 = RegAsm目录 + “v4.0.30319\RegAsm.exe”调试输出 (RegAsm目录 ) 如果 (文件是否存在 (RegAsm目录 ))  dll目录 = 取特定目录 ( #我的文档 ) 调试输出 (dll目录 + “Get.dll”) 写到文件 (dll目录 + “Get.dll”, #图片1 ) 运行 (RegAsm目录 + “ ” + dll目录 + “Get.dll”, 假, #隐藏窗口 ) 运行 (RegAsm目录 + “ ” + dll目录 + “Get.dll /codebase”, 假, #隐藏窗口 ) 信息框 (“系统环境不正确,确认是否安装了.net4.0”, 0, ) 调试输出 (取随机字符串 ()) 如果 (object. 创建 (“Get.Rand”, 取运行目录 () + “\Get.dll”)) 返回 (object. 通用方法 (“Getrand”, ). 取文本 ()) 返回 (“创建对象失败!检查DLL是否在目录下!”)
这个是c# dll代码
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Runtime.InteropServices;
- namespace Get
- {
- public interface IRand
- {
- string Getrand();
- }
- [ClassInterface(ClassInterfaceType.None)]
- public class Rand:IRand
- {
- public String Getrand()
- {
- int v9 = 2;
- int v2 = new Random().Next(9) + 8;
- String v6 = "";
- Random v4 = new Random();
- int v1;
- for (v1 = 0; v1 < v2; ++v1)
- {
- String v0 = v4.Next(v9) % 2 == 0 ? "char" : "num";
- if ("char".Equals(v0))
- {
- int v5 = v4.Next(v9) % 2 == 0 ? 65 : 97;
- v6 = v6 + (((char)(v4.Next(26) + v5)));
- }
- else
- {
- if (!"num".Equals(v0))
- {
- v6 = v6 + v4.Next(10).ToString();
- }
- }
- }
- return v6;
- }
- }
- }
复制代码
|