By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,931 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,931 IT Pros & Developers. It's quick & easy.

StringBuilder termination char

P: n/a
Hi,

I'm trying to use stringbuilder to collect a list of strings. (as suggested
by Claes Bergefall)

Declare Auto Function CM_Get_Device_ID_List Lib "cfgmgr32.dll" (ByVal
pszFilter As String, ByVal ptChar As System.Text.StringBuilder, ByVal
bufferLen As Integer, ByVal ulFlags As Integer) As Integer

Dim sb As New StringBuilder(len + 1)
CM_Get_Device_ID_List(filter, sb, sb.Capacity, flags)

But this only givs me the first string and I need them all..
Is it possible to configure the StringBuilder to use a double NULL value as
string termination.
or are there another way of retriving the list?

BTW does anyone know why there are no pointers in VB, I didn't find them to
be a problem in C? I liked them.

Henning



Apr 8 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
What makes you think that you are only getting the first string?

Are you perchance doing something a'kin to?:

Console.Writeline(sb.ToString)

If so, try:

Console.Writeline("*{0}*", sb.ToString)

and see what happens.

I suspect that you are, in fact, getting all the strings but the 2nd and
subsequent strings are being 'hidden' by the first null character delimiter.

Try stripping the trailing nulls and then splitting the string into an array
of strings and you just might be pleasantly surprised:

Dim _s As String = sb.ToString.Trim

Dim _ss() As String = _s.Split(ControlChars.NullChar)

For Each _s in _ss
Console.Writeline(_s)
Next

"Henning M" <he*****@fys.ku.dk> wrote in message
news:a0***************************@news.arrownet.d k...
Hi,

I'm trying to use stringbuilder to collect a list of strings. (as
suggested by Claes Bergefall)

Declare Auto Function CM_Get_Device_ID_List Lib "cfgmgr32.dll" (ByVal
pszFilter As String, ByVal ptChar As System.Text.StringBuilder, ByVal
bufferLen As Integer, ByVal ulFlags As Integer) As Integer

Dim sb As New StringBuilder(len + 1)
CM_Get_Device_ID_List(filter, sb, sb.Capacity, flags)

But this only givs me the first string and I need them all..
Is it possible to configure the StringBuilder to use a double NULL value
as string termination.
or are there another way of retriving the list?

BTW does anyone know why there are no pointers in VB, I didn't find them
to be a problem in C? I liked them.

Henning


Apr 8 '06 #2

P: n/a
Hi,

I tried both
Console.Writeline("*{0}*", sb.ToString)
Output:
*ACPI\AuthenticAMD_-_x86_Family_6_Model_6\_0*

And
Dim _s As String = sb.ToString.Trim
Dim _ss() As String = _s.Split(ControlChars.NullChar)
For Each _s in _ss
Console.Writeline(_s)
Next
Output:
ACPI\AuthenticAMD_-_x86_Family_6_Model_6\_0

So it looks like I do only get the first item in the list....

Other idears?

/Henning

"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
What makes you think that you are only getting the first string?

Are you perchance doing something a'kin to?:

Console.Writeline(sb.ToString)

If so, try:

Console.Writeline("*{0}*", sb.ToString)

and see what happens.

I suspect that you are, in fact, getting all the strings but the 2nd and
subsequent strings are being 'hidden' by the first null character
delimiter.

Try stripping the trailing nulls and then splitting the string into an
array of strings and you just might be pleasantly surprised:

Dim _s As String = sb.ToString.Trim

Dim _ss() As String = _s.Split(ControlChars.NullChar)

For Each _s in _ss
Console.Writeline(_s)
Next

"Henning M" <he*****@fys.ku.dk> wrote in message
news:a0***************************@news.arrownet.d k...
Hi,

I'm trying to use stringbuilder to collect a list of strings. (as
suggested by Claes Bergefall)

Declare Auto Function CM_Get_Device_ID_List Lib "cfgmgr32.dll" (ByVal
pszFilter As String, ByVal ptChar As System.Text.StringBuilder, ByVal
bufferLen As Integer, ByVal ulFlags As Integer) As Integer

Dim sb As New StringBuilder(len + 1)
CM_Get_Device_ID_List(filter, sb, sb.Capacity, flags)

But this only givs me the first string and I need them all..
Is it possible to configure the StringBuilder to use a double NULL value
as string termination.
or are there another way of retriving the list?

