SetupDiGetClassDevs causing error on XP, app built in VS2010, on Win7

1.2k views Asked by At

I'm writing a WPF app that uses PINVOKE to make calls to a dll that I'm also writing. In one of the exported functions in the dll, the SetupDiGetClassDevs is called. At this point, when running the app on XP, I get an error, first of all a dialog box saying:

"The procedure entry point RegOpenKeyExW could not be located in the dynamic link library KERNAL32.dll."

Clicking ok then leads me to an unhandled exception dialog. Both the WPP app and the dll are built with VS2010 on a Win7 machine, and the app runs fine on Win7 systems. The problem only happens when running the app on XP. If I avoid the SetupDiGetClassDevs (and subsequent SetUpdi function calls) in the dll, then nothing goes wrong; so it seems the PINVOKE mechanism is working ok.

Any ideas what is going wrong? I'm a bit confused about seeing RegOpenKeyExW referenced, as the dll is not built with UNICODE enabled.

Thanks Tom

1

There are 1 answers

3
David Heffernan On

I strongly suspect that the problem lies in some P/invoke code of yours, or perhaps a direct LoadLibrary/GetProcAddress bind in your DLL. The thing is, RegOpenKeyEx is not part of kernel32. It is exported by advapi32. I can't believe that you have a .lib file that is tries to import it from kernel32 so I think you should look for a P/invoke or a GetProcAddress in your code or perhaps third party code that you are including.