c# - How to install USB driver after the installing of software -


i want install (or @ least, prepairing installing of) usb driver after software installed on client computer.

i have small program, written in c# in visual studio 2008, , can install program using standard feature in vs2008. program talks hardware device via usb cable. usb driver came ftdi , can installed when user plugs in usb socket. works fine, want file copied during installation of software. once done, show message on screen e.g. "please plug in usb cable in socket , click ok continue", on installing of driver automatically carried out moment. (the same when install software new printer).

please advice how can it. , it's great if can me start examples.

great thanks, henry.

this works:

// szinfdirectory directory on hard drive installer copied driver files to.  tchar szinfpath[max_path];  _tcscpy( szinfpath, szinfdirectory ); _tcscat( szinfpath, _t("yourdriver.inf") );  tchar szdestinationinffilename[max_path];  if( (!setupcopyoeminf( szinfpath, szinfdirectory, spost_path, 0, szdestinationinffilename, max_path, null, null )) ) {   nresult = err_copyinf_failed;   return; }  lpctstr hardwareids[] =  {   _t("usb\\vid_123f&pid_0444"),    _t("usb\\vid_123f&pid_0555"),  }; const size_t cbmax = sizeof(hardwareids) / sizeof(*hardwareids);      bool finnerloopfailed = false; for( size_t cb=0; (cb<cbmax) && (!finnerloopfailed); cb++ ) {   bool brebootreqtemp = false;   if( (!updatedriverforplugandplaydevices( null, hardwareids[cb], szinfpath, installflag_force, &brebootreqtemp )) )   {     if( error_no_such_devinst == getlasterror() )     {       // nothing do: device not present     }     else     {       nresult = err_update_driver_failed;       finnerloopfailed = true;       break;     }   } }  if( finnerloopfailed ) {     // error     return; }  // success 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -