勾选Enable running application out of the browser及其Require elevated trust when running in-browser
勾选Require elevated trust when running in-browser
注2:win32 dll文件编译后放在\windows\system32或\windows\system目录下,win7 x64的系统放在后者。
///<summary>
/// 弹出窗口
///</summary>
///<param name="h">弹出窗口的父窗口,在这里没有,所以为0</param>
///<param name="message">需要显示的消息</param>
///<param name="title">窗口的标题</param>
///<param name="type">窗口的类型 0为确定按钮,1为确定、取消双按钮</param>
///<returns></returns>
[DllImport("user32.dll",EntryPoint = "MessageBoxA")]
public static extern int MsgBox(int h,string message,string title,int type);
///<summary>
/// 获取到DLL的值
///</summary>
///<param name="Anumber">数字A</param>
///<param name="Bnumber">数字B</param>
///<returns></returns>
[DllImport("IlasLinkDll.dll",CharSet = CharSet.Ansi,EntryPoint = "GetNum",ExactSpelling = false)]
public static extern double GetNum(double Anumber,double Bnumber);
public SLDlltest() { InitializeComponent(); MsgBox(0,"调用IlasLinkDll.dll获得的结果:" + GetNum(500.0,23.0).ToString(),"提示信息",1); MsgBox(0,"这是调用User32.dll弹出的窗口",1); }