新微赢技术网
标题:
C++ 以服务形式加载驱动的问题!急切!!!
[打印本页]
作者:
天山花芯
时间:
2009-11-4 01:21
标题:
C++ 以服务形式加载驱动的问题!急切!!!
代码核心如下:
BOOL LoadDriver( IN LPCTSTR lpFileName )
{
HANDLE hDevice=0;
SC_HANDLE hSCManager = OpenSCManager( NULL, NULL,SC_MANAGER_CREATE_SERVICE );
if ( NULL != hSCManager )
{
SC_HANDLE hService = CreateService( hSCManager, SERVICE_NAME,
SERVICE_NAME, SERVICE_START,
SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START,
SERVICE_ERROR_IGNORE, lpFileName, NULL, NULL, NULL, NULL, NULL );
if ( ERROR_SERVICE_EXISTS == GetLastError() )
{
hService = OpenService( hSCManager, SERVICE_NAME, SERVICE_START );
}
if(!StartService( hService, 0, NULL ))
{
cout<<"StartService Error!\n";
return false;
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2