I'm using DiInstallDevice function (MSDN) for driver installing. However, I've got a linker error when building solution under x86, while x64 version is OK. Error is LNK2019, linked was unable to find function in x86 version of newdev.lib. Here is a linker output for x86 and x64 versions:
x86:
Searching C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\newdev.lib:
Found _UpdateDriverForPlugAndPlayDevicesW@20
Referenced in KernelDriverInstaller.obj
Loaded newdev.lib(newdev.dll)
Found __IMPORT_DESCRIPTOR_newdev
Referenced in newdev.lib(newdev.dll)
Loaded newdev.lib(newdev.dll)
Found newdev_NULL_THUNK_DATA
Referenced in newdev.lib(newdev.dll)
Loaded newdev.lib(newdev.dll)
x64:
Searching C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64\newdev.lib:
Found DiInstallDevice
Referenced in KernelDriverInstaller.obj
Loaded newdev.lib(newdev.dll)
Found UpdateDriverForPlugAndPlayDevicesW
Referenced in KernelDriverInstaller.obj
Loaded newdev.lib(newdev.dll)
Found __IMPORT_DESCRIPTOR_newdev
Referenced in newdev.lib(newdev.dll)
Referenced in newdev.lib(newdev.dll)
Loaded newdev.lib(newdev.dll)
Found newdev_NULL_THUNK_DATA
Referenced in newdev.lib(newdev.dll)
Loaded newdev.lib(newdev.dll)
As you can see, linker was unable to find function reference for x86 library. Does somebody knows something about this problem and how it can be solved? I'm using Win7 x64 + VS2008 SP1.
Thank you
Problem solved. DiInstallDevice declaration is moved to the separate header and WINAPI declaration added. So that the right declaration should be:
BOOL WINAPI DiInstallDevice(
__in_opt HWND hwndParent,
__in HDEVINFO DeviceInfoSet,
__in PSP_DEVINFO_DATA DeviceInfoData,
__in_opt PSP_DRVINFO_DATA DriverInfoData,
__in DWORD Flags,
__out_opt PBOOL NeedReboot
);
EDIT: Actual for 6.0A SDK, not 7.1 where declaration is correct.