<DllImport("kernel32.dll", SetLastError := True)> _
Private Function Beep _
(ByVal dwFreq As Integer, ByVal dwDuration As Integer) As Boolean
End Function
private static void Main()
{
bool ret = Beep(0x8000, 500);
if (ret == false)
{
// エラーが発生 int errCode = Marshal.GetLastWin32Error();
Console.WriteLine("Win32エラー・コード:" +
String.Format("{0:X8}", errCode));
// 出力結果:
// Win32エラー・コード:00000057
}
}
}
Imports System.Runtime.InteropServices
Module BeepProgram
<DllImport("kernel32.dll", SetLastError:=True)> _ Private Function Beep _ (ByVal dwFreq As Integer, ByVal dwDuration As Integer) As Boolean End Function
Sub Main()
Dim ret As Boolean = Beep(&H8000, 500)
If ret = False Then
' エラーが発生 Dim errCode As Integer = Marshal.GetLastWin32Error()
Console.WriteLine("Win32エラー・コード:" & _
String.Format("{0:X8}", errCode))