- 注册时间
 - 2021-4-16
 
- 最后登录
 - 2024-7-3
 
- 在线时间
 - 3 小时
 
 
 
 
 
编程入门 
  
	- 龙马币
 - 56 
 
 
 
 
 | 
 
 
实现在应用层下遍历输出驱动文件路径列表信息。 
 
实现代码: 
- #include <stdio.h>
 
 - #include <windows.h>
 
 - #include <Psapi.h>
 
 - #include <shlwapi.h>  //PathFileExists
 
 - #pragma comment(lib, "psapi.lib")
 
 - #pragma comment(lib, "shlwapi.lib")
 
 - #define  ARRAY_SIZE 1024
 
  
- int _tmain(int argc, _TCHAR* argv[]){
 
 -     DWORD cbNeeded = 0; // drivers[] 返回的字节数
 
 -     LPVOID drivers[ARRAY_SIZE] = {0}; // 驱动程序地址列表数组
 
 -     int cDrivers = 0;    // 驱动个数
 
 -     if (EnumDeviceDrivers(drivers, sizeof(drivers), &cbNeeded) && cbNeeded < sizeof(drivers)) // EnumDeviceDrivers 检索每个驱动文件的加载地址
 
 -     {
 
 -         char szDriver[ARRAY_SIZE] = {0};    // 驱动文件名
 
 -         char szPath[ARRAY_SIZE] = {0};    // 存放驱动文件全路径
 
 -         char szSystemPath[ARRAY_SIZE] = {0}; // 存放 system32 文件夹路径
 
 -         cDrivers = cbNeeded / sizeof(LPVOID);    // 驱动个数
 
 -         
 
 -         //得到C:\Windows\system32\dbghelp.dll
 
 -         GetSystemDirectory(szSystemPath, sizeof(szSystemPath));
 
 -         strcat_s(szSystemPath, "\\dbghelp.dll");
 
  
-         for (int i = 0; i < cDrivers; i++)
 
 -         {
 
 -             if (GetDeviceDriverBaseName(drivers[i], szDriver, sizeof(szDriver) / sizeof(LPVOID)))
 
 -             {
 
 -                 // 打印驱动名
 
 -                 printf("【%d】:%s\n", i+1, szDriver);
 
  
-                 // 打印驱动文件路径
 
 -                 //GetDeviceDriverFileName(drivers[i], szPath, sizeof(szPath));
 
 -                 //printf("%s\n", szPath);
 
 -             }
 
 -         }
 
 -     }
 
  
-     getchar();
 
 -     return 0;
 
 - }
 
  复制代码 
 |   
 
 
 
 |