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

Null terminated strings...

I need to call a Win32 function that returns a set of string values. Each
value is terminated by a null and the last value is terminated by two nulls.
How do I code for this in C#?

The call is:
[DllImport("Kernel32.dll")]
internal static extern uint QueryDosDevice(string lpDeviceName,
string lpTargetPath,uint ucchMax);

According to the help, if lpDeviceName is NULL, the function retrieves a
list of all existing MS-DOS device names. Each null-terminated string stored
into the buffer is the name of an existing MS-DOS device.

Do I need to retrieve the buffer as a char array and process it myself? Can
I retrieve it as a string and use Split to split it in to an array?

Thanks
Steve
Jul 3 '06 #1
2 3070
"Steve Barnett" <no****@nodomain.comwrote in
news:#Y**************@TK2MSFTNGP02.phx.gbl:
I need to call a Win32 function that returns a set of string values.
Each value is terminated by a null and the last value is terminated by
two nulls. How do I code for this in C#?
PInvoke.net has some sample code that might help...

http://www.pinvoke.net/default.aspx/...QueryDosDevice

(use IE, not FireFox).

-mdb
Jul 3 '06 #2
Thanks, that'll do nicely.
Steve

"Michael Bray" <mbray@makeDIntoDot_ctiusaDcomwrote in message
news:Xn****************************@207.46.248.16. ..
"Steve Barnett" <no****@nodomain.comwrote in
news:#Y**************@TK2MSFTNGP02.phx.gbl:
>I need to call a Win32 function that returns a set of string values.
Each value is terminated by a null and the last value is terminated by
two nulls. How do I code for this in C#?

PInvoke.net has some sample code that might help...

http://www.pinvoke.net/default.aspx/...QueryDosDevice

(use IE, not FireFox).

-mdb

Jul 3 '06 #3

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

Similar topics

4
by: Barry | last post by:
Hi all! I support a rather large production EDI application with a number of C programs, and I ran across a very interesting problem. I have some code that used to work just fine for years, and...
15
by: ehabaziz2001 | last post by:
Hi, Till now I do not understand how the null character automatically added to the end of the string and it is not an element of the string array . All books said the null character (\0) added...
1
by: Peter Gloor | last post by:
Hello NG, I have a mirror.dll written in C I would like to access from a C# console application. However, I dont't know how to to it. The dll is fairly well documented and I have access to the...
3
by: Michel Racicot | last post by:
I need to read a null terminated ASCII string from a FileStream. How can I do that? I know that with FileStream.ReadByte, I can read until I get a byte == 0 but how can I convert a single byte to...
2
by: Ithaqua | last post by:
How do you create them? -- Cheers Ithaqua
3
by: Carlo Stonebanks | last post by:
I need to read a binary file which has mixed data types embedded in it. Fixed length strings, 16-bit integers and zero (null) terminated ASCII strings. (akak ASCIIZ) The first two types are no...
21
by: Michael | last post by:
Hi All, I've received (via UDP) a null terminated string and need to convert it into a Python string. Can anyone tell me how this is done? If it helps, I know the number of characters in the...
12
by: semut | last post by:
Given that the string is of null terminated type. What could be the possible causes (by experience) the string to have no null terminated and cause buffer overflow later. I know it is quite broad,...
7
by: semut | last post by:
Given that the string is of null-terminated type. What could be the possible causes (by experience) the string to have no null character (\0) and cause buffer overflow later. I know it is quite...
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:
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.