Delphi調用C# 編寫dll動態庫
編寫C#dll的方法都一樣,首先在vs2005中創建一個“類庫”項目WZPayDll,
using System.Runtime.InteropServices;
namespace WZPayDll
{
public interface IWZPay
{
void Pay(stirng url,string payType);
}
[ClassInterface(ClassInterfaceType.None)]
public class WZPay:IWZPay
{
public void YourProcedure (stirng url,string payType);
{
//something is here,myself code
}
}
}
完成之后,選中該項目右擊,選擇屬性,然后在應用程序中選擇程序集信息如圖:

將圖中紅框的地方選中,然后

然后在生成欄目中選中紅框的為com互操作注冊
接下來需要注冊dll,
使用regasm.exe注冊即可,為了方便注冊,我們需要組一個批處理,要雙擊即可,
@echo off start regasm2.0_x86.exe WZPayDll.dll exit
見上述代碼拷貝到文本文件中,然后保存為.bat的批出來,將regasm.exe文件和你的動態庫,還有批處理放在同一個文件夾下,然后雙擊批出來接口注冊完畢
