device object name

Hi all,
?
I want to ask about naming the device object. I create a function driver for PCI card, and name the device object. I just wonder, if i have two same PCI card and using the same driver, how my application can access the device object. Because the device object name is the same. So, how should i deal with this problem?
?
Regards,
Sofian

>Because the device object name is the same

Use PnP device interfaces, or use names like Device0, Device1 etc.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

sahrizal sofian wrote:

I want to ask about naming the device object. I create a function
driver for PCI card, and name the device object. I just wonder, if i
have two same PCI card and using the same driver, how my application
can access the device object. Because the device object name is the
same. So, how should i deal with this problem?

If you try to create two devices with the same name, the second one will
fail. In the “good old days”, we kept an instance counter in a global
variable and created names like “MyDevice0”, “MyDevice1”, etc.

Today, the right way to handle this is through a device interface. It
takes more code in the application to enumerate through the list of
devices that support a single interface, but it’s a better solution in
the long term.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.