title: Installing a driver programmatically using INF file c++
body: <p>Could someone here please let me know how to install 3rd party device drivers 
  programmatically if all the required files i.e. inf file, .sys etc are provided. The
  minimum operating system this solution SHOULD work on is Windows2000.</p>
  
  <p>I tried copying the <code>.inf</code> file into the Win Folder\INF folder and the sys file
  into the Win folder\system32\drivers but each time plug in the device, windows
  pops up Found New Hardware user interface which is what i am trying to avoid.</p>
  
  <p>Below is something i tried but the function returns <code>error 87 (The parameter is incorrect)</code>.</p>
  
  <pre><code>HINF HInf;                
  UINT ErrorLine;            
  BOOL bRes = FALSE;
  PBOOL FileWasInUse = FALSE;
  
  LPCSTR szSourceFileName = _T("C:\\Drivers_HypercomP1320\\hypvcpusb.inf");
  LPCSTR szInfFileName  = _T("hypvcpusb.inf");
  PVOID Context = NULL;
  
  HInf = SetupOpenInfFile ( szSourceFileName, NULL, INF_STYLE_WIN4, &amp;ErrorLine);          
  
  LPCSTR  SourceFile = ("hypvcp.sys");
  LPCSTR SourcePathRoot = _T("C:\\Drivers_HypercomP1320");
  LPCSTR DestinationName = _T("C:\\WINDOWS\\system32\\drivers\\hypvcp.sys");
  
  bRes = SetupInstallFileEx ( HInf, NULL, SourceFile, SourcePathRoot, DestinationName, SP_COPY_FORCE_IN_USE,
                              (PSP_FILE_CALLBACK)CopyMsgHandler, Context, FileWasInUse);   
  
  DWORD dwVal = GetLastError();
  
  SetupCloseInfFile(HInf);
  
  
  // Callback function
  UINT CopyMsgHandler (UINT Context, UINT Notification,UINT_PTR Param1, UINT_PTR Param2)
  {
      UINT rtnValue = NO_ERROR;
      return rtnValue;
  }
  </code></pre>
  
  <p>Thanks.</p>