RE: loading a driver [revised]

Rajeev,

In your call to CreateService, make sure that the entire path to your
driver binary is specified in lpBinaryPathName. If there are any
spaces, make sure that the string is quoted.

CreateService only creates the service entry; it does not load the
driver. Once the service is created, you can use StartService.

The typical sequence is:

Try to open the driver with CreateFile:

– CreateFile( “\\.\MyDriver”, …, …, …, );

If the returned handle is INVALID_HANDLE_VALUE and GetLastError() ==
ERROR_FILE_NOT_FOUND:

– Call OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS )
– Call CreateService( hSCManager, “MyDriver”, “MyDriver”, …, …, )
– Call OpenService( hSCManager, “MyDriver”, SERVICE_ALL_ACCESS )
– Call StartService( hService, 0, NULL )
– Call CloseServiceHandle( hService )
– Call CloseServiceHandle( hSCManager )

Try to open the driver again via CreateFile( \\.\MyDriver, …, … )

You only have to create the service once. You can probably skip that
step and go to Open Service. If that fails, backup and create it and
retry opening the service.

Bryan S. Burgin
xxxxx@microsoft.com

This posting is provided “AS IS” with no warranties, and confers no
rights

-----Original Message-----
From: Rajeev Rao [mailto:xxxxx@hotmail.com]
Sent: Tuesday, March 26, 2002 12:46 AM
To: NT Developers Interest List
Subject: [ntdev] loading a driver [revised]

Hi, I’m trying to load a simple driver using the win32 CreateService
routine. However I keep getting an error (error = 2); can i choose an
arbitrary driver name? I’ve already checked and ensured correct path,
yet i
cannot explain the errorcode. (obtained from GetLastError() .

Rajeev


MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx


You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to %%email.unsub%%