⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 messagebox.cpp

📁 Vc.Net入门与提高源码
💻 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 + -