UpdateDriverForPlugAndPlayDevices error is telling me I'm *not* doing something that I am
===

I'm working on a means of installing a driver.  Because of the multiple platforms on which this must work, I'm shelling-out to both devcon and dpinst to do the work of driver install/update/removal when needed.  While testing, I'm having problems with the shelling out to devcon.  To isolate, I wrote a small app to do what devcon does in update [see here][2], using the devcon source from the WinDDK for reference.  I'm having some problems with UpdateDriverForPlugAndPlayDevices() from Setup API (actually part of Newdev.dll) [see here][1].  The source code is here:

    #include <iostream>
    #include <Windows.h>
    #include <newdev.h>

    int main(int argc, char** argv) {
        // Go through the same steps as does dev con for this update crap
        char infFile[MAX_PATH];

        if(3 > argc) {
            std::cerr << "an INF and HW ID must be specified" << std::endl;
            return 1;
        }

        DWORD result(GetFullPathName(argv[1], MAX_PATH, infFile, NULL));
        if((result >= MAX_PATH) || (0 == result)) {
            std::cerr << "path is too long for buffer" << std::endl;
            return 1;
        }

        if(GetFileAttributes(infFile) == -1) {
            std::cerr << "file doesn't exist" << std::endl;
            return 1;
	}

        BOOL reboot(FALSE);
        if(!UpdateDriverForPlugAndPlayDevices(NULL, argv[2], infFile, INSTALLFLAG_FORCE, &reboot)) {
            std::cerr << "Failed to install the driver.  Code: "
                      << GetLastError()
                      << std::endl;
            return 2;
	}

        if(reboot) {
            std::cout << "A reboot is needed to complete driver install"
                      << std::endl;
        }

        return 0;
    }

The program fails when UpdateDriverForPlugAndPlayDevices() returns false.  This then prints the error code, returned by GetLastError(), so I'd know what went wrong.  The error code returned: 259.  According to [this][3] resource says this is ERROR_NO_MORE_ITEMS.  According to the link for UpdateDriverForPlugAndPlayDevices(), this function returns this error code when, "The function found a match for the HardwareId value, but the specified driver was not a better match than the current driver and the caller did ***not*** specify the INSTALLFLAG_FORCE flag."  You'll notice from my code that I ***did*** specify this flag.

I do not know where to go from here.  Can someone please identify from this code what it is I'm missing?  This just has the "feel" of something simple, but I'm totally missing it.

Thank you,
Andy


  [1]: http://msdn.microsoft.com/en-us/library/ff553534%28v=vs.85%29.aspx
  [2]: http://msdn.microsoft.com/en-us/library/windows/hardware/ff544832%28v=vs.85%29.aspx
  [3]: http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382%28v=vs.85%29.aspx