例子:
using System;
using System.Runtime.InteropServices;
namespace Anytao.net
{
class MainClass
{
[DllImport("User32.dll")]
public static extern int MessageBox(int hParent, string msg, string caption, int type);
static int Main()
{
return MessageBox(0, "How to use attribute in .NET", "Anytao_net", 0);
}
}
}
你的错误有两个可能,
一是,vb生成的dll组件有问题,所以调用失败
二是,已经成功生成DLL:CheckName.dll
[DllImport("工程1.dll")]
调用的组件书写不正确,应该是[DllImport("CheckName.dll")]
你可以用ImportDll在程序声明一下你的DLL,然后再使用其中的函数。使用时可用当做内部函数使用了!
C#和VB的dll是通用的,直接在工程的引用里添加,然后在文件头using一下就可以了
keyi
[ImportDll]