473,804 Members | 2,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_DAT A {
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_DAT A, *PSP_DRVINFO_DA TA;

Here's my latest implementation attempt:

[StructLayout(La youtKind.Sequen tial)]
public struct SP_DRVINFO_DATA
{
public System.UInt32 cbSize;
public System.UInt32 DriverType;
public System.UIntPtr Reserved;

[MarshalAs(Unman agedType.ByValT Str, SizeConst = 256)]
public System.String Description;

[MarshalAs(Unman agedType.ByValT Str, SizeConst = 256)]
public System.String MfgName;

[MarshalAs(Unman agedType.ByValT Str, SizeConst = 256)]
public System.String ProviderName;

public System.Runtime. InteropServices .ComTypes.FILET IME DriverDate;
public System.UInt64 DriverVersion;
}
Thanks, all

-MH
Sep 19 '06 #1
3 1709
>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.o rgwrote in message
news:up******** ******@TK2MSFTN GP03.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.c omwrote in message
news:Ow******** *****@TK2MSFTNG P06.phx.gbl...
**"Mattias Sjögren" <ma************ ********@mvps.o rgwrote in message
* news:up******** ******@TK2MSFTN GP03.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
2523
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 trans_handle, ref int stmt_handle,
11
14980
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. Every now and then, when I stop the service from the Services applet, it will timeout and bring up an error message saying that the service isn't responding.
4
2817
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 these two functions in which they have used " As Any" I know that in VB.NET this is not supported but i am not able to find wht will i use insted of that in the declarations part.
3
5745
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 0x3f0 / 515L which amounts to ERROR_NO_TOKEN. Every single instance of this in the past was due to mistakes I made while within PInvoked structs. Is anybody able to point me to documentation or just tell me outright how to
3
4358
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
7909
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 I PInvoke SetupDiEnumDriverInfo though, I get winerror.h code of 1784L, which basically says it doesn't like my buffer, which I assume is the structure. Below is my PInvoke, my structure and a sample of my code. Please, please PLEASE help me!
0
339
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 the csta32.dll and wind up with the PInvoke stack imbalance error. Here are the data types my C# mappings are based on: typedef unsigned long ACSHandle_t; typedef enum { APP_GEN_ID, /* application will provide invokeIDs; any 4-byte value
1
6665
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 parameters as c# structs, but when I tried the call (to RtcInitialize) I got the following error: MarshalDirectiveException Method's type signature is not PInvoke compatible. I then changed the structs to classes but now I get the following...
5
1798
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, ST_TYPES **st_type, ST_ERROR **st_error);
0
9576
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5516
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.