[Winpcap-users] Distribute Winpcap Files with my app

ZhiyuHe sanhex at gmail.com
Fri Aug 5 05:13:48 GMT 2005


If your application is designed for Win2000/XP/2003,you can copy
wpcap.dll,packet.dll,wanpacket.dll (they're in %systemroot%\system32)
and put them in the directory of your application,and copy npf.sys,put
it in %systemroot%\system32\drivers,then create a service for this
driver. for example:

	SC_HANDLE scmHandle=NULL;
	SC_HANDLE srvHandle=NULL;
	LPCTSTR NPFServiceName=TEXT("NPF");
	LPCTSTR NPFServiceDesc=TEXT("Netgroup Packet Filter");
	LPCTSTR NPFDriverPath=TEXT("system32\\drivers\\npf.sys");
	char DriverPath[50];
	
	GetWindowsDirectory(DriverPath,12);
	lstrcat(DriverPath,"\\system32\\drivers\\npf.sys");
	
	if(!CopyFile("npf.sys",DriverPath,FALSE))
		return 1;
	
	scmHandle=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
	if(scmHandle) 
	{
    		srvHandle=CreateService(scmHandle,
        		NPFServiceName,
        		NPFServiceDesc,
        		SERVICE_ALL_ACCESS,
        		SERVICE_KERNEL_DRIVER,
        		SERVICE_DEMAND_START,
        		SERVICE_ERROR_NORMAL,
        		NPFDriverPath,
        		NULL,NULL,NULL,NULL,NULL);
    		if(srvHandle)
    			CloseServiceHandle(srvHandle);
    		
    		CloseServiceHandle(scmHandle);
    	}

On 8/5/05, Nick Koranda <nkk at eml.cc> wrote:
> Thanks Eric,
> 
> Do I need to "install" any device drivers?  (I see npf.sys and npf.vxd files
> in the setup.exe file).
> 
> Thanks
> Nick Koranda
>



More information about the Winpcap-users mailing list