Pavel Minaev
8/11/2008 6:08:00 AM
On Aug 11, 7:01 am, Kerem Gümrükcü <kareem...@hotmail.com> wrote:
> Hi,
>
> i get a "Wrong Parameter" from Marshal.GetLastWin32Error() on using this:
>
> [StructLayout(LayoutKind.Sequential)]
> public class SP_DEVINFO_DATA
> {
> public int cbSize;
> public Guid classGuid;
> public int devInst;
> public ulong reserved;
Why do you use "ulong" for "reserved" here? It's ULONG_PTR in the API
declaration, and, unless you're on x64, this is equivalent to
"unsigned long", which is uint in C#, not ulong. Though in this case,
to remain 64-bit clean, it's best to just use UIntPtr.
Anyway, assuming you used Marshal.SizeOf() to set cbSize, you've got a
wrong size in it with your declaration - perhaps it is the reason.