Search code examples
c++visual-studioprintingdriverwdk

V4 printer driver not listed after installing using INF file


I followed this Microsoft tutorial, for developing a V4 printer driver.

Here is the full working solution.

And for installing I simply right clicked the INF file and clicked on install.

I get the following confirmation: enter image description here

But the driver does not list under Print Management.

What could be the problem? Am I doing the installation in a wrong way or is there a problem with the code.

I tried adding logging to file to all the functions in the driver source code. And none seems to be written. So the driver has not installed itself.

FYI: I have put the PC to test signing mode and Driver Signature Enforcement is also disabled.


Solution

  • After a lot of digging, I found the solution. I am sharing this so that people who face similar problem can save a lot of effort.

    First thing. In device driver installation, there are two things which are happening.

    1. The driver files gets uploaded/copied to the driver store (which is to here: %windir%\System32\DriverStore\FileRepository\
    2. When the corresponding device is plugged in, now is when the actual installation takes place. The corresponding device meaning the device/model you specify in the INF file.

    This is the traditional path.

    So when you try to install using the INF file, the driver files get uploaded to the file repository of driver store. I think if any of the supported models is plugged in during the INF installation, the driver would install completely (haven't tested it).

    Installation. Now my requirement demands the driver be installed and listed priorly. For this, you can explicitly install it using the function InstallPrinterDriverFromPackage function. Here is an example using it:

    HRESULT Install(LPCTSTR pszInfPath)
    {
        HRESULT ret = InstallPrinterDriverFromPackage(
            NULL,
            pszInfPath, //path of the INF file in the Driver Store
            L"MyV4PrintDriver", //the name of the driver as in the INF file
            //L"Windows NT x86", 32 bit environment
            L"Windows x64",
            0); 
    
        if ( ret != S_OK )
        {
            _com_error err(ret);
            LPCTSTR errMsg = err.ErrorMessage();
            wcout << errMsg << endl;
        }
        return ret;
    }
    

    More. You can use the function UploadPrinterDriverPackage function to upload the printer driver files to the driver store.