📄 messagebox.cpp
字号:
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
__gc struct S
{
[DllImport("user32", CharSet=CharSet::Ansi)] //通过P/Invoke导入
static int MessageBox(void* hWnd,
String* pText,
String* pCaption,
unsigned int uType);
};
__delegate int MyMessageBox (void* hWnd, // 代理的声明
String * pText,
String * pCaption,
unsigned int uType);
int main()
{
MyMessageBox* myb = new MyMessageBox(0, &S::MessageBox); // 实例化
String * pText = S"Hello, World!";
String * pCaption = S"Pinvoke Test";
myb(0, pText, pCaption, 0); // 通过代理myb调用MessageBox调用Windows API函数
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -