473,378 Members | 1,360 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,378 software developers and data experts.

convert to vb.net

hi i got the following from c, how do i convert into vb.net?

typedef struct _SP_DEVICE_INTERFACE_DETAIL_DATA {
DWORD cbSize;
TCHAR DevicePath[ANYSIZE_ARRAY];
} SP_DEVICE_INTERFACE_DETAIL_DATA, *PSP_DEVICE_INTERFACE_DETAIL_DATA;
Nov 21 '05 #1
8 1662
Try:

Structure _SP_DEVICE_INTERFACE_DETAIL_DATA

Public cbSize As Integer
Public DevicePath(ANYSIZE_ARRAY - 1) As Char

End Structure
"newbie" <ne****@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
hi i got the following from c, how do i convert into vb.net?

typedef struct _SP_DEVICE_INTERFACE_DETAIL_DATA {
DWORD cbSize;
TCHAR DevicePath[ANYSIZE_ARRAY];
} SP_DEVICE_INTERFACE_DETAIL_DATA, *PSP_DEVICE_INTERFACE_DETAIL_DATA;

Nov 21 '05 #2
Staphany,

"Stephany Young" <noone@localhost> schrieb:
Structure _SP_DEVICE_INTERFACE_DETAIL_DATA
[...]
Public DevicePath(ANYSIZE_ARRAY - 1) As Char


The line above won't work...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #3
In that case try:

Public Class _SP_DEVICE_INTERFACE_DETAIL_DATA

Private Const ANYSIZE_ARRAY As Integer = 1024

Public cbSize As Integer
Public DevicePath(ANYSIZE_ARRAY - 1) As Char

End Class
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Staphany,

"Stephany Young" <noone@localhost> schrieb:
Structure _SP_DEVICE_INTERFACE_DETAIL_DATA
[...]
Public DevicePath(ANYSIZE_ARRAY - 1) As Char


The line above won't work...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4
"Stephany Young" <noone@localhost> schrieb:
Public Class _SP_DEVICE_INTERFACE_DETAIL_DATA

Private Const ANYSIZE_ARRAY As Integer = 1024

Public cbSize As Integer
Public DevicePath(ANYSIZE_ARRAY - 1) As Char

End Class


This won't work too in a p/invoke scenario because the function is expecting
a value type (structure).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
I didn't notice the OP asking about a p/invoke scenario.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
"Stephany Young" <noone@localhost> schrieb:
Public Class _SP_DEVICE_INTERFACE_DETAIL_DATA

Private Const ANYSIZE_ARRAY As Integer = 1024

Public cbSize As Integer
Public DevicePath(ANYSIZE_ARRAY - 1) As Char

End Class


This won't work too in a p/invoke scenario because the function is
expecting a value type (structure).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6
"Stephany Young" <noone@localhost> schrieb:
I didn't notice the OP asking about a p/invoke scenario.


Oh, I thought that's self-evident :-). Otherwise I don't understand why the
OP is posting the question at all.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #7
Several issues exist here:
1) The Layout of the Structure needs to be defined
2) The Windows32 API expects a C-String -- this is what the StringBuilder
class is ideal for
3) The cbSize member needs to pass the size of the structure
4) Int32 should (probably) be used in lieu of Integer (eventhough they
currently mean the same thing -- with the advent of Win64, I expect that the
definition of integer will eventually widen).

<StructLayout(LayoutKind.Explicit)> Structure
SP_DEVICE_INTERFACE_DETAIL_DATA

<FieldOffset(0)> Public cbSize As Int32
<FieldOffset(4)> Public DevicePath As StringBuilder(ANYSIZE_ARRAY - 1)

End Structure
Nov 21 '05 #8
"stand__sure" <st*********@hotmail.com> schrieb:
4) Int32 should (probably) be used in lieu of Integer (eventhough they
currently mean the same thing -- with the advent of Win64, I expect that
the
definition of integer will eventually widen).


I prefer 'Int32' when dealing with unmanaged code too, however, 'Integer'
will remain an alias for 'Int32' in 64-bit versions of .NET.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #9

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

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
1
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
7
by: whatluo | last post by:
Hi, all I'm now working on a program which will convert dec number to hex and oct and bin respectively, I've checked the clc but with no luck, so can anybody give me a hit how to make this done...
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
4
by: Edwin Knoppert | last post by:
In my code i use the text from a textbox and convert it to a double value. I was using Convert.ToDouble() but i'm used to convert comma to dot. This way i can assure the text is correct. However...
1
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
6
by: Ken Fine | last post by:
This is a basic question. What is the difference between casting and using the Convert.ToXXX methods, from the standpoint of the compiler, in terms of performance, and in other ways? e.g. ...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.