已解决 Devcon.exe 中的Install 调用的是哪个API?
本帖最后由 Qokelate 于 2012-3-27 21:39 编辑如题,想用纯AU3做个自动安装驱动的工具,SetupAPI.au3看不明白,有人解答下吗?
无解。。。 如果是一个API能解决我就不会到现在也看不懂P版的帖子了 本帖最后由 Qokelate 于 2012-3-24 15:35 编辑
回复 2# 502762378
?? 这和你看不看得懂P版的帖子有什么关系?你要求的是直接给个文件名就能傻瓜式使用,而我想知道的只是它首先调用或核心调用是哪个API,有关系吗? 回复 3# Qokelate
呵呵,是我淡疼多言了,希望你早日解决问题,当然偶没折 找到原型如下,不知是否正确
int cmdInstall(__in LPCTSTR BaseName, __in LPCTSTR Machine, __in DWORD Flags, __in int argc, __in_ecount(argc) TCHAR* argv[])
/*++
Routine Description:
CREATE
Creates a root enumerated devnode and installs drivers on it
Arguments:
BaseName- name of executable
Machine - machine name, must be NULL
argc/argv - remaining parameters
Return Value:
EXIT_xxxx
--*/
{
HDEVINFO DeviceInfoSet = INVALID_HANDLE_VALUE;
SP_DEVINFO_DATA DeviceInfoData;
GUID ClassGUID;
TCHAR ClassName;
TCHAR hwIdList;
TCHAR InfPath;
int failcode = EXIT_FAIL;
LPCTSTR hwid = NULL;
LPCTSTR inf = NULL;
if(Machine) {
//
// must be local machine
//
return EXIT_USAGE;
}
if(argc<2) {
//
// at least HWID required
//
return EXIT_USAGE;
}
inf = argv;
if(!inf) {
return EXIT_USAGE;
}
hwid = argv;
if(!hwid) {
return EXIT_USAGE;
}
//
// Inf must be a full pathname
//
if(GetFullPathName(inf,MAX_PATH,InfPath,NULL) >= MAX_PATH) {
//
// inf pathname too long
//
return EXIT_FAIL;
}
//
// List of hardware ID's must be double zero-terminated
//
ZeroMemory(hwIdList,sizeof(hwIdList));
if (FAILED(StringCchCopy(hwIdList,LINE_LEN,hwid))) {
goto final;
}
//
// Use the INF File to extract the Class GUID.
//
if (!SetupDiGetINFClass(InfPath,&ClassGUID,ClassName,sizeof(ClassName)/sizeof(ClassName),0))
{
goto final;
}
//
// Create the container for the to-be-created Device Information Element.
//
DeviceInfoSet = SetupDiCreateDeviceInfoList(&ClassGUID,0);
if(DeviceInfoSet == INVALID_HANDLE_VALUE)
{
goto final;
}
//
// Now create the element.
// Use the Class GUID and Name from the INF file.
//
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
if (!SetupDiCreateDeviceInfo(DeviceInfoSet,
ClassName,
&ClassGUID,
NULL,
0,
DICD_GENERATE_ID,
&DeviceInfoData))
{
goto final;
}
//
// Add the HardwareID to the Device's HardwareID property.
//
if(!SetupDiSetDeviceRegistryProperty(DeviceInfoSet,
&DeviceInfoData,
SPDRP_HARDWAREID,
(LPBYTE)hwIdList,
(lstrlen(hwIdList)+1+1)*sizeof(TCHAR)))
{
goto final;
}
//
// Transform the registry element into an actual devnode
// in the PnP HW tree.
//
if (!SetupDiCallClassInstaller(DIF_REGISTERDEVICE,
DeviceInfoSet,
&DeviceInfoData))
{
goto final;
}
FormatToStream(stdout,MSG_INSTALL_UPDATE);
//
// update the driver for the device we just created
//
failcode = cmdUpdate(BaseName,Machine,Flags,argc,argv);
final:
if (DeviceInfoSet != INVALID_HANDLE_VALUE) {
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
}
return failcode;
}
http://www.autoitx.com/forum.php?mod=viewthread&tid=17798&extra= 本帖最后由 Qokelate 于 2012-3-25 00:47 编辑
回复 6# hzxymkb
这个是Update方式的,不能用于添加新硬件,我想要的是Install的,相当于添加新硬件并安装驱动,而且iFlag 类型是 DWORD 但却用个字符串传入,表示不解,该贴作者测试过可用性了吗?
关于Devcon MS有详细使用说明 http://msdn.microsoft.com/en-us/library/windows/hardware/ff544780(v=vs.85).aspx 去搜p侠的setupapi 学习一下下哈哈
页:
[1]