[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Find DLL paths, versions at runtime?

Posted on 1999-12-14
13
Medium Priority
?
259 Views
Last Modified: 2013-12-03
How can I find out at runtime what DLLs my app
is using, their versions and paths?  The answer
should not require me to look through the source
for LoadLibrary() and such (it's an MFC app and
these calls may be buried in code I don't want to
wade through).
0
Comment
Question by:trovatore
  • 7
  • 5
13 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 400 total points
ID: 2282023
Windows 9x, Windows 2000: Use Tool Help functions - Module32First, Module32Next.

Windows NT, Windows 2000: Use PSAPI functions - EnumProcessModules, GetModuleFileNameEx.

Once you get the file name, use the GetFileVersionInfoSize and GetFileVersionInfo functions to retrieve the version information.
0
 

Author Comment

by:trovatore
ID: 2282181
OK, thanks; I'm leaving work now so I probably won't
try it till Thursday -- will grade it after I try it.
0
 

Author Comment

by:trovatore
ID: 2282184
P.S. does this also work for OCXs ?
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
LVL 23

Expert Comment

by:chensu
ID: 2282270
>does this also work for OCXs?

Not sure. I doubt so.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2282613
Well, OCXs are just another kind of dlls, so I think that should work for OCXs, too...
Just my opinion...

Regards, Madshi.
0
 

Author Comment

by:trovatore
ID: 2288086
It doesn't work for OCXs.  Can we find these too?
0
 

Author Comment

by:trovatore
ID: 2288103
Also I can't make it link when GetFileVersionInfo()
is included.  What lib do I have to link to?
0
 
LVL 23

Expert Comment

by:chensu
ID: 2288199
>It doesn't work for OCXs.  Can we find these too?

Sorry, I have no idea.

>Also I can't make it link when GetFileVersionInfo()
is included.  What lib do I have to link to?

version.lib
0
 

Author Comment

by:trovatore
ID: 2288626
Turns out I was wrong; it *does* pick up the OCXs
after all.  When I tried it before, the app just hadn't
used any controls yet that used the OCXs, so they
hadn't been loaded.
0
 
LVL 23

Expert Comment

by:chensu
ID: 2288638
Great.
0
 

Author Comment

by:trovatore
ID: 2289014
Well, I was disappointed: I thought I'd be able to
have the code find out if it was running on 95/98
or on NT and call the appropriate functions.  But
no; when I tried to run the app on NT, I got
  "The procedure entry point Module32Next could not
   be located in the dynamic link library KERNEL32.DLL"

So, unless you know another way around it, I guess I'll
have to move these calls into a little DLL and supply
different versions of the DLL depending on whether
the user's running 95/98 or NT.

A couple questions:

  1) will that work?  or will the two DLLs result in different .LIB
      files and produce different .EXE files?

  2) If someone's double-booting 95 and NT, can I
      just copy one version of the DLL into WINDOWS\SYSTEM
     and the other into WINNT\SYSTEM ?
0
 

Author Comment

by:trovatore
ID: 2289042
Well, I was disappointed: I thought I'd be able to
have the code find out if it was running on 95/98
or on NT and call the appropriate functions.  But
no; when I tried to run the app on NT, I got
  "The procedure entry point Module32Next could not
   be located in the dynamic link library KERNEL32.DLL"

So, unless you know another way around it, I guess I'll
have to move these calls into a little DLL and supply
different versions of the DLL depending on whether
the user's running 95/98 or NT.

A couple questions:

  1) will that work?  or will the two DLLs result in different .LIB
      files and produce different .EXE files?

  2) If someone's double-booting 95 and NT, can I
      just copy one version of the DLL into WINDOWS\SYSTEM
     and the other into WINNT\SYSTEM ?
0
 
LVL 23

Expert Comment

by:chensu
ID: 2289063
The correct way to do it is to use LoadLibrary and GetProcAddress to call the functions.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question