есть драйвер и inf-файл. хочу написать программу для установки этого драйвера через inf-файл. как это сделать?
Код (Text): #define APP_NAME _T("xxxxx") DWORD GetServiceInfFilePath( LPTSTR lpFilename, DWORD nSize ) { // Get Path to This Module DWORD nResult; TCHAR szDrive[ _MAX_DRIVE ]; TCHAR szDir[ _MAX_DIR ]; nResult = GetModuleFileName( NULL, lpFilename, nSize ); if( nResult == 0 ) { return 0; } _tsplitpath( lpFilename, szDrive, szDir, NULL, NULL ); _tmakepath( lpFilename, szDrive, szDir, NDISPROT_SERVICE_INF_FILE, _T(".inf") ); return (DWORD )_tcslen( lpFilename ); } // // Function: InstallSpecifiedComponent // // Purpose: Install a network component from an INF file. // // Arguments: // lpszInfFile [in] INF file. // lpszPnpID [in] PnpID of the network component to install. // pguidClass [in] Class GUID of the network component. // // Returns: None. // // Notes: // HRESULT InstallSpecifiedComponent( LPTSTR lpszInfFile, LPTSTR lpszPnpID, const GUID *pguidClass ) { INetCfg *pnc; LPTSTR lpszApp; HRESULT hr; hr = (HRESULT) HrGetINetCfg( TRUE, APP_NAME, &pnc, &lpszApp ); if ( hr == S_OK ) { // // Install the network component. // hr = (HRESULT) HrInstallNetComponent( pnc, lpszPnpID, pguidClass, lpszInfFile ); if ( (hr == S_OK) || (hr == NETCFG_S_REBOOT) ) { hr = pnc->Apply(); } else { if ( hr != HRESULT_FROM_WIN32(ERROR_CANCELLED) ) { MessageBox(NULL, L"Couldn't install the network component!", L"Install Error:", MB_OK); } } HrReleaseINetCfg( pnc, TRUE ); } else { if ( (hr == NETCFG_E_NO_WRITE_LOCK) && lpszApp ) { MessageBox(NULL, L"Application currently holds the lock, try later!", L"Install Error:", MB_OK); CoTaskMemFree( lpszApp ); } else { MessageBox(NULL, L"Couldn't the get notify object interface!", L"Install Error:", MB_OK); } } return hr; } DWORD InstallDriver() { DWORD nResult; // Get Path to Service INF File // ---------------------------- // The INF file is assumed to be in the same folder as this application... TCHAR szFileFullPath[ _MAX_PATH ]; nResult = GetServiceInfFilePath( szFileFullPath, MAX_PATH ); if( nResult == 0 ) { MessageBox(NULL, L"Unable to get INF file path!", L"Install Error:", MB_OK); return 0; } HRESULT hr=S_OK; hr = InstallSpecifiedComponent( szFileFullPath, NDISPROT_SERVICE_PNP_DEVICE_ID, &GUID_DEVCLASS_NETTRANS ); if( hr != S_OK ) { MessageBox(NULL, L"Failed to install NDIS driver!", L"Install Error:", MB_OK); return 0; } return 1; }