0

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

Barbarian
  • 11
  • 4

1 Answers1

0

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.

Barbarian
  • 11
  • 4
  • Don't write your own winapi declarations, `#include ` instead. And set the _WIN32_WINNT macro value correctly, Vista and up required. – Hans Passant Jul 04 '12 at 15:59
  • 6.0A SDK contains wrong declaration (7.1 is correct), so it's the only way. Probably this information will be helpful for somebody. – Barbarian Jul 04 '12 at 16:20
  • Hmm, I don't see it. Posting a question that shows you using 7.1 does not exactly help to clarify anything. – Hans Passant Jul 04 '12 at 16:26