I got the answer from the brand new (and very promising) Stack Overflow programming Q&A site: System.Diagnostics.Process.GetCurrentProcess returns a Process object, which has a Modules collection. You can iterate the collection, find the module you're looking for, and check its FileVersionInfo property. This will work, of course, for any module, not just comctl32.
Here's a function that returns the FileVersionInfo for any loaded module:
using System.Diagnostics;
internal static FileVersionInfo GetLoadedModuleVersion(string name)
{
Process process = Process.GetCurrentProcess();
foreach (ProcessModule module in process.Modules)
{
if (module.ModuleName.ToLower() == name)
return module.FileVersionInfo;
}
return null;
}
internal static bool HaveComctl6()
{
FileVersionInfo verInfo = GetLoadedModuleVersion("comctl32.dll");
return verInfo != null && verInfo.FileMajorPart >= 6;
}
No comments:
Post a Comment