如何通过服务加载驱动文件?(100分)

  • 主题发起人 主题发起人 l0v3_y1n9
  • 开始时间 开始时间
L

l0v3_y1n9

Unregistered / Unconfirmed
GUEST, unregistred user!
在 Delphi Driver Development Kit v0.0.4
中用服务加载驱动的代码
#include <windows.h>
#include <stdio.h>

int main(int argc,char **argv)
{
printf("Load Driver/n");
HANDLE scm=OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE);

if(scm)
{
printf("Create Service/n");

HANDLE svc=CreateService(scm,argv[1],argv[2],SERVICE_START | DELETE | SERVICE_STOP,SERVICE_KERNEL_DRIVER,
SERVICE_DEMAND_START,SERVICE_ERROR_IGNORE,argv[3],NULL,NULL,NULL,NULL,NULL);

if(!svc) svc=OpenService(scm,argv[1],SERVICE_START | DELETE | SERVICE_STOP);

if(svc)
{
printf("Starting service/n");

StartService(svc,0,NULL);

printf("Press Enter to stop and delete service /n");
getchar();

SERVICE_STATUS status;
ControlService(svc,SERVICE_CONTROL_STOP,&status);

DeleteService(svc);
CloseServiceHandle(svc);
} else printf("error: unable to create/open service/n");

CloseServiceHandle(scm);
} else printf("error: unable to open manager/n");

return 0;
}
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2837909
 
后退
顶部