Listing 2: infcopy.cpp Avoiding the Add New Hardware Wizard
// infcopy.cpp : // // This program takes a single argument: the absolute path to an // .inf file that is to be "registered" with the O.S. device // database. Executing this program makes the O.S. aware of the // .inf file and all the devices it supports, just as if it had // been installed using the Add New Hardware Wizard. // #include <stdio.h> #include <windows.h> #include <setupapi.h> int main(int argc, char* argv[]) { if (argc < 2) { printf("aborting because arg count too small\n"); return -1; } // helps during installer debugging printf("Copying %s",argv[1]); BOOL result; result = SetupCopyOEMInf(argv[1],NULL,SPOST_PATH, \ SP_COPY_NOOVERWRITE,NULL,0l,NULL,NULL); if (result) printf("true\n"); // helps during installer debugging else printf("false\n"); return result; } // End of File