Hi,
I'm trying to use stringbuilder to collect a list of strings. (as suggested
by Claes Bergefall)
Declare Auto Function CM_Get_Device_I D_List Lib "cfgmgr32.d ll" (ByVal
pszFilter As String, ByVal ptChar As System.Text.Str ingBuilder, ByVal
bufferLen As Integer, ByVal ulFlags As Integer) As Integer
Dim sb As New StringBuilder(l en + 1)
CM_Get_Device_I D_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 8 2255
What makes you think that you are only getting the first string?
Are you perchance doing something a'kin to?:
Console.Writeli ne(sb.ToString)
If so, try:
Console.Writeli ne("*{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.Tri m
Dim _ss() As String = _s.Split(Contro lChars.NullChar )
For Each _s in _ss
Console.Writeli ne(_s)
Next
"Henning M" <he*****@fys.ku .dk> wrote in message
news:a0******** *************** ****@news.arrow net.dk... Hi,
I'm trying to use stringbuilder to collect a list of strings. (as suggested by Claes Bergefall)
Declare Auto Function CM_Get_Device_I D_List Lib "cfgmgr32.d ll" (ByVal pszFilter As String, ByVal ptChar As System.Text.Str ingBuilder, ByVal bufferLen As Integer, ByVal ulFlags As Integer) As Integer
Dim sb As New StringBuilder(l en + 1) CM_Get_Device_I D_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
Hi,
I tried both
Console.Writeli ne("*{0}*", sb.ToString)
Output:
*ACPI\Authentic AMD_-_x86_Family_6_M odel_6\_0*
And
Dim _s As String = sb.ToString.Tri m
Dim _ss() As String = _s.Split(Contro lChars.NullChar )
For Each _s in _ss
Console.Writeli ne(_s)
Next
Output:
ACPI\AuthenticA MD_-_x86_Family_6_M odel_6\_0
So it looks like I do only get the first item in the list....
Other idears?
/Henning
"Stephany Young" <noone@localhos t> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. .. What makes you think that you are only getting the first string?
Are you perchance doing something a'kin to?:
Console.Writeli ne(sb.ToString)
If so, try:
Console.Writeli ne("*{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.Tri m
Dim _ss() As String = _s.Split(Contro lChars.NullChar )
For Each _s in _ss Console.Writeli ne(_s) Next "Henning M" <he*****@fys.ku .dk> wrote in message news:a0******** *************** ****@news.arrow net.dk... Hi,
I'm trying to use stringbuilder to collect a list of strings. (as suggested by Claes Bergefall)
Declare Auto Function CM_Get_Device_I D_List Lib "cfgmgr32.d ll" (ByVal pszFilter As String, ByVal ptChar As System.Text.Str ingBuilder, ByVal bufferLen As Integer, ByVal ulFlags As Integer) As Integer
Dim sb As New StringBuilder(l en + 1) CM_Get_Device_I D_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
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.arrow net.dk... Hi,
I tried both Console.Writeli ne("*{0}*", sb.ToString) Output: *ACPI\Authentic AMD_-_x86_Family_6_M odel_6\_0*
And Dim _s As String = sb.ToString.Tri m Dim _ss() As String = _s.Split(Contro lChars.NullChar ) For Each _s in _ss Console.Writeli ne(_s) Next Output: ACPI\AuthenticA MD_-_x86_Family_6_M odel_6\_0
So it looks like I do only get the first item in the list....
Other idears?
/Henning
"Stephany Young" <noone@localhos t> wrote in message news:%2******** ********@TK2MSF TNGP05.phx.gbl. .. What makes you think that you are only getting the first string?
Are you perchance doing something a'kin to?:
Console.Writeli ne(sb.ToString)
If so, try:
Console.Writeli ne("*{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.Tri m
Dim _ss() As String = _s.Split(Contro lChars.NullChar )
For Each _s in _ss Console.Writeli ne(_s) Next "Henning M" <he*****@fys.ku .dk> wrote in message news:a0******** *************** ****@news.arrow net.dk... Hi,
I'm trying to use stringbuilder to collect a list of strings. (as suggested by Claes Bergefall)
Declare Auto Function CM_Get_Device_I D_List Lib "cfgmgr32.d ll" (ByVal pszFilter As String, ByVal ptChar As System.Text.Str ingBuilder, ByVal bufferLen As Integer, ByVal ulFlags As Integer) As Integer
Dim sb As New StringBuilder(l en + 1) CM_Get_Device_I D_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
Hi, again
Here are some more info.
This is what I have so far..
Declare Auto Function CM_Get_Device_I D_List_Size Lib "cfgmgr32.d ll" _
(ByRef pulLen As Integer, ByVal pszFilter As String, ByVal ulFlags As
Integer) As Integer
Declare Auto Function CM_Get_Device_I D_List Lib "cfgmgr32.d ll" _
(ByVal pszFilter As String, ByVal ptChar As System.Text.Str ingBuilder, 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_I D_List_Size(len , filter, flags)
Dim sb As New StringBuilder(l en + 1)
CM_Get_Device_I D_List(filter, sb, sb.Capacity, flags)
Console.WriteLi ne("*{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_I D_List
--------------------------------------------------
CM_Get_Device_I D_List
The CM_Get_Device_I D_List function retrieves a list of device instance IDs
for the local machine's device instances.
CMAPI CONFIGRET WINAPI
CM_Get_Device_I D_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_I D_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_FI LTER_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_En umerators.
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_FI LTER_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_DO NOTGENERATE.
CM_GETIDLIST_FI LTER_EJECTRELAT IONS
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_FI LTER_REMOVALREL ATIONS
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_FI LTER_POWERRELAT IONS
Not used.
CM_GETIDLIST_FI LTER_BUSRELATIO NS
Not used.
CM_GETIDLIST_DO NOTGENERATE
Used only with CM_GETIDLIST_FI LTER_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@localhos t> wrote in message
news:%2******** ********@TK2MSF TNGP04.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.arrow net.dk... Hi,
I tried both Console.Writeli ne("*{0}*", sb.ToString) Output: *ACPI\Authentic AMD_-_x86_Family_6_M odel_6\_0*
And Dim _s As String = sb.ToString.Tri m Dim _ss() As String = _s.Split(Contro lChars.NullChar ) For Each _s in _ss Console.Writeli ne(_s) Next Output: ACPI\AuthenticA MD_-_x86_Family_6_M odel_6\_0
So it looks like I do only get the first item in the list....
Other idears?
/Henning
"Stephany Young" <noone@localhos t> wrote in message news:%2******** ********@TK2MSF TNGP05.phx.gbl. .. What makes you think that you are only getting the first string?
Are you perchance doing something a'kin to?:
Console.Writeli ne(sb.ToString)
If so, try:
Console.Writeli ne("*{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.Tri m
Dim _ss() As String = _s.Split(Contro lChars.NullChar )
For Each _s in _ss Console.Writeli ne(_s) Next "Henning M" <he*****@fys.ku .dk> wrote in message news:a0******** *************** ****@news.arrow net.dk... Hi,
I'm trying to use stringbuilder to collect a list of strings. (as suggested by Claes Bergefall)
Declare Auto Function CM_Get_Device_I D_List Lib "cfgmgr32.d ll" (ByVal pszFilter As String, ByVal ptChar As System.Text.Str ingBuilder, ByVal bufferLen As Integer, ByVal ulFlags As Integer) As Integer
Dim sb As New StringBuilder(l en + 1) CM_Get_Device_I D_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
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_I D_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.WriteLi ne("CM_Get_Devi ce_ID_List_Size = {0}",
CM_Get_Device_I D_List_Size(len , filter, flags))
Dim c() As Char = New Char(len - 1) {}
Console.WriteLi ne("CM_Get_Devi ce_ID_List = {0}",
CM_Get_Device_I D_List(filter, c, c.Length, flags))
Dim sb As New StringBuilder()
sb.Append(c, 0, c.Length)
Dim ss() As String =
sb.ToString.Tri m(ControlChars. NullChar).Split (ControlChars.N ullChar)
Console.WriteLi ne("---- Start of Device list ----")
For Each s As String In ss
Console.WriteLi ne(s)
Next
Console.WriteLi ne("---- End of Device list ----")
"Henning M" <he*****@fys.ku .dk> wrote in message
news:dd******** *************** ****@news.arrow net.dk... Hi, again
Here are some more info.
This is what I have so far..
Declare Auto Function CM_Get_Device_I D_List_Size Lib "cfgmgr32.d ll" _ (ByRef pulLen As Integer, ByVal pszFilter As String, ByVal ulFlags As Integer) As Integer
Declare Auto Function CM_Get_Device_I D_List Lib "cfgmgr32.d ll" _ (ByVal pszFilter As String, ByVal ptChar As System.Text.Str ingBuilder, 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_I D_List_Size(len , filter, flags)
Dim sb As New StringBuilder(l en + 1)
CM_Get_Device_I D_List(filter, sb, sb.Capacity, flags)
Console.WriteLi ne("*{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_I D_List --------------------------------------------------
CM_Get_Device_I D_List The CM_Get_Device_I D_List function retrieves a list of device instance IDs for the local machine's device instances.
CMAPI CONFIGRET WINAPI CM_Get_Device_I D_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_I D_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_FI LTER_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_En umerators.
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_FI LTER_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_DO NOTGENERATE.
CM_GETIDLIST_FI LTER_EJECTRELAT IONS
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_FI LTER_REMOVALREL ATIONS
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_FI LTER_POWERRELAT IONS
Not used. CM_GETIDLIST_FI LTER_BUSRELATIO NS
Not used. CM_GETIDLIST_DO NOTGENERATE
Used only with CM_GETIDLIST_FI LTER_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@localhos t> wrote in message news:%2******** ********@TK2MSF TNGP04.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.arrow net.dk... Hi,
I tried both Console.Writeli ne("*{0}*", sb.ToString) Output: *ACPI\Authentic AMD_-_x86_Family_6_M odel_6\_0*
And Dim _s As String = sb.ToString.Tri m Dim _ss() As String = _s.Split(Contro lChars.NullChar ) For Each _s in _ss Console.Writeli ne(_s) Next Output: ACPI\AuthenticA MD_-_x86_Family_6_M odel_6\_0
So it looks like I do only get the first item in the list....
Other idears?
/Henning
"Stephany Young" <noone@localhos t> wrote in message news:%2******** ********@TK2MSF TNGP05.phx.gbl. .. What makes you think that you are only getting the first string?
Are you perchance doing something a'kin to?:
Console.Writeli ne(sb.ToString)
If so, try:
Console.Writeli ne("*{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.Tri m
Dim _ss() As String = _s.Split(Contro lChars.NullChar )
For Each _s in _ss Console.Writeli ne(_s) Next "Henning M" <he*****@fys.ku .dk> wrote in message news:a0******** *************** ****@news.arrow net.dk... > Hi, > > I'm trying to use stringbuilder to collect a list of strings. (as > suggested by Claes Bergefall) > > Declare Auto Function CM_Get_Device_I D_List Lib "cfgmgr32.d ll" (ByVal > pszFilter As String, ByVal ptChar As System.Text.Str ingBuilder, ByVal > bufferLen As Integer, ByVal ulFlags As Integer) As Integer > > Dim sb As New StringBuilder(l en + 1) > CM_Get_Device_I D_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 > > > > > > >
Thanks ALOT :) That work.
Hope you are around when I get into real programming troubles :)
Thanks again.
/Henning
"Stephany Young" <noone@localhos t> wrote in message
news:O5******** ******@TK2MSFTN GP05.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_I D_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.WriteLi ne("CM_Get_Devi ce_ID_List_Size = {0}", CM_Get_Device_I D_List_Size(len , filter, flags))
Dim c() As Char = New Char(len - 1) {}
Console.WriteLi ne("CM_Get_Devi ce_ID_List = {0}", CM_Get_Device_I D_List(filter, c, c.Length, flags))
Dim sb As New StringBuilder()
sb.Append(c, 0, c.Length)
Dim ss() As String = sb.ToString.Tri m(ControlChars. NullChar).Split (ControlChars.N ullChar)
Console.WriteLi ne("---- Start of Device list ----")
For Each s As String In ss Console.WriteLi ne(s) Next
Console.WriteLi ne("---- End of Device list ----") "Henning M" <he*****@fys.ku .dk> wrote in message news:dd******** *************** ****@news.arrow net.dk... Hi, again
Here are some more info.
This is what I have so far..
Declare Auto Function CM_Get_Device_I D_List_Size Lib "cfgmgr32.d ll" _ (ByRef pulLen As Integer, ByVal pszFilter As String, ByVal ulFlags As Integer) As Integer
Declare Auto Function CM_Get_Device_I D_List Lib "cfgmgr32.d ll" _ (ByVal pszFilter As String, ByVal ptChar As System.Text.Str ingBuilder, 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_I D_List_Size(len , filter, flags)
Dim sb As New StringBuilder(l en + 1)
CM_Get_Device_I D_List(filter, sb, sb.Capacity, flags)
Console.WriteLi ne("*{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_I D_List --------------------------------------------------
CM_Get_Device_I D_List The CM_Get_Device_I D_List function retrieves a list of device instance IDs for the local machine's device instances.
CMAPI CONFIGRET WINAPI CM_Get_Device_I D_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_I D_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_FI LTER_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_En umerators.
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_FI LTER_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_DO NOTGENERATE.
CM_GETIDLIST_FI LTER_EJECTRELAT IONS
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_FI LTER_REMOVALREL ATIONS
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_FI LTER_POWERRELAT IONS
Not used. CM_GETIDLIST_FI LTER_BUSRELATIO NS
Not used. CM_GETIDLIST_DO NOTGENERATE
Used only with CM_GETIDLIST_FI LTER_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@localhos t> wrote in message news:%2******** ********@TK2MSF TNGP04.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.arrow net.dk... Hi,
I tried both Console.Writeli ne("*{0}*", sb.ToString) Output: *ACPI\Authentic AMD_-_x86_Family_6_M odel_6\_0*
And Dim _s As String = sb.ToString.Tri m Dim _ss() As String = _s.Split(Contro lChars.NullChar ) For Each _s in _ss Console.Writeli ne(_s) Next Output: ACPI\AuthenticA MD_-_x86_Family_6_M odel_6\_0
So it looks like I do only get the first item in the list....
Other idears?
/Henning
"Stephany Young" <noone@localhos t> wrote in message news:%2******** ********@TK2MSF TNGP05.phx.gbl. .. > What makes you think that you are only getting the first string? > > Are you perchance doing something a'kin to?: > > Console.Writeli ne(sb.ToString) > > If so, try: > > Console.Writeli ne("*{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.Tri m > > Dim _ss() As String = _s.Split(Contro lChars.NullChar ) > > For Each _s in _ss > Console.Writeli ne(_s) > Next > > > > "Henning M" <he*****@fys.ku .dk> wrote in message > news:a0******** *************** ****@news.arrow net.dk... >> Hi, >> >> I'm trying to use stringbuilder to collect a list of strings. (as >> suggested by Claes Bergefall) >> >> Declare Auto Function CM_Get_Device_I D_List Lib "cfgmgr32.d ll" (ByVal >> pszFilter As String, ByVal ptChar As System.Text.Str ingBuilder, ByVal >> bufferLen As Integer, ByVal ulFlags As Integer) As Integer >> >> Dim sb As New StringBuilder(l en + 1) >> CM_Get_Device_I D_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 >> >> >> >> >> >> >> > >
"Henning M" <he*****@fys.ku .dk> wrote in message
news:a0******** *************** ****@news.arrow net.dk... 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>.
"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/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mahmood Ahmad |
last post by:
Hello,
I have written a program that reads three types of records, validates
them acording to certain requirements and writes the valid records
into a binary file. The invalid records are supposed to be reported on
the printer but I have commented those pieces of code and have got
those records printed on the screen. I am using Microsoft...
|
by: Andrea |
last post by:
Hy
I have a litle problem :
I have to invoke a function in an unmanaged dll (writen in C) from C#
------------------------------------------------
int string_modify(unsigned char* myparameter)
--------------------------------------------------
how to declare this function in C# ?
|
by: Sagaert Johan |
last post by:
Hi
I am construncting a string containing some control chars (STX/ETX)
I noticed that adding a byte with value 2 is the same as adding a character
'2' ???
How can i solve this problem ?
Is the stringbuilder restricted to pure readable ascii code contents ?
|
by: deko |
last post by:
I need to loop through a string and remove all characters except numbers or
letters. I am getting an ArgumentOutOfRangeException: "Index was out of
range. Must be non-negative and less than the size of the collection"
Not sure what is going on... any suggestions welcome!
public static string fixStr(string aStr)
{
StringBuilder bStr =...
|
by: Peter |
last post by:
Hi,
A newbie question ..
I want to use an array of length 4 while each array element
is a string of 40 chars.
I typed ..
StringBuilder title = new StringBuilder(40);
| |
by: John Smith |
last post by:
Lets say I was given a Char array as:
Dim Arr(size) As Char
and this array holds a string which ends with a C-Style zero termination.
I want to make this into a String object and cut it off at the end.
So in C# I could do:
String str = (new String(arr)).Trim('\0');
|
by: DV |
last post by:
I have a StringBuilder that has a string with 12,000,000 characters.
When I do a ToString(), I expect to have ~25,000,000 bytes worth of
memory, yet, I end up with ~43,000,000 bytes. That's almost double
the size. The string returned from ToString() is actually of size
StringBuilder.Capacity, NOT StringBuilder.Length. It may have a...
|
by: rhkodiak |
last post by:
I was in an interview question what is the most efficient way to sort
a string for example "010101", the result would then be "000111", and
write the code on how to do this. I wrote the code for the
interviewers and I was told I did ok, but a stringbuilder would have
been better to use. In this storing the string in an array and
calling the...
|
by: raylopez99 |
last post by:
StringBuilder better and faster than string for adding many strings.
Look at the below. It's amazing how much faster StringBuilder is than
string.
The last loop below is telling: for adding 200000 strings of 8 char
each, string took over 25 minutes while StringBuilder took 40
milliseconds!
Can anybody explain such a radical...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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...
|
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...
|
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...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |