以编程方式安装筛选驱动程序?

我正在尝试编写以编程方式安装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的path不起作用。

它将采用“从磁盘安装”浏览选项中的默认path

例如:我的inf文件path是C:\ Users \ Mani \ Desktop \ sagar \ objchk_win7_x86 \ i386 \ netlwf.inf

但它是要求在默认path(第一条目)有磁盘菜单

d:\软件\ filter_driver

类似于图像==> http://img.zgserver.com/windows/tmyMX.png

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

有什么遗漏?

你的问题已经过了一年多了,我希望你已经找到了解决办法。 为了开发者面临同样的问题,我张贴这个答案。

从ndis.com的ProtInstall项目开始

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

您可能需要进行一些更改:包括头文件,库; 和一些调试。

除此之外,这个项目的工作,我已经通过这个成功安装和卸载ndislwf 6.0示例项目。