我一把动态库的方法定义在一个类中,例子如下:
using System;
using System.Runtime.InteropServices;
namespace mynamespace
{
/// <summary>
/// MyClass 的摘要说明。
/// </summary>
public class MyClass
{
public CBJClass()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
[ DllImport( "your.dll" )]
public static extern int closeport();//动态库的函数原型
[ DllImport( "your.dll" )]
public static extern int closeport();//动态库的函数原型
........................................
}
}
using System;
using System.Runtime.InteropServices;
namespace mynamespace
{
/// <summary>
/// MyClass 的摘要说明。
/// </summary>
public class MyClass
{
public CBJClass()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
[ DllImport( "your.dll" )]
public static extern int closeport();//动态库的函数原型
[ DllImport( "your.dll" )]
public static extern int closeport();//动态库的函数原型
........................................
}
}
http://expert.csdn.net/Expert/topic/2378/2378349.xml?temp=6.312197E-02
{[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
public extern static long DeleteFile(String lpFileName);}