Help with PInvoke of a struct

M

Michael

Hi all,

I believe I'm not PInvoking this struct correctly.
Here's the API definition.

typedef struct _SP_DRVINFO_DATA {
DWORD cbSize;
DWORD DriverType;
ULONG_PTR Reserved;
TCHAR Description[LINE_LEN];
TCHAR MfgName[LINE_LEN];
TCHAR ProviderName[LINE_LEN];
FILETIME DriverDate;
DWORDLONG DriverVersion;
} SP_DRVINFOR_DATA, *PSP_DRVINFO_DATA;

Here's my latest implementation attempt:

[StructLayout(LayoutKind.Sequential)]
public struct SP_DRVINFO_DATA
{
public System.UInt32 cbSize;
public System.UInt32 DriverType;
public System.UIntPtr Reserved;

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public System.String Description;

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public System.String MfgName;

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public System.String ProviderName;

public System.Runtime.InteropServices.ComTypes.FILETIME DriverDate;
public System.UInt64 DriverVersion;
}


Thanks, all

-MH
 
M

Mattias Sjögren

Here's my latest implementation attempt:

Looks correct to me (assuming LINE_LEN = 256).


Mattias
 
M

Michael

* ***>Here's my latest implementation attempt:
**
** Looks correct to me (assuming LINE_LEN = 256).
**
**
** Mattias
**
** --
** Mattias Sjögren [C# MVP] mattias @ mvps.org
** http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
** Please reply only to the newsgroup.
*
* Thanks Mattias,
*
* I believe LINE_LEN is 256 :). It's been a chore tracking down this latest
* PInvoke problem :(.
*
* -MH
*
*

I think my main hang up is w/ the TCHAR arrays... I'll start a separate, new
thread for that in this ng.

-MH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top