2014-03-04 74 views
2

我正在嘗試編寫以編程方式安裝NDIS 6.0輕量級篩選器驅動程序的C++代碼。在回顧了WinDDK,在線示例和MSDN文檔後,我最終得到了下面的代碼示例。以編程方式安裝篩選器驅動程序?

************** 
hr = InstallSpecifiedComponent(
     ModuleFileName, 
     L"MS_NdisLwf", 
     &GUID_DEVCLASS_NETSERVICE 
     ); 
************** 

hr = HrInstallNetComponent( 
     pnc, 
     lpszPnpID, 
     pguidClass, 
     lpszInfFile  
     ); 
************** 
    if (!SetupCopyOEMInfW(lpszInfFullPath, 
         DirWithDrive, // Other files are in the same dir.as primary INF 
          SPOST_PATH, // SPOST_NONE, //First param is path to INF 
          0,    // Default copy style 
          NULL,// Name of the INF after it's copied to %windir%\inf 
          0,   // Max buf. size for the above 
          NULL,   // Required size if non-null 
          NULL) // Optionally get the filename part of Inf name 
           after it is copied. 
         ) 
     { 
      ---- 
     } 

***************  
hr = HrInstallComponent(pnc, 
          lpszComponentId, 
          pguidClass); 

*************** 

hr = pnc->QueryNetCfgClass (pguidClass, 
         IID_INetCfgClassSetup, 
         (void**)&pncClassSetup);       

if (hr == S_OK) { 

wprintf(L"\n No Test\n"); 

hr = pncClassSetup->Install(szComponentId, 
          &OboToken, 
          0, 
          0,  // Upgrade from build number. 
          NULL, // Answerfile name 
          NULL, // Answerfile section name 
          &pncc); // Reference after the component   
if (S_OK == hr) { ... }     // is installed. 

使用INetCfgClassSetup :: Install的路徑不起作用。

它走在從磁盤安裝瀏覽選項中的默認路徑

例如:我的INF文件路徑爲C:\用戶\瑪尼\桌面\薩加爾\ objchk_win7_x86 \ I386 \ netlwf.inf

但它要求在有盤菜單

d默認路徑(第1項):\ \軟件filter_driver

類似於圖像==>http://i.stack.imgur.com/tmyMX.png

它總是要求相同的sys文件。

有什麼遺漏了嗎?

+0

你也可以分享INF嗎? –

+0

請查看鏈接 我的inf文件在性質上幾乎相似 [INF_FILE](http://weppinhole.googlecode.com/svn/trunk/WifiCaptureService/netlwf.inf) – arya2arya

回答

1

你的問題已經過了一年多了,我希望你找到了解決方案。爲了開發者面臨同樣的問題,我發佈了這個答案。在ndis.com

http://www.ndis.com/ndis-general/ndisinstall/programinstall.htm

開始ProtInstall項目

你可能需要作出一些改變:包括頭文件,庫;和一些調試。

除此之外,這個項目的工作原理和我已經成功安裝和卸載ndislwf 6.0樣本項目通過這個。