500分求XP下动态加载WDM硬件设备驱动代码 新写了硬件设备驱动,有现成的INF和SYS文件,可以用控制面板系统设备添加并正常使用。但用网络上给出的编程动态添加总是不能正确加载。怎么办好?急求啊。答案正确给满100后继续开一加分帖给满另外400分。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.codeproject.com/system/tdriver.asp char *p; ::GetFullPathName("CPNDriver.sys",256,szDriverPath,&p); if(notifying==false) { hSCM = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS); if(hSCM==NULL) { ShowMessage("打开服务控制管理器失败."); notifying = false; Button1->Enabled = true; Button2->Enabled = false; Button3->Enabled = true; return; } hService = CreateService(hSCM,szLinkName,szLinkName,SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER,SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,szDriverPath, NULL,0,NULL,NULL,NULL); if(hService==NULL) { int nError = GetLastError(); if(nError==ERROR_SERVICE_EXISTS || nError==ERROR_SERVICE_MARKED_FOR_DELETE) { hService = OpenService(hSCM,szLinkName,SERVICE_ALL_ACCESS); } } if(hService==NULL) { ShowMessage("创建服务出错."); CloseServiceHandle(hSCM); notifying = false; Button1->Enabled = true; Button2->Enabled = false; Button3->Enabled = true; return; } if(!StartService(hService,0,NULL)) { int nError = GetLastError(); if(nError != ERROR_SERVICE_ALREADY_RUNNING) { ShowMessage("启动服务出错."); DeleteService(hService); CloseServiceHandle(hService); CloseServiceHandle(hSCM); notifying = false; Button1->Enabled = true; Button2->Enabled = false; Button3->Enabled = true; return; } } char szDriverFile[256] = ""; wsprintf(szDriverFile,"\\\\.\\%s",szLinkName); hDriver = CreateFile(szDriverFile,GENERIC_READ|GENERIC_WRITE, 0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); if(hDriver==INVALID_HANDLE_VALUE) { ShowMessage("打开设备失败."); DeleteService(hService); CloseServiceHandle(hService); CloseServiceHandle(hSCM); notifying = false; Button1->Enabled = true; Button2->Enabled = false; Button3->Enabled = true; return; } hProcessEvent = OpenEvent(SYNCHRONIZE,FALSE,"CPNDriverEvent"); th = new GetInformationThread(true,ListView1); th->Resume(); notifying = true; Button1->Enabled = false; Button2->Enabled = true; Button3->Enabled = false; } http://www.dishou.com/news/2/79/81/qudongchengxudedongtaijiazai.html 1楼朋友给的网址打不开,2楼朋友给的只是普通设备驱动(非硬件设备)3楼给的似乎只是一个进入RING0的驱动设备代码。请高手继续指点:该设备为鼠标设备,我是在该设备上添加了一下层过滤驱动。用系统面板安装可以正常使用,但用Rundll32 Setupapi,....安装时能在注册表项里找到其安装项,但系统设备里却找不到。无法使用该驱动。 求一DSOFramer教程或者例子 离职成功,散分!散光为止 关于ODBC驱动程序问题 使用类模板来设计类时,出现连接错误!!!! 飞图flyfot这家公司怎么样?熟悉的给讲讲吧 請問下面配置有慎麼問題? 求《WINDOWS网络编程技术》的源原代码 求助:我要拆分一个窗口,左边为一个树形控件,右边为一个列表控件。该怎么弄啊? UltraVNC 里怎么给下面这个控件添加快捷键 微调控件的响应代码问题 为何缺少UpdataData(FALSE);就无法在屏幕上输出结果? 大家给指导啊!急
::GetFullPathName("CPNDriver.sys",256,szDriverPath,&p);
if(notifying==false)
{
hSCM = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
if(hSCM==NULL)
{
ShowMessage("打开服务控制管理器失败.");
notifying = false;
Button1->Enabled = true;
Button2->Enabled = false;
Button3->Enabled = true;
return;
}
hService = CreateService(hSCM,szLinkName,szLinkName,SERVICE_ALL_ACCESS,
SERVICE_KERNEL_DRIVER,SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL,szDriverPath,
NULL,0,NULL,NULL,NULL);
if(hService==NULL)
{
int nError = GetLastError();
if(nError==ERROR_SERVICE_EXISTS || nError==ERROR_SERVICE_MARKED_FOR_DELETE)
{
hService = OpenService(hSCM,szLinkName,SERVICE_ALL_ACCESS);
}
}
if(hService==NULL)
{
ShowMessage("创建服务出错.");
CloseServiceHandle(hSCM);
notifying = false;
Button1->Enabled = true;
Button2->Enabled = false;
Button3->Enabled = true;
return;
}
if(!StartService(hService,0,NULL))
{
int nError = GetLastError();
if(nError != ERROR_SERVICE_ALREADY_RUNNING)
{
ShowMessage("启动服务出错.");
DeleteService(hService);
CloseServiceHandle(hService);
CloseServiceHandle(hSCM);
notifying = false;
Button1->Enabled = true;
Button2->Enabled = false;
Button3->Enabled = true;
return;
}
}
char szDriverFile[256] = "";
wsprintf(szDriverFile,"\\\\.\\%s",szLinkName);
hDriver = CreateFile(szDriverFile,GENERIC_READ|GENERIC_WRITE,
0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if(hDriver==INVALID_HANDLE_VALUE)
{
ShowMessage("打开设备失败.");
DeleteService(hService);
CloseServiceHandle(hService);
CloseServiceHandle(hSCM);
notifying = false;
Button1->Enabled = true;
Button2->Enabled = false;
Button3->Enabled = true;
return;
}
hProcessEvent = OpenEvent(SYNCHRONIZE,FALSE,"CPNDriverEvent");
th = new GetInformationThread(true,ListView1);
th->Resume();
notifying = true;
Button1->Enabled = false;
Button2->Enabled = true;
Button3->Enabled = false;
}
2楼朋友给的只是普通设备驱动(非硬件设备)
3楼给的似乎只是一个进入RING0的驱动设备代码。
请高手继续指点:
该设备为鼠标设备,我是在该设备上添加了一下层过滤驱动。用系统面板安装可以正常使用,但用Rundll32 Setupapi,....安装时能在注册表项里找到其安装项,但系统设备里却找不到。无法使用该驱动。