My EMX board is connected to a computer, it shows various data through a GUI written in C#. The connection between the board and the computer is the CDC_Driver provided byy GHI. The main problem, is that I would like to include the device driver in my GUI in such a way that if the driver is not install, the GUI will propose to install it. I am using click once to publish my application.
For now I have a look on the DIFXApi.
[DllImport("DIFXApi.dll", CharSet = CharSet.Unicode)]
public static extern Int32 DriverPackagePreinstall(string DriverPackageInfPath, Int32 Flags);
static void driverinstall()
{
DirectoryInfo assemblyDir = new DirectoryInfo(Application.ExecutablePath);
DirectoryInfo installDir = assemblyDir.Parent;
int result = DriverPackagePreinstall(installDir.FullName + @ "..\\Driver\\CDC_Driver.inf", 0);
if (result != 0)
MessageBox.Show("Driver installation failed. " + result);
}
but this returns the error 3 (invalid path). If I run
int result = DriverPackagePreinstall(@ "C:\Driver\CDC_Driver.inf", 0);
I get ACCESS_DENIED
I have also see the SetupCopyOEMInf method but I don’t know how to import the setup.dll and where to find it.
At least I have no errors but I am not sure if it works. If I uninstall the driver in Windows peripherals manager and unplug/ plug the EMX board it still succeed to find the correct driver
In fact the driver was still present on the system. After deleting the driver properly using the device manager, it does not find it anymore.
Unfortunately the InstallHinfSection seems to not install the driver. But it does not print errors.
Driver PackageInstall returns 5 with a correct path and 2 with a uncorrect one. Where can I found the error corresponding to 5. The c++ msdn doc on it specifies return code as DWORD…
I’ve just tried from the gui app, app starts but when I plug the emx it still ask for the cdc Vcom driver. Therefore it has not been added to the driverstore… Windows is not an easy os to know what can be wrong.