今回は、なぜ私はそれがなぜ存在するかを理解しようとしているエラーがあります。エラーは無視できますが、なぜそれが第1位に存在するのかを知りたいのですが。SetupDiGetDeviceInterfaceDetail説明できないエラー
result = SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref anInterface, IntPtr.Zero, 0, ref buffersize, IntPtr.Zero);
if (!result)
{
int errCode = Marshal.GetLastWin32Error();
errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
statusLabel.Text += "\n(1)SetupDiGetDeviceInterfaceDetail Error: " + errCode + " => " + errorMessage + ".";
//break;
}
これは単に関数の2番目の呼び出しにBUFFERSIZE変数を設定するためのものであり、この関数の第一の呼び出しです。 122 =>システムコールに渡されたデータ領域が小さすぎます。 エラーメッセージから判断すると、2番目のパラメータ(ref anInterface)と何か関係があり、2番目のパスでこれを無視することができます。しかし、エラーはまだ存在し、なぜ私が「後ろ」の場所に噛み付くのが戻ってくるのか知りたいのですが。 問題のパラメータが宣言され、このように定義されている:私は、MSDNの記事を離れて選んだと私の知る限り、ここでのコードと間違って何もない
[StructLayout(LayoutKind.Sequential)] // defined here
public struct SP_DEVICE_INTERFACE_DATA
{
public uint cbSize;
public Guid InterfaceClassGuid;
public uint Flags;
public IntPtr Reserved;
}
anInterface = new SP_DEVICE_INTERFACE_DATA(); // declared here
anInterface.cbSize = (uint)Marshal.SizeOf(anInterface);
anInterface.InterfaceClassGuid = Guid.Empty;
anInterface.Reserved = IntPtr.Zero;
anInterface.Flags = 0;
。