1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
using System; using System.Windows.Forms; using System.Runtime.InteropServices; namespace WindowsFormsApplication1 { public partial class Form1 : Form { //https://msdn.microsoft.com/ja-jp/library/cc428923.aspx //関数の存在するdllを指定。 [DllImport("kernel32.dll")] //関数の実体が外部にあることを示す。 extern static bool Beep(uint dwFreq, uint dwDuration); public Form1() { InitializeComponent(); button1.Click += new EventHandler((object sender, EventArgs e) => { Beep(262, 500); }); } } } /* Win32API / .NET HANDLE (void *) System.IntPtr BYTE (unsigned char) byte (System.Byte) SHORT (short) short (System.Int16) WORD (unsigned short) ushort (System.UInt16) INT (int) int (System.Int32) LONG (long) UINT (unsigned int) uint (System.UInt32) DWORD, ULONG (unsigned long) BOOL (long) bool (System.Boolean) CHAR (char) char (System.Char) LPSTR (char *) System.Text.StringBuilder LPWSTR (wchar_t *) LPCSTR (const char *) string (System.String) LPCWSTR (const wchar_t *) FLOAT (float) float (System.Single) DOUBLE (double) double (System.Double) */ |