问题
I am trying to write C++ code programmatically installing NDIS 6.0 lightweight filter driver. After reviewing WinDDK, online examples and MSDN documentation I ended up with the code sample below.
**************
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.
The path using INetCfgClassSetup::Install does not work.
It is taking the default path in the Have Disk Browse Options
eg: my inf file path is C:\Users\Mani\Desktop\sagar\objchk_win7_x86\i386\netlwf.inf
but it is asking for the default path(1st entry) in have disk menu
d:\softwares\filter_driver
similar to the image ==> http://i.stack.imgur.com/tmyMX.png
It is always asking for the same sys file.
Is anything was missing ?
回答1:
Your question is over a year old, and I hope that you have found the solution. For the sake of developers facing same problem, I posting this answer.
Start with ProtInstall project at ndis.com
http://www.ndis.com/ndis-general/ndisinstall/programinstall.htm
you might need to make some changes : include the header files, libraries; and some debugging.
Other than that, this project works and I have successfully installed and uninstalled ndislwf 6.0 sample project via this.
来源:https://stackoverflow.com/questions/22173170/installing-the-filter-driver-programmatically