Results 1 to 8 of 8
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detecting the files a program is using (VB6 SR6)

    Is There a way to detect what reference files an application is using?

    I'm writing an updater for our main application which will check for the latest version of each file and if the users version is out of date, overwrite it. As messing with dll's and ocx's is risky at the best of times i'd prefer to detect exactly which ones are being used by our application. Is this possible outside the application similar to the dependancy scanner in Installshield?

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Detecting the files a program is using (VB6 SR6)

    Recommend take look at application such as PE Explorer. Web site:

    Heaventools - PE Explorer

    Among many other features, this application has a Dependency Scanner that can scan an executable file for any dependencies. To quote web site briefly:

    "The Dependency Scanner tool allows you to recursively scan all modules linked to by a particular PE file and build the hierarchical dependency tree of executable files (a graphical representation of all the modules an executable is statically linked to). Dependency Scanner also detects delay-load dependencies. This type of linking was introduced with Microsoft Visual C++ 6.00 and works under Windows 9x, NT, 2000 and XP. For each module found, it lists the full path to the file and the version information. Then you can easily examine this particular linked module in PE Explorer and get back again to the previously selected executable."

    Also see attached screen shot for example of info provided by Dependency Scanner. You can download a 30-day trial version of PE Explorer from the web site. FWIW, I wound up purchasing a licensed copy of the program, as it provides many other useful functions in an attractive interface, and is probably the best program of its type out there.

    HTH

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting the files a program is using (VB6 SR6)

    Minor omission on my part sorry!

    I meant programmatically i.e. Write the dependancy scanning into a VB project.

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Detecting the files a program is using (VB6 SR6)

    That sounds like a different question to me. Are you referring to a VB application you created & compiled yourself? In that case you could simply use the dependency (.DEP) files created by the VB6 Package & Deployment Wizard (that is, if you used the P&D Wizard to create an installation package). As noted in MSKB 178354, "A dependency (.DEP) file contains information about the run-time requirements of an application or component; it contains information regarding which files are needed, how the files are to be registered, and where they should be installed on the target computer. You can create dependency files for standard Visual Basic projects, ActiveX controls, ActiveX documents, and other ActiveX components." And: "A dependency file is a standard Windows .INI file and can be read and written to using the standard Windows APIs (GetPrivateProfileString and WritePrivateProfileString)." For more info see article:

    INFO: How Setup Wizard and PDW Use Dependency Files

    If you used InstallShield or some other 3rd-party tool to distribute application, then there may be no .DEP file available. According to MSKB 279693, "InstallShield provides a Visual Basic Setup Wizard that scans Visual Basic applications for dependencies and creates a setup." I don't have this product so don't know if it creates a file analagous to the PDW .DEP file that can be read programmatically. For more info see:

    HOWTO: Troubleshoot Application Errors in Visual Basic Programs That Are Installed with InstallShield

    This article also notes: "NOTE: Microsoft does not support the creation of Visual Basic setup programs with InstallShield. For more information, refer to the following Microsoft Knowledge Base article:"

    INFO: InstallSHIELD Not Supported by Microsoft Tech Support

    This states: "The use of InstallSHIELD to distribute and install Visual Basic applications is not supported by Microsoft Technical Support. Support must be obtained directly from InstallShield. The recommended and supported method of creating distribution media for Visual Basic applications is to use the Application Setup Wizard provided with Visual Basic 5.0 or the Package & Deployment Wizard with Visual Basic 6.0."

    So you would probably have to refer to the InstallShield documentation to see if it provides some way to "capture" the dependency information generated when it creates an installation package. If not, you can always run the P&D Wizard on the original VB project file, if only to generate a dependency file that can be read like an .INI file, but still use InstallShield or another product to create the actual package you intend to distribute.

    HTH

  5. #5
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting the files a program is using (VB6 SR6)

    Thanks for your reply Mark, and its installshield for me and being new to it, I have no idea if it creates a similar file to a .dep, I couldnt see one if it did.

    However, I think i've solved my problem. It is a program that I have created and compiled that I'm looking to find the references for, and seeing as I know which references should be there its just the reference location I need. However, after some more research I think my original question has been rendered useless. I've never really looked into how reference files are stored (the ones in use) on a PC.

    For anyone who doesn't know, all reference objects (dll and ocx files) are stored in the registry under HKEY_CLASSES_ROOT and CLSID. Each object is only referenced once. So if you had the Mdac 2.6 object on C: and the same file in C:WindowsSystem32 only one would be in use, and that is whichever file was registered last.

    Therefore, my update program has a list of files, so it can search the registry to find the location, check the version and update the file if older than the one on our website.

    Sorry for the misleading question but my knowledge of how windows uses refence files was a bit thin on the ground! I thought the only place I could get the file locations was from a program that used the files i.e. my original program.

  6. #6
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting the files a program is using (VB6 SR6)

    Small sub question:

    If I have component A version 1.5 and I copy version 2.0 over the top, do I need to re-register it? (i.e. regsvr32 C:winntsystem32ComponentA.dll)

  7. #7
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Detecting the files a program is using (VB6 SR6)

    In reference to installing a new version of a component over an old one, if you want to be safe, if the old version is installed on target system, unregister it first, install new version, then register new component. If using Regsvr32.exe to register component, you'd use the /u command-line switch to unregister the old component. Example of syntax:

    <code>Regsvr32 <!t>[/u]<!/t> <!t>[/s]<!/t> <<OCX/DLL/EXE File Name>></code>

    Note /s option denotes Silent Mode (ie, display no messages). For more info on Regsvr32 see this MSKB article:

    Explanation of Regsvr32 Usage and Error Messages

    For some reason, this article doesn't include the /s switch in the list of command-line options, but it is documented in other MSKB articles & elsewhere. BTW, I didn't realize it the other day (because I did not have VB/Visual Studio installed at work), but there is a "Dependency Walker" tool included with Visual Studio 6.0. Look in this folder:

    C:Program FilesMicrosoft Visual StudioCommonTools

    for a file named Depends.exe (also was included with Windows 98 and Windows NT 4.0 Resource Kits). It functions in similar fashion as the PE Explorer Dependency Scanner, but with a more basic-looking interface (not as pretty). BTW, if adventurous, here's a link an old Microsoft Systems Journal (MSJ) article from Feb 1997:

    MSJ - Under the Hood Feb 1997

    The article provides a link (first line) for downloading the source code for a console (command-line) utility named DEPENDS that can be used to list an executable file's dependencies. Of course, the source code in question is all written in C++, so you'd have to be proficient in that language to be able to translate code to VB, which may not be a practical exercise to pursue.... However, the download includes a compiled version of the program (DEPENDS.EXE) which can be run from a command line, which may or may not be useful. (Not to be confused with the VS tool described above.) See MSJ article for more info on this utility.

    HTH

  8. #8
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting the files a program is using (VB6 SR6)

    How, hordes of information! Thanks Mark.

    For now, I don't think i'll need the dependancy functions, but its always useful to know.

    I'll definately be making use of the /s command for regsvr , I didn't know about that.

    Thanks again for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •