Discussion:
Installing a driver (.INF file) from code
(too old to reply)
MySelf
2011-04-13 13:05:44 UTC
Permalink
Hello,

I need to install a driver for a smart card reader directly from the C#
code of my application, but all I got from the manufacturer of the
reader is a driver made of two files : a .INF file and a .CAT file.

I tried to install the driver by right-clicking on the .INF file, but I
got a message error saying that this .INF file does not support this
way of installing.

On the web, I found this command line :

C:\WINDOWS\System32\rundll32.exe setupapi,InstallHinfSection
DefaultInstall 132 yourfile.inf

but when trying it, I got a message saying that InstallInfSection was
not provided.

So my question is How can I install such a .INF file from C# code,
without asking the user for an action ?

Thank you for your help.
Peter Duniho
2011-04-13 14:19:43 UTC
Permalink
Post by MySelf
Hello,
I need to install a driver for a smart card reader directly from the C#
code of my application, but all I got from the manufacturer of the
reader is a driver made of two files : a .INF file and a .CAT file.
I tried to install the driver by right-clicking on the .INF file, but I
got a message error saying that this .INF file does not support this way
of installing.
If you can't get the install to work from the GUI, why do you expect it
to work from code?
Post by MySelf
C:\WINDOWS\System32\rundll32.exe setupapi,InstallHinfSection
DefaultInstall 132 yourfile.inf
but when trying it, I got a message saying that InstallInfSection was
not provided.
Which is probably the same reason it doesn't work from the GUI.
Post by MySelf
So my question is How can I install such a .INF file from C# code,
without asking the user for an action ?
It seems to me that your question really has nothing to do with C#.
Most likely, you need an answer from the manufacturer to explain how
they expect you to use the files they gave you to install the driver.
Once you know how the installation is supposed to work generally, then
you can work on how to accomplish it programmatically.

Pete
Peter Duniho
2011-04-13 14:37:17 UTC
Permalink
(sorry if this is a duplicate…my newsgroup burped and it appears to me
that the first attempt to send failed)
Post by MySelf
Hello,
I need to install a driver for a smart card reader directly from the C#
code of my application, but all I got from the manufacturer of the
reader is a driver made of two files : a .INF file and a .CAT file.
I tried to install the driver by right-clicking on the .INF file, but I
got a message error saying that this .INF file does not support this way
of installing.
If you can't get the install to work from the GUI, why do you expect it
to work from code?
Post by MySelf
C:\WINDOWS\System32\rundll32.exe setupapi,InstallHinfSection
DefaultInstall 132 yourfile.inf
but when trying it, I got a message saying that InstallInfSection was
not provided.
Which is probably the same reason it doesn't work from the GUI.
Post by MySelf
So my question is How can I install such a .INF file from C# code,
without asking the user for an action ?
It seems to me that your question really has nothing to do with C#. Most
likely, you need an answer from the manufacturer to explain how they
expect you to use the files they gave you to install the driver. Once
you know how the installation is supposed to work generally, then you
can work on how to accomplish it programmatically.

Pete
MySelf
2011-04-13 15:22:39 UTC
Permalink
If you can't get the install to work from the GUI, why do you expect it to
work from code?
The error message said "INF file does not support THIS way of
installing". I supposed there it exist were some other ways to install
this kind of files.
NumbLock
2011-04-13 15:56:54 UTC
Permalink
Hello MySelf,
It sounds like you are trying to install just an INF. The right-click INF
install feature only works for windows features, not devices. Since you
only have the INF, there is no GUI setup to fail. A Device Driver INF is
installed through Device Manager. You need to find a way to interact with
device manager from code. Probably a rundll command or something. Here
is a link to an article about what you are trying to do. It is not specific
to C#.

http://www.techtalkz.com/microsoft-device-drivers/245175-installing-driver-using-rundll32.html

Best of luck.

---
Regards,
NumbLock

--------
There are only 10 kinds of people in the world. Those who understand binary
and those who don't
Post by MySelf
Post by Peter Duniho
If you can't get the install to work from the GUI, why do you expect
it to work from code?
The error message said "INF file does not support THIS way of
installing". I supposed there it exist were some other ways to install
this kind of files.
MySelf
2011-04-13 16:02:58 UTC
Permalink
Post by NumbLock
Hello MySelf,
It sounds like you are trying to install just an INF. The right-click INF
install feature only works for windows features, not devices. Since you only
have the INF, there is no GUI setup to fail. A Device Driver INF is
installed through Device Manager. You need to find a way to interact with
device manager from code. Probably a rundll command or something. Here is a
link to an article about what you are trying to do. It is not specific to
C#.
http://www.techtalkz.com/microsoft-device-drivers/245175-installing-driver-using-rundll32.html
Best of luck.
Thank you for your help. In fact, I already tried to use RunDLL as said
in my previous post, but with no success.

We finally found a way to solve the problem by using a DPInst.exe
program available from Microsoft, that was able to install the driver.

I agree it is not a C# specific problem, sorry for posting in the wrong
channel.
NumbLock
2011-04-13 16:43:53 UTC
Permalink
Hello MySelf,
No Prob. I wasn't complaining I was just noting that the link I referred
you to was not C# specific...

---
Regards,
NumbLock

--------
There are only 10 kinds of people in the world. Those who understand binary
and those who don't
Post by MySelf
Post by NumbLock
Hello MySelf,
It sounds like you are trying to install just an INF. The
right-click INF
install feature only works for windows features, not devices. Since you only
have the INF, there is no GUI setup to fail. A Device Driver INF is
installed through Device Manager. You need to find a way to interact with
device manager from code. Probably a rundll command or something.
Here is a
link to an article about what you are trying to do. It is not specific to
C#.
http://www.techtalkz.com/microsoft-device-drivers/245175-installing-d
river-using-rundll32.html
Best of luck.
Thank you for your help. In fact, I already tried to use RunDLL as
said in my previous post, but with no success.
We finally found a way to solve the problem by using a DPInst.exe
program available from Microsoft, that was able to install the driver.
I agree it is not a C# specific problem, sorry for posting in the
wrong channel.
Loading...