Replies: 1 comment
-
#if CS
native {
using System;
using System.Runtime.InteropServices;
class PInvokeHelper
{
// Import user32.dll (containing the function we need) and define
// the method corresponding to the native function.
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int MessageBox(IntPtr hWnd, string lpText, string lpCaption, uint uType);
}
}
#endif
public class Program
{
public static void Main()
{
#if CS
native {
PInvokeHelper.MessageBox(IntPtr.Zero, "Command-line message box", "Attention!", 0);
}
#endif
}
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Can I treat the code inside
native
blocks just like normal C# code in a C# source file?Beta Was this translation helpful? Give feedback.
All reactions