class1.cs
来自「Professional C# 2nd Edition」· CS 代码 · 共 27 行
CS
27 行
using System;
using System.Runtime.InteropServices;
namespace Wrox.ProCSharp.ComInterop.UnmanagedExample
{
class PInvokeExample
{
//Declare the external, unmanaged function.
//[DllImport ("user32.dll")]
// Uncomment the next line and comment the above line to create an alias
[DllImport("user32.dll",EntryPoint="MessageBoxA")]
public static extern int ErrorMessage (int Modal,
string Message,
string Caption,
int Options);
//Program starts here.
public static void Main (string[] args)
{
//Invoke the unmanaged function using PInvoke.
//MessageBoxA(0,"PInvoke worked!","PInvoke Example",0);
// Uncomment the next line, and comment the above line to use the alias
ErrorMessage(0, "PInvoke worked with alias name!", "PInvoke Example",0);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?