Install KMDF programmatically using DiInstallDriver

时间:2016-07-11 19:23:17

标签: c++ windows-7 kmdf wdf

I want to install a kmdf driver on Windows 7 32bit machine. At first I used hdwwiz (the add hardware tool) and it worked correctly.

Now I want to install it programmatically using a software. After some research I found DiInstallDriver I used the following code

int _tmain(int argc, _TCHAR* argv[])
{
    std::wstring FilePath = L"<file name>.inf";
    bool result = DiInstallDriver(NULL, FilePath.c_str(), DIIRFLAG_FORCE_INF, false);
    DWORD error = GetLastError();
    if (!result){
        printf("The driver is not installed \r\n");
        printf("The error is %x ", error);
    }else
    {
        printf("The driver is installed correctly !");
    }

    getchar();
    return 0;
}

After running the software I get "The driver is installed correctly !", that means the functions returns with success but I cannot find it in the Device Manager?

Any idea what is going wrong ?

0 个答案:

没有答案