BTW does anyone know why there are no pointers in VB, I didn't find them
to be a problem in C? I liked them.

Henning



Apr 8 '06 #3

P: n/a
Not enough information!

You have to make sure that the StringBuilder object is big enough to hold
the result. You are setting it's capacity to len + 1, so what is len?

Also, does filter and/or flags have any effect on what is supposed to be
returned?
"Henning M" <he*****@fys.ku.dk> wrote in message
news:3c***************************@news.arrownet.d k...
Hi,

I tried both
Console.Writeline("*{0}*", sb.ToString)
Output:
*ACPI\AuthenticAMD_-_x86_Family_6_Model_6\_0*

And
Dim _s As String = sb.ToString.Trim
Dim _ss() As String = _s.Split(ControlChars.NullChar)
For Each _s in _ss
Console.Writeline(_s)
Next
Output:
ACPI\AuthenticAMD_-_x86_Family_6_Model_6\_0

So it looks like I do only get the first item in the list....

Other idears?

/Henning

"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
What makes you think that you are only getting the first string?

Are you perchance doing something a'kin to?:

Console.Writeline(sb.ToString)

If so, try:

Console.Writeline("*{0}*", sb.ToString)

and see what happens.

I suspect that you are, in fact, getting all the strings but the 2nd and
subsequent strings are being 'hidden' by the first null character
delimiter.

Try stripping the trailing nulls and then splitting the string into an
array of strings and you just might be pleasantly surprised:

Dim _s As String = sb.ToString.Trim

Dim _ss() As String = _s.Split(ControlChars.NullChar)

For Each _s in _ss
Console.Writeline(_s)
Next

"Henning M" <he*****@fys.ku.dk> wrote in message
news:a0***************************@news.arrownet.d k...
Hi,

I'm trying to use stringbuilder to collect a list of strings. (as
suggested by Claes Bergefall)

Declare Auto Function CM_Get_Device_ID_List Lib "cfgmgr32.dll" (ByVal
pszFilter As String, ByVal ptChar As System.Text.StringBuilder, ByVal
bufferLen As Integer, ByVal ulFlags As Integer) As Integer

Dim sb As New StringBuilder(len + 1)
CM_Get_Device_ID_List(filter, sb, sb.Capacity, flags)

But this only givs me the first string and I need them all..
Is it possible to configure the StringBuilder to use a double NULL value
as string termination.
or are there another way of retriving the list?

BTW does anyone know why there are no pointers in VB, I didn't find them
to be a problem in C? I liked them.

Henning




Apr 8 '06 #4

P: n/a
Hi, again

Here are some more info.

This is what I have so far..

Declare Auto Function CM_Get_Device_ID_List_Size Lib "cfgmgr32.dll" _
(ByRef pulLen As Integer, ByVal pszFilter As String, ByVal ulFlags As
Integer) As Integer

Declare Auto Function CM_Get_Device_ID_List Lib "cfgmgr32.dll" _
(ByVal pszFilter As String, ByVal ptChar As System.Text.StringBuilder, ByVal
bufferLen As Integer, ByVal ulFlags As Integer) As Integer

Dim filter As String
Dim flags As Integer
Dim len As Integer
filter = 0
flags = 0

CM_Get_Device_ID_List_Size(len, filter, flags)

Dim sb As New StringBuilder(len + 1)

CM_Get_Device_ID_List(filter, sb, sb.Capacity, flags)

Console.WriteLine("*{0}*", sb.ToString)

System.Console.ReadLine()

The length I recive is about 8500, so that sounds right. right?

Thanks for your help

/ Henning

Below: The MSDN info for the CM_Get_Device_ID_List
--------------------------------------------------

CM_Get_Device_ID_List
The CM_Get_Device_ID_List function retrieves a list of device instance IDs
for the local machine's device instances.

CMAPI CONFIGRET WINAPI
CM_Get_Device_ID_List(
IN PCTSTR pszFilter, OPTIONAL
OUT PTCHAR Buffer,
IN ULONG BufferLen,
IN ULONG ulFlags
);

