473,394 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help with PInvoke of a struct

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
Sep 19 '06 #1
3 1690
>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.
Sep 20 '06 #2
*"Mattias Sjögren" <ma********************@mvps.orgwrote in message
news:up**************@TK2MSFTNGP03.phx.gbl...
**>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
Sep 20 '06 #3
*"Michael" <mh***@domain.comwrote in message
news:Ow*************@TK2MSFTNGP06.phx.gbl...
**"Mattias Sjögren" <ma********************@mvps.orgwrote in message
* news:up**************@TK2MSFTNGP03.phx.gbl...
***>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
Sep 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Carlos Guzmán Álvarez | last post by:
Hello: I'm trying to execute a function of a unmanaged dll using PInvoke, i have definied the function as: public static extern int isc_dsql_prepare( int status_vector, ref int...
11
by: Frank Rizzo | last post by:
Hello, My c# based windows service takes a while to dispose. I have to release bunch of resources all over the place and unfortunately it can take 20-40 seconds before I can cleanly exit. ...
4
by: simran | last post by:
Hi !!1 I am making on application to contl the volume similar to sndvol32.exe . I got the some code in VB6. I am working in VB.NET so i ma trying to convert that ocde in VB.NET In VB6 i have...
3
by: Michael | last post by:
Hi all, I'm having trouble PInvoking a TCHAR within a struct. I'll paste the specific struct's API definition below. I've tried so many numerous variations. The main Win32 error I get is...
3
by: angshuman.agarwal | last post by:
Structure in C DLL ---------------------------- typedef struct IrData { unsigned short uiFormat; unsigned short uiLength; unsigned char* pchData; } tagIrData; Function in C DLL
7
by: Rymfax | last post by:
I would really appreciate it if someone could help me figure out what I'm doing wrong trying to PInvoke SetupDiEnumDriverInfo. All the other PInvokes i've done up to this point work fine. Whenver...
0
by: gregarican | last post by:
A couple of days ago I was debating about whether to use C++/CLI or C# 2005's PInvoke in order to tie in my VS 2005 app with a legacy csta32.dll file. So far I have tried to call one method out of...
1
by: eastlands | last post by:
I need to use an unmanaged c++ dll which uses structs that contain callbacks and also functions. I have included the appropriate c++ definitials and my c# translations below. I first defined the...
5
by: =?Utf-8?B?SmVzc2ljYQ==?= | last post by:
Hello, I have a pInvoke question. This is the C function that is exported from one of the C dll, extern __declspec(dllexport) IM_RET_CODE ST_import (IM_MODE mode, char *filename,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.