find out device's PCI slot number programmatically

G

GoAheadTarCon

Hi all,
I'm creating an industrial customized WinXP setup. the setup works in
the cloning method - uses a ghost image on a predefined HW
configuration.
the HW configuration includes two identical intel NICs.
in order to configure each NIC's IP address & so (after the ghost
image is loaded), I need to programmatically find out in which PCI
slot each NIC is installed.
does anybody know of a way to do it?
thanx,
Ariel
 
G

Guest

----- GoAheadTarCon wrote: ----

Hi all
[...
in order to configure each NIC's IP address & so (after the ghos
image is loaded), I need to programmatically find out in which PC
slot each NIC is installed
does anybody know of a way to do it

Hi

There's probably a far neater and more elegant solution, but here's a quick-and-dirty workaround idea

If you can read the system registry (I've done it from Visual Basic, so if VB can handle it then any other language should be able to), then drill down to HKLM\System\CurrentControlSet\Enum
The NICs will be enumerated in sub-keys under there. If you know the vendor ID (e.g 8086 for Intel) and device ID (e.g 2449 for the Pro/100VE LAN) then you can find the appropriate key, e.g on my system
HKLM\System\CurrentControlSet\VEN_8086&DEV_2449&SUBSYS_30138086&REV_03 (you don't care about the &SUBSYS... bit)
Under that is another key, whose name is unfortunately, AFAIK, not predicatable, for example \4&122329e2&0&40F0 on my system here. As it's the only key under the VEN_ one, though, some elementary registry enumeration and pattern-matching should find it programatically
Under THAT key is a STRING value called LocationInformation. This contains the details of which PCI bus and slot the device is on. For example, again from my system here
LocationInformation = "PCI bus 2, device 8, function 0

You could parse that to get the information you need

Does this help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top