【发布时间】:2014-02-06 16:30:15
【问题描述】:
我正在尝试进行 PInvoke 调用以注册任何 USB 设备连接通知。
[DllImport("user32.dll", SetLastError = true)]
protected static extern IntPtr RegisterDeviceNotification(IntPtr hwnd, DeviceBroadcastInterface oInterface, uint nFlags);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public class DeviceBroadcastInterface
{
public int Size;
public int DeviceType;
public int Reserved;
public Guid ClassGuid;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string Name;
}
通常需要从 Winforms 应用程序中的 OnHandleCreated 获得的窗口句柄才能进行此类 PInvoke 调用。有没有办法在silverlight 5中获取用户控件的句柄?
【问题讨论】:
-
是什么让您决定使用
Pack=1?你确定这是正确的吗?
标签: c# .net silverlight user-controls pinvoke