Parameters
pszFilter
Caller-supplied pointer to a character string specifying a subset of the
machine's device instance identifiers, or NULL. See the following
description of ulFlags.
Buffer
Address of a buffer to receive a set of NULL-terminated device instance
identifier strings. The end of the set is terminated by an extra NULL. The
required buffer size should be obtained by calling
CM_Get_Device_ID_List_Size.
BufferLen
Caller-supplied length, in characters, of the buffer specified by Buffer.
ulFlags
One of the optional, caller-supplied bit flags, listed in the following
table, which specify search filters. If no flags are specified, the function
returns all device instance IDs for all device instances.
CM_GETIDLIST_FILTER_ENUMERATOR

If this flag is set, pszFilter must specify the name of a device enumerator,
optionally followed by a device identifier. The string format is
EnumeratorName\<DeviceID>, such as ROOT or ROOT\*PNP0500.
If pszFilter supplies only an enumerator name, the function returns device
instance IDs for the instances of each device associated with the
enumerator. Enumerator names can be obtained by calling
CM_Enumerate_Enumerators.

If pszFilter supplies both an enumerator and a device ID, the function
returns device instance IDs only for the device instances of the specified
device, associated with the enumerator.

CM_GETIDLIST_FILTER_SERVICE

If this flag is set, pszFilter must specify the name of a Windows service
(typically a driver). The function returns device instance IDs for the
device instances controlled by the specified service.
Note that if the device tree does not contain a device node for the
specified service, this function creates one by default. To inhibit this
behavior, also set CM_GETIDLIST_DONOTGENERATE.

CM_GETIDLIST_FILTER_EJECTRELATIONS

If this flag is set, pszFilter must specify a device name. The function
returns device instance IDs for the ejection relations of the specified
device instance.
CM_GETIDLIST_FILTER_REMOVALRELATIONS

If this flag is set, pszFilter must specify a device name. The function
returns device instance IDs for the removal relations of the specified
device instance.
CM_GETIDLIST_FILTER_POWERRELATIONS

Not used.
CM_GETIDLIST_FILTER_BUSRELATIONS

Not used.
CM_GETIDLIST_DONOTGENERATE

Used only with CM_GETIDLIST_FILTER_SERVICE. If set, and if the device tree
does not contain a device node for the specified service, this flag prevents
the function from creating a device node for the service.
Return Value
If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it
returns one of the CR_-prefixed error codes defined in cfgmgr32.h.

Headers
Declared in cfgmgr32.h. Include cfgmgr32.h.

Comments
For information about device instance IDs, see Device Identification
Strings.


"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Not enough information!

You have to make sure that the StringBuilder object is big enough to hold
the result. You are setting it's capacity to len + 1, so what is len?

Also, does filter and/or flags have any effect on what is supposed to be
returned?
"Henning M" <he*****@fys.ku.dk> wrote in message
news:3c***************************@news.arrownet.d k...
Hi,

I tried both
Console.Writeline("*{0}*", sb.ToString)
Output:
*ACPI\AuthenticAMD_-_x86_Family_6_Model_6\_0*

And
Dim _s As String = sb.ToString.Trim
Dim _ss() As String = _s.Split(ControlChars.NullChar)
For Each _s in _ss
Console.Writeline(_s)
Next
Output:
ACPI\AuthenticAMD_-_x86_Family_6_Model_6\_0

So it looks like I do only get the first item in the list....

Other idears?

/Henning

"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
What makes you think that you are only getting the first string?

Are you perchance doing something a'kin to?:

Console.Writeline(sb.ToString)

If so, try:

Console.Writeline("*{0}*", sb.ToString)

and see what happens.

I suspect that you are, in fact, getting all the strings but the 2nd and
subsequent strings are being 'hidden' by the first null character
delimiter.

Try stripping the trailing nulls and then splitting the string into an
array of strings and you just might be pleasantly surprised:

Dim _s As String = sb.ToString.Trim

Dim _ss() As String = _s.Split(ControlChars.NullChar)

For Each _s in _ss
Console.Writeline(_s)
Next

"Henning M" <he*****@fys.ku.dk> wrote in message
news:a0***************************@news.arrownet.d k...
Hi,

I'm trying to use stringbuilder to collect a list of strings. (as
suggested by Claes Bergefall)

Declare Auto Function CM_Get_Device_ID_List Lib "cfgmgr32.dll" (ByVal
pszFilter As String, ByVal ptChar As System.Text.StringBuilder, ByVal
bufferLen As Integer, ByVal ulFlags As Integer) As Integer

