需要几个在c#调用dll的网址

来源:百度知道 编辑:UC知道 时间:2024/06/29 22:18:38
我初学c#,现在尝试调用dll
有什么好的网址可以贴出来,就类似这个网站http://msdn.microsoft.com/zh-cn/library/3707x96z(VS.80).aspx
我还不太会调用简单的dll

采用如下的方式:

DllImport("dll名字.dll")] //dll 需放置在和EXE同目录或者系统环境变量目录下
public static extern 函数返回类型 函数名(参数类型 参数名);

举例如下:

DllImport("mbt2005.dll")]
public static extern bool GetErrorStatus(ref int error_code, StringBuilder error_string);

private void button1_Click(object sender, EventArgs e)
{
int error_code = -1;
StringBuilder error_string = new StringBuilder(255);
bool flag = GetErrorStatus(ref error_code, error_string);
}

在项目中引用该DLL

接着在后台代码中添加该DLL中各类的命名空间

最后DLL中类就能为你所用了

MSDN上已经说的很明白了,看不懂?