PDA

View Full Version : سوال: یک مثال در رابطه با کلمه extrn



alexmcse
پنج شنبه 21 اردیبهشت 1391, 16:16 عصر
سلام
یک مثال در رابطه با کلمه کلیدی extrn در c# بزنید و توضیح دهید
تشکر
:تشویق:

cpppro
پنج شنبه 21 اردیبهشت 1391, 19:32 عصر
سلام
از این کلمه ی کلیدی برای فراخوانی متدها ، ساختار ها و callback ها استفاده میشه.البته اونهای که بصورت native و غیر مدیریت شده نوشته شدن.مثل user32.dll و ...
P/Invoke, short for Platform Invocation Services

using System;
using System.Runtime.InteropServices;
class MsgBoxTest
{
[DllImport("user32.dll")]
static extern int MessageBox (IntPtr hWnd, string text, string caption,
int type);
public static void Main()
{
MessageBox (IntPtr.Zero,
"Please do not press this again.", "Attention", 0);
}
}