views:

298

answers:

2

I've got some P/Invoke code that invokes DBGHELP.DLL. I'll add the signatures to pinvoke.net later.

The version of DBGHELP.DLL that ships with Windows 2003 is too old, and my code requires the version of DBGHELP.DLL that shipped with "Debugging Tools for Windows" version 6.9.

How do I do one of the following?

  • Ensure that DllImport requires a minimum version.
  • Find out which DLL will be loaded and then get its version number. I'll need to use FileVersionInfo, but how do I find out the search order that P/Invoke will use?

That said: does anyone have robust code that uses FileVersionInfo to check minimum version info?

+1  A: 

P/Invoke a call to LoadLibrary with the explicit path of the DBGHELP that you want, that way when you go to make your actual P/Invoke call, the DLL will already be loaded.

Paul Betts
Not a bad idea, but I don't really want to specify the full path to the DLL, since that would require configuration. I just want to verify that the one I'm about to load is new enough.
Roger Lipscombe
A: 

Wouldn't it be easier to import (but not call) a function that's only present in DbgHelp.DLL version 6.9 and higher?

MSalters
The function that I want to call is present in all versions of DbgHelp.DLL. It's one of those that takes a variable-sized structure. It fails with "invalid parameter" when given a structure too big.
Roger Lipscombe