I get this error while trying to add a printer driver.
The operation was canceled by the user. (Exception from HRESULT: 0x800704C7)
Am i doing something wrong here?
Public Function AddDriver(ByVal DriverName As String, ByVal InfFile As String) As Boolean
Try
Dim PRNADMIN As New PRNADMINLib.PrintMaster
Dim Drv As New PRNADMINLib.Driver
Drv.ModelName = DriverName
Drv.InfFile = InfFile
PRNADMIN.DriverAdd(Drv)
Return True
Catch ex As Exception
MessageBox.Show(ex.Message, frmMain.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Return False
End Try
End Function
Here comes the c# version
public bool AddDriver(string DriverName, string InfFile)
{
try {
PRNADMINLib.PrintMaster PRNADMIN = new PRNADMINLib.PrintMaster();
PRNADMINLib.Driver Drv = new PRNADMINLib.Driver();
Drv.ModelName = DriverName;
Drv.InfFile = InfFile;
PRNADMIN.DriverAdd(Drv);
return true;
} catch (Exception ex) {
MessageBox.Show(ex.Message, frmMain.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return false;
}
}
UPDATE:
The application requests administration rights in app.manifest (requestedExecutionLevel level="requireAdministrator")
I get the same error with UAC On or even OFF.
The driver is not digitally signed
If i install the driver manually i get the windows security warning, with "Don't install this driver software" as the default option (And unfortunately, do not get that Message while running the code above).