DllImport会按照顺序自动去寻找的地方:
1、exe所在目录
2、System32目录
3、环境变量目录
所以只需要你把引用的DLL 拷贝到这三个目录下 就可以不用写路径了

Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace AtuoIdTest
{
public partial class Form2 : Form
{
[DllImport("user32.dll")]
public static extern int MessageBoxA(int hwnd, string message,
string caption, int type);
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int result = MessageBoxA(0, "Hello World", "PInvoke Test", 0);
}
}
}