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

Calling dll functions from vb.net with pointer returns!

Hej All

Im relativ new to VB.net and im trying to collect som device information
using cfgmgr32.dll

I use - Declare Function GetListLength Lib "cfgmgr32.dll" Alias
"CM_Get_Device_ID_List_SizeA" (ByRef pulLen As Integer, ByVal pszFilter As
Integer, ByVal UlFlags As Integer) As Integer -
To get the length of the device list. This seems to work as I get a
CR_SUCCESS (I get a number around 8500. But as I'm not sure what is in the
list I do not know if this is a valid number)

The problem arisis when I want to retrive the list itself..

MSDN:
CM_Get_Device_ID_List(
IN PCTSTR pszFilter, OPTIONAL
OUT PTCHAR Buffer,
IN ULONG BufferLen,
IN ULONG ulFlags
);

I can't get this to work, neighter the declaration or the call of the
function :( I have tried everything I know (and could find on the net) but
it all crashses or give no information.
To the best of my knowledge there are no thing like pointers in vb and as I
read this, it gives you a pointer..?!?

Anyone out there thet can show how to retrive the list or an example that
explains the workings of functions like this?

Hope someone out there can help.

Thanks
Henning
------------------------------------------------------------FULL MSDN
INFORMATION----------------------------------------------------------------------
-------http://msdn.microsoft.com/library/default.asp?url=/library/en-us/DevInst_r/hh/DevInst_r/cfgmgrfn_e9f614d2-9bac-4b30-b9a0-f0764e37950b.xml.asp------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

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.
Apr 7 '06 #1
4 3320
The recommended way to pass string buffers when using P/Invoke is to use a
StringBuilder object
Something like this should work (watch out for line breaks)

Declare Auto Function CM_Get_Device_ID_List_Size Lib "cfgmgr32.dll" Alias
(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 ' TODO: Initialize
Dim flags As Integer ' TODO: Initialize
Dim len As Integer
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)
/claes

"Henning M" <he*****@fys.ku.dk> wrote in message
news:38***************************@news.arrownet.d k...
Hej All

Im relativ new to VB.net and im trying to collect som device information
using cfgmgr32.dll

I use - Declare Function GetListLength Lib "cfgmgr32.dll" Alias
"CM_Get_Device_ID_List_SizeA" (ByRef pulLen As Integer, ByVal pszFilter As
Integer, ByVal UlFlags As Integer) As Integer -
To get the length of the device list. This seems to work as I get a
CR_SUCCESS (I get a number around 8500. But as I'm not sure what is in the
list I do not know if this is a valid number)

The problem arisis when I want to retrive the list itself..

MSDN:
CM_Get_Device_ID_List(
IN PCTSTR pszFilter, OPTIONAL
OUT PTCHAR Buffer,
IN ULONG BufferLen,
IN ULONG ulFlags
);

I can't get this to work, neighter the declaration or the call of the
function :( I have tried everything I know (and could find on the net) but
it all crashses or give no information.
To the best of my knowledge there are no thing like pointers in vb and as
I read this, it gives you a pointer..?!?

Anyone out there thet can show how to retrive the list or an example that
explains the workings of functions like this?

Hope someone out there can help.

Thanks
Henning
------------------------------------------------------------FULL MSDN
INFORMATION----------------------------------------------------------------------
-------http://msdn.microsoft.com/library/default.asp?url=/library/en-us/DevInst_r/hh/DevInst_r/cfgmgrfn_e9f614d2-9bac-4b30-b9a0-f0764e37950b.xml.asp------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

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.

Apr 7 '06 #2
Thanks a lot, this works if I only need the first item in the list.
The stringbuilder only reads till the first NULL value.

Is it possible to configure the StringBuilder to use a double NULL value as
string termination.
I found nothing of the kind in the list of StringBuilder Members :(

Are there any other way of manually cyclinging trough the list?

/Henning

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
The recommended way to pass string buffers when using P/Invoke is to use a
StringBuilder object
Something like this should work (watch out for line breaks)

Declare Auto Function CM_Get_Device_ID_List_Size Lib "cfgmgr32.dll" Alias
(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 ' TODO: Initialize
Dim flags As Integer ' TODO: Initialize
Dim len As Integer
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)
/claes

"Henning M" <he*****@fys.ku.dk> wrote in message
news:38***************************@news.arrownet.d k...
Hej All

Im relativ new to VB.net and im trying to collect som device information
using cfgmgr32.dll

I use - Declare Function GetListLength Lib "cfgmgr32.dll" Alias
"CM_Get_Device_ID_List_SizeA" (ByRef pulLen As Integer, ByVal pszFilter
As Integer, ByVal UlFlags As Integer) As Integer -
To get the length of the device list. This seems to work as I get a
CR_SUCCESS (I get a number around 8500. But as I'm not sure what is in
the list I do not know if this is a valid number)

The problem arisis when I want to retrive the list itself..

MSDN:
CM_Get_Device_ID_List(
IN PCTSTR pszFilter, OPTIONAL
OUT PTCHAR Buffer,
IN ULONG BufferLen,
IN ULONG ulFlags
);

I can't get this to work, neighter the declaration or the call of the
function :( I have tried everything I know (and could find on the net)
but it all crashses or give no information.
To the best of my knowledge there are no thing like pointers in vb and as
I read this, it gives you a pointer..?!?

Anyone out there thet can show how to retrive the list or an example that
explains the workings of functions like this?

Hope someone out there can help.

Thanks
Henning
------------------------------------------------------------FULL MSDN
INFORMATION----------------------------------------------------------------------
-------http://msdn.microsoft.com/library/default.asp?url=/library/en-us/DevInst_r/hh/DevInst_r/cfgmgrfn_e9f614d2-9bac-4b30-b9a0-f0764e37950b.xml.asp------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

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.


Apr 7 '06 #3
The StringBuilder should handle embedded nulls just fine, but the debugger
might not show the correct result.
How are you checking the returned value?

/claes

"Henning M" <he*****@fys.ku.dk> wrote in message
news:cd**************************@news.arrownet.dk ...
Thanks a lot, this works if I only need the first item in the list.
The stringbuilder only reads till the first NULL value.

Is it possible to configure the StringBuilder to use a double NULL value
as string termination.
I found nothing of the kind in the list of StringBuilder Members :(

Are there any other way of manually cyclinging trough the list?

/Henning

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
The recommended way to pass string buffers when using P/Invoke is to use
a StringBuilder object
Something like this should work (watch out for line breaks)

Declare Auto Function CM_Get_Device_ID_List_Size Lib "cfgmgr32.dll" Alias
(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 ' TODO: Initialize
Dim flags As Integer ' TODO: Initialize
Dim len As Integer
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)
/claes

"Henning M" <he*****@fys.ku.dk> wrote in message
news:38***************************@news.arrownet.d k...
Hej All

Im relativ new to VB.net and im trying to collect som device information
using cfgmgr32.dll

I use - Declare Function GetListLength Lib "cfgmgr32.dll" Alias
"CM_Get_Device_ID_List_SizeA" (ByRef pulLen As Integer, ByVal pszFilter
As Integer, ByVal UlFlags As Integer) As Integer -
To get the length of the device list. This seems to work as I get a
CR_SUCCESS (I get a number around 8500. But as I'm not sure what is in
the list I do not know if this is a valid number)

The problem arisis when I want to retrive the list itself..

MSDN:
CM_Get_Device_ID_List(
IN PCTSTR pszFilter, OPTIONAL
OUT PTCHAR Buffer,
IN ULONG BufferLen,
IN ULONG ulFlags
);

I can't get this to work, neighter the declaration or the call of the
function :( I have tried everything I know (and could find on the net)
but it all crashses or give no information.
To the best of my knowledge there are no thing like pointers in vb and
as I read this, it gives you a pointer..?!?

Anyone out there thet can show how to retrive the list or an example
that explains the workings of functions like this?

Hope someone out there can help.

Thanks
Henning
------------------------------------------------------------FULL MSDN
INFORMATION----------------------------------------------------------------------
-------http://msdn.microsoft.com/library/default.asp?url=/library/en-us/DevInst_r/hh/DevInst_r/cfgmgrfn_e9f614d2-9bac-4b30-b9a0-f0764e37950b.xml.asp------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

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.



Apr 10 '06 #4
Hi again,

The problem was solved using a char array instead of a stringbuilder.

Thanks for your feedback

/Henning
"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:Oi**************@TK2MSFTNGP04.phx.gbl...
The StringBuilder should handle embedded nulls just fine, but the debugger
might not show the correct result.
How are you checking the returned value?

/claes

"Henning M" <he*****@fys.ku.dk> wrote in message
news:cd**************************@news.arrownet.dk ...
Thanks a lot, this works if I only need the first item in the list.
The stringbuilder only reads till the first NULL value.

Is it possible to configure the StringBuilder to use a double NULL value
as string termination.
I found nothing of the kind in the list of StringBuilder Members :(

Are there any other way of manually cyclinging trough the list?

/Henning

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
The recommended way to pass string buffers when using P/Invoke is to use
a StringBuilder object
Something like this should work (watch out for line breaks)

Declare Auto Function CM_Get_Device_ID_List_Size Lib "cfgmgr32.dll"
Alias (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 ' TODO: Initialize
Dim flags As Integer ' TODO: Initialize
Dim len As Integer
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)
/claes

"Henning M" <he*****@fys.ku.dk> wrote in message
news:38***************************@news.arrownet.d k...
Hej All

Im relativ new to VB.net and im trying to collect som device
information using cfgmgr32.dll

I use - Declare Function GetListLength Lib "cfgmgr32.dll" Alias
"CM_Get_Device_ID_List_SizeA" (ByRef pulLen As Integer, ByVal pszFilter
As Integer, ByVal UlFlags As Integer) As Integer -
To get the length of the device list. This seems to work as I get a
CR_SUCCESS (I get a number around 8500. But as I'm not sure what is in
the list I do not know if this is a valid number)

The problem arisis when I want to retrive the list itself..

MSDN:
CM_Get_Device_ID_List(
IN PCTSTR pszFilter, OPTIONAL
OUT PTCHAR Buffer,
IN ULONG BufferLen,
IN ULONG ulFlags
);

I can't get this to work, neighter the declaration or the call of the
function :( I have tried everything I know (and could find on the net)
but it all crashses or give no information.
To the best of my knowledge there are no thing like pointers in vb and
as I read this, it gives you a pointer..?!?

Anyone out there thet can show how to retrive the list or an example
that explains the workings of functions like this?

Hope someone out there can help.

Thanks
Henning
------------------------------------------------------------FULL MSDN
INFORMATION----------------------------------------------------------------------
-------http://msdn.microsoft.com/library/default.asp?url=/library/en-us/DevInst_r/hh/DevInst_r/cfgmgrfn_e9f614d2-9bac-4b30-b9a0-f0764e37950b.xml.asp------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

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.



Apr 11 '06 #5

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

Similar topics

5
by: Andrew Slade | last post by:
Hello, I am making calls from one compilation unit to functions in another by pointers and I get the warnings below from gcc on 2.4.x Debian Linux. The executable seems to work fine but the...
19
by: Ross A. Finlayson | last post by:
Hi, I hope you can help me understand the varargs facility. Say I am programming in ISO C including stdarg.h and I declare a function as so: void log_printf(const char* logfilename, const...
1
by: H.B. | last post by:
Hi, I need to make a function that can display data on my Managed C++ app and be called by an unmanaged C++ DLL. Something like : void Form1::Form1_Load(System::Object * sender,...
23
by: Timothy Madden | last post by:
Hello all. I program C++ since a lot of time now and I still don't know this simple thing: what's the problem with local functions so they are not part of C++ ? There surely are many people...
4
by: msolem | last post by:
I have some code where there are a set of functions that return pointers to each other. I'm having a bit of a hard time figuring out the correct type to use to do that. The code below works but...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
2
by: ramasubramanian.rahul | last post by:
hi i am trying to call some java APIs from c . i use the standatd JNI calls to load the JVM from a c program and call all java functions by using a pointer to the jvm which was returned by the JNI...
9
by: flopbucket | last post by:
Hi, Say I have a baseclass B that has many derived classes, let's say C..Z, for example: class B { }; class C : public B {};
13
by: JohnQ | last post by:
The implementation of classes with virtual functions is conceptually easy to understand: they use vtables. Which begs the question about POD structs: how are they associated with their member...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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.