64位系统下的驱动安装
64位系统下的驱动安装包
HDEVINFO DeviceInfoSet = 0;
SP_DEVINFO_DATA DeviceInfoData;
GUID ClassGUID;
TCHAR ClassName[MAX_CLASS_NAME_LEN];
DWORD err;
// Use the INF File to extract the Class GUID.
//
if (!SetupDiGetINFClass(INFFile,&ClassGUID,ClassName,sizeof(ClassName),0))
{
::MessageBox( NULL, "GetInfoClass", "Error", MB_OK );
return DisplayError(TEXT("GetINFClass"));
}
//
// Create the container for the to-be-created Device Information Element.
DeviceInfoSet = SetupDiCreateDeviceInfoList(&ClassGUID,0);
if(DeviceInfoSet == INVALID_HANDLE_VALUE)
{
::MessageBox( NULL, "CreateDeviceInfoList", "Error", MB_OK );
return DisplayError(TEXT("CreateDeviceInfoList"));
}
//
// 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))
{
::MessageBox( NULL, "CreateDeviceInfo", "Error", MB_OK );
DisplayError(TEXT("CreateDeviceInfo"));
goto cleanup_DeviceInfo;
}
// Transform the registry element into an actual devnode
// in the PnP HW tree.
//
if (!SetupDiCallClassInstaller(DIF_REGISTERDEVICE, DeviceInfoSet, &DeviceInfoData))
{
::MessageBox( NULL, "CallClassInstaller(REGISTERDEVICE)", "Error", MB_OK );
DisplayError(TEXT("CallClassInstaller(REGISTERDEVICE)"));
goto cleanup_DeviceInfo;
}
到 SetupDiCallClassInstaller 就失败了,请教高手指点