Dim sb As New StringBuilder(len + 1)
CM_Get_Device_ID_List(filter, sb, sb.Capacity, flags)

But this only givs me the first string and I need them all..
Is it possible to configure the StringBuilder to use a double NULL
value as string termination.
or are there another way of retriving the list?

BTW does anyone know why there are no pointers in VB, I didn't find
them to be a problem in C? I liked them.

Henning





Apr 8 '06 #5

P: n/a
Had me bluffed for bit but finally got it!

First of all I suggust you turn Option Strict on. This will help you avoid
various gotchas.

The secret is that the ptChar parameter of CM_Get_Device_ID_List really
wants an array of characters. While it could be argued that a stringbuilder
van represent an array of characters, in this case it does not work.

Change the declaration to ByVal ptChar As Char() and try this - it works for
me:

Dim filter As String = ""
Dim flags As Integer = 0
Dim len As Integer

Console.WriteLine("CM_Get_Device_ID_List_Size = {0}",
CM_Get_Device_ID_List_Size(len, filter, flags))

Dim c() As Char = New Char(len - 1) {}

Console.WriteLine("CM_Get_Device_ID_List = {0}",
CM_Get_Device_ID_List(filter, c, c.Length, flags))

Dim sb As New StringBuilder()

sb.Append(c, 0, c.Length)

Dim ss() As String =
sb.ToString.Trim(ControlChars.NullChar).Split(Cont rolChars.NullChar)

Console.WriteLine("---- Start of Device list ----")

For Each s As String In ss
Console.WriteLine(s)
Next

Console.WriteLine("---- End of Device list ----")

"Henning M" <he*****@fys.ku.dk> wrote in message
news:dd***************************@news.arrownet.d k...
Hi, again

Here are some more info.

This is what I have so far..

Declare Auto Function CM_Get_Device_ID_List_Size Lib "cfgmgr32.dll" _
(ByRef pulLen As Integer, ByVal pszFilter As String, ByVal ulFlags As
Integer) As Integer

Declare Auto Function CM_Get_Device_ID_List Lib "cfgmgr32.dll" _
(ByVal pszFilter As String, ByVal ptChar As System.Text.StringBuilder,
ByVal bufferLen As Integer, ByVal ulFlags As Integer) As Integer

Dim filter As String
Dim flags As Integer
Dim len As Integer
filter = 0
flags = 0

CM_Get_Device_ID_List_Size(len, filter, flags)

Dim sb As New StringBuilder(len + 1)

CM_Get_Device_ID_List(filter, sb, sb.Capacity, flags)

Console.WriteLine("*{0}*", sb.ToString)

System.Console.ReadLine()

The length I recive is about 8500, so that sounds right. right?

Thanks for your help

/ Henning

Below: The MSDN info for the CM_Get_Device_ID_List
--------------------------------------------------

CM_Get_Device_ID_List
The CM_Get_Device_ID_List function retrieves a list of device instance IDs
for the local machine's device instances.

CMAPI CONFIGRET WINAPI
CM_Get_Device_ID_List(
IN PCTSTR pszFilter, OPTIONAL
OUT PTCHAR Buffer,
IN ULONG BufferLen,
IN ULONG ulFlags
);

Parameters
pszFilter
Caller-supplied pointer to a character string specifying a subset of the
machine's device instance identifiers, or NULL. See the following
description of ulFlags.
Buffer
Address of a buffer to receive a set of NULL-terminated device instance
identifier strings. The end of the set is terminated by an extra NULL. The
required buffer size should be obtained by calling
CM_Get_Device_ID_List_Size.
BufferLen
Caller-supplied length, in characters, of the buffer specified by Buffer.
ulFlags
One of the optional, caller-supplied bit flags, listed in the following
table, which specify search filters. If no flags are specified, the
function
returns all device instance IDs for all device instances.
CM_GETIDLIST_FILTER_ENUMERATOR

If this flag is set, pszFilter must specify the name of a device
enumerator,
optionally followed by a device identifier. The string format is
EnumeratorName\<DeviceID>, such as ROOT or ROOT\*PNP0500.
If pszFilter supplies only an enumerator name, the function returns device
instance IDs for the instances of each device associated with the
enumerator. Enumerator names can be obtained by calling
CM_Enumerate_Enumerators.

If pszFilter supplies both an enumerator and a device ID, the function
returns device instance IDs only for the device instances of the specified
device, associated with the enumerator.

CM_GETIDLIST_FILTER_SERVICE

If this flag is set, pszFilter must specify the name of a Windows service
(typically a driver). The function returns device instance IDs for the
device instances controlled by the specified service.
Note that if the device tree does not contain a device node for the
specified service, this function creates one by default. To inhibit this
behavior, also set CM_GETIDLIST_DONOTGENERATE.

CM_GETIDLIST_FILTER_EJECTRELATIONS

If this flag is set, pszFilter must specify a device name. The function
returns device instance IDs for the ejection relations of the specified
device instance.
CM_GETIDLIST_FILTER_REMOVALRELATIONS

If this flag is set, pszFilter must specify a device name. The function
returns device instance IDs for the removal relations of the specified
device instance.
CM_GETIDLIST_FILTER_POWERRELATIONS

Not used.
CM_GETIDLIST_FILTER_BUSRELATIONS

Not used.
CM_GETIDLIST_DONOTGENERATE

Used only with CM_GETIDLIST_FILTER_SERVICE. If set, and if the device tree
does not contain a device node for the specified service, this flag
prevents
the function from creating a device node for the service.
Return Value
If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it
returns one of the CR_-prefixed error codes defined in cfgmgr32.h.

Headers
Declared in cfgmgr32.h. Include cfgmgr32.h.

Comments
For information about device instance IDs, see Device Identification
Strings.


"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Not enough information!

You have to make sure that the StringBuilder object is big enough to hold
the result. You are setting it's capacity to len + 1, so what is len?

Also, does filter and/or flags have any effect on what is supposed to be
returned?
"Henning M" <he*****@fys.ku.dk> wrote in message
news:3c***************************@news.arrownet.d k...
Hi,

I tried both
Console.Writeline("*{0}*", sb.ToString)
Output:
*ACPI\AuthenticAMD_-_x86_Family_6_Model_6\_0*

And
Dim _s As String = sb.ToString.Trim
Dim _ss() As String = _s.Split(ControlChars.NullChar)
For Each _s in _ss
Console.Writeline(_s)
Next
Output:
ACPI\AuthenticAMD_-_x86_Family_6_Model_6\_0

So it looks like I do only get the first item in the list....

Other idears?

/Henning

"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
What makes you think that you are only getting the first string?

Are you perchance doing something a'kin to?:

Console.Writeline(sb.ToString)

If so, try:

Console.Writeline("*{0}*", sb.ToString)

and see what happens.

I suspect that you are, in fact, getting all the strings but the 2nd
and subsequent strings are being 'hidden' by the first null character
delimiter.

Try stripping the trailing nulls and then splitting the string into an
array of strings and you just might be pleasantly surprised:

Dim _s As String = sb.ToString.Trim

Dim _ss() As String = _s.Split(ControlChars.NullChar)

For Each _s in _ss
Console.Writeline(_s)
Next

"Henning M" <he*****@fys.ku.dk> wrote in message
news:a0***************************@news.arrownet.d k...
> Hi,
>
> I'm trying to use stringbuilder to collect a list of strings. (as
> suggested by Claes Bergefall)
>
> Declare Auto Function CM_Get_Device_ID_List Lib "cfgmgr32.dll" (ByVal
> pszFilter As String, ByVal ptChar As System.Text.StringBuilder, ByVal
> bufferLen As Integer, ByVal ulFlags As Integer) As Integer
>
> Dim sb As New StringBuilder(len + 1)
> CM_Get_Device_ID_List(filter, sb, sb.Capacity, flags)
>
> But this only givs me the first string and I need them all..
> Is it possible to configure the StringBuilder to use a double NULL
> value as string termination.
> or are there another way of retriving the list?
>
> BTW does anyone know why there are no pointers in VB, I didn't find
> them to be a problem in C? I liked them.
>
> Henning
>
>
>
>
>
>
>



Apr 8 '06 #6

P: n/a
Thanks ALOT :) That work.

Hope you are around when I get into real programming troubles :)

Thanks again.

/Henning

"Stephany Young" <noone@localhost> wrote in message
news:O5**************@TK2MSFTNGP05.phx.gbl...
Had me bluffed for bit but finally got it!

First of all I suggust you turn Option Strict on. This will help you avoid
various gotchas.

The secret is that the ptChar parameter of CM_Get_Device_ID_List really
wants an array of characters. While it could be argued that a
stringbuilder van represent an array of characters, in this case it does
not work.

Change the declaration to ByVal ptChar As Char() and try this - it works
for me:

Dim filter As String = ""
Dim flags As Integer = 0
Dim len As Integer

Console.WriteLine("CM_Get_Device_ID_List_Size = {0}",
CM_Get_Device_ID_List_Size(len, filter, flags))

Dim c() As Char = New Char(len - 1) {}

Console.WriteLine("CM_Get_Device_ID_List = {0}",
CM_Get_Device_ID_List(filter, c, c.Length, flags))

Dim sb As New StringBuilder()

sb.Append(c, 0, c.Length)

Dim ss() As String =
sb.ToString.Trim(ControlChars.NullChar).Split(Cont rolChars.NullChar)

Console.WriteLine("---- Start of Device list ----")

For Each s As String In ss
Console.WriteLine(s)
Next

Console.WriteLine("---- End of Device list ----")

"Henning M" <he*****@fys.ku.dk> wrote in message
news:dd***************************@news.arrownet.d k...
Hi, again

Here are some more info.

This is what I have so far..

Declare Auto Function CM_Get_Device_ID_List_Size Lib "cfgmgr32.dll" _
(ByRef pulLen As Integer, ByVal pszFilter As String, ByVal ulFlags As
Integer) As Integer

Declare Auto Function CM_Get_Device_ID_List Lib "cfgmgr32.dll" _
(ByVal pszFilter As String, ByVal ptChar As System.Text.StringBuilder,
ByVal bufferLen As Integer, ByVal ulFlags As Integer) As Integer

Dim filter As String
Dim flags As Integer
Dim len As Integer
filter = 0
flags = 0

CM_Get_Device_ID_List_Size(len, filter, flags)

Dim sb As New StringBuilder(len + 1)

CM_Get_Device_ID_List(filter, sb, sb.Capacity, flags)

Console.WriteLine("*{0}*", sb.ToString)

System.Console.ReadLine()

The length I recive is about 8500, so that sounds right. right?

Thanks for your help

/ Henning

Below: The MSDN info for the CM_Get_Device_ID_List
--------------------------------------------------

CM_Get_Device_ID_List
The CM_Get_Device_ID_List function retrieves a list of device instance
IDs
for the local machine's device instances.

CMAPI CONFIGRET WINAPI
CM_Get_Device_ID_List(
IN PCTSTR pszFilter, OPTIONAL
OUT PTCHAR Buffer,
IN ULONG BufferLen,
IN ULONG ulFlags
);

Parameters
pszFilter
Caller-supplied pointer to a character string specifying a subset of the
machine's device instance identifiers, or NULL. See the following
description of ulFlags.
Buffer
Address of a buffer to receive a set of NULL-terminated device instance
identifier strings. The end of the set is terminated by an extra NULL.
The
required buffer size should be obtained by calling
CM_Get_Device_ID_List_Size.
BufferLen
Caller-supplied length, in characters, of the buffer specified by Buffer.
ulFlags
One of the optional, caller-supplied bit flags, listed in the following
table, which specify search filters. If no flags are specified, the
function
returns all device instance IDs for all device instances.
CM_GETIDLIST_FILTER_ENUMERATOR

If this flag is set, pszFilter must specify the name of a device
enumerator,
optionally followed by a device identifier. The string format is
EnumeratorName\<DeviceID>, such as ROOT or ROOT\*PNP0500.
If pszFilter supplies only an enumerator name, the function returns
device
instance IDs for the instances of each device associated with the
enumerator. Enumerator names can be obtained by calling
CM_Enumerate_Enumerators.

If pszFilter supplies both an enumerator and a device ID, the function
returns device instance IDs only for the device instances of the
specified
device, associated with the enumerator.

CM_GETIDLIST_FILTER_SERVICE

If this flag is set, pszFilter must specify the name of a Windows service
(typically a driver). The function returns device instance IDs for the
device instances controlled by the specified service.
Note that if the device tree does not contain a device node for the
specified service, this function creates one by default. To inhibit this
behavior, also set CM_GETIDLIST_DONOTGENERATE.

CM_GETIDLIST_FILTER_EJECTRELATIONS

If this flag is set, pszFilter must specify a device name. The function
returns device instance IDs for the ejection relations of the specified
device instance.
CM_GETIDLIST_FILTER_REMOVALRELATIONS

If this flag is set, pszFilter must specify a device name. The function
returns device instance IDs for the removal relations of the specified
device instance.
CM_GETIDLIST_FILTER_POWERRELATIONS

Not used.
CM_GETIDLIST_FILTER_BUSRELATIONS

Not used.
CM_GETIDLIST_DONOTGENERATE

Used only with CM_GETIDLIST_FILTER_SERVICE. If set, and if the device
tree
does not contain a device node for the specified service, this flag
prevents
the function from creating a device node for the service.
Return Value
If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it
returns one of the CR_-prefixed error codes defined in cfgmgr32.h.

Headers
Declared in cfgmgr32.h. Include cfgmgr32.h.

Comments
For information about device instance IDs, see Device Identification
Strings.


"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Not enough information!

You have to make sure that the StringBuilder object is big enough to
hold the result. You are setting it's capacity to len + 1, so what is
len?

Also, does filter and/or flags have any effect on what is supposed to be
returned?
"Henning M" <he*****@fys.ku.dk> wrote in message
news:3c***************************@news.arrownet.d k...
Hi,

I tried both
Console.Writeline("*{0}*", sb.ToString)
Output:
*ACPI\AuthenticAMD_-_x86_Family_6_Model_6\_0*

And
Dim _s As String = sb.ToString.Trim
Dim _ss() As String = _s.Split(ControlChars.NullChar)
For Each _s in _ss
Console.Writeline(_s)
Next
Output:
ACPI\AuthenticAMD_-_x86_Family_6_Model_6\_0

So it looks like I do only get the first item in the list....

Other idears?

/Henning

"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
> What makes you think that you are only getting the first string?
>
> Are you perchance doing something a'kin to?:
>
> Console.Writeline(sb.ToString)
>
> If so, try:
>
> Console.Writeline("*{0}*", sb.ToString)
>
> and see what happens.
>
> I suspect that you are, in fact, getting all the strings but the 2nd
> and subsequent strings are being 'hidden' by the first null character
> delimiter.
>
> Try stripping the trailing nulls and then splitting the string into an
> array of strings and you just might be pleasantly surprised:
>
> Dim _s As String = sb.ToString.Trim
>
> Dim _ss() As String = _s.Split(ControlChars.NullChar)
>
> For Each _s in _ss
> Console.Writeline(_s)
> Next
>
>
>
> "Henning M" <he*****@fys.ku.dk> wrote in message
> news:a0***************************@news.arrownet.d k...
>> Hi,
>>
>> I'm trying to use stringbuilder to collect a list of strings. (as
>> suggested by Claes Bergefall)
>>
>> Declare Auto Function CM_Get_Device_ID_List Lib "cfgmgr32.dll" (ByVal
>> pszFilter As String, ByVal ptChar As System.Text.StringBuilder, ByVal
>> bufferLen As Integer, ByVal ulFlags As Integer) As Integer
>>
>> Dim sb As New StringBuilder(len + 1)
>> CM_Get_Device_ID_List(filter, sb, sb.Capacity, flags)
>>
>> But this only givs me the first string and I need them all..
>> Is it possible to configure the StringBuilder to use a double NULL
>> value as string termination.
>> or are there another way of retriving the list?
>>
>> BTW does anyone know why there are no pointers in VB, I didn't find
>> them to be a problem in C? I liked them.
>>
>> Henning
>>
>>
>>
>>
>>
>>
>>
>
>



Apr 8 '06 #7

P: n/a

"Henning M" <he*****@fys.ku.dk> wrote in message
news:a0***************************@news.arrownet.d k...
BTW does anyone know why there are no pointers in VB, I didn't find them
to be a problem in C? I liked them.


Pointers are too complicated for the MTV generation. That's why they
invented Java/J# -- to get rid of them <G>.

Apr 8 '06 #8

P: n/a
"Henning M" <he*****@fys.ku.dk> schrieb:
BTW does anyone know why there are no pointers in VB, I didn't find them
to be a problem in C? I liked them.


VB uses type-safe references instead of pointers! Thus there is no support
for pointer arithmetics built directly into the language.

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

Apr 8 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.