A dependency (.DEP) file contains information about the run-timerequirements of an application or component; it contains informationregarding which files are needed, how the files are to be registered, andwhere they should be installed on the target computer. You can createdependency files for standard Visual Basic projects, ActiveX controls,ActiveX documents, and other ActiveX components.
When a component is used in another project, the dependency information forthe component is incorporated into the project's dependency information.This dependency information is used by the Setup Wizard (known as thePackage and Deployment Wizard or PDW in Visual Basic 6.0). When you use theSetup Wizard or PDW to generate a setup for your project, the wizard refersto the project's dependency information to determine which files should bedistributed with your project and how those files should be installed.
All of the ActiveX controls that ship with Visual Basic have a companiondependency file. It is strongly recommended that you generate a dependencyfile for your component, especially if you intend that the component beused in other Visual Basic projects. The Setup Wizard and PDW give you theoption to generate a dependency file for your project or component. Thedependency file may also be generated using a text editor if you cannot usethe Setup Wizard or PDW to create one. The remainder of this articledescribes the syntax for a dependency file.
A dependency file is a standard Windows .INI file and can be read andwritten to using the standard Windows APIs (GetPrivateProfileString andWritePrivateProfileString).
There are a few items to note for dependency files:
- Dependency files may have multiple sections. The section order is not significant.
- Entries are not case-sensitive.
- Comments are allowed when preceded by a semi-colon (;).
- The dependency file name is important. The file name prefix must match the file name of the component it describes. For example, a dependency file MyOCX.DEP would correspond to a component, such as MyOCX.OCX or MyOCX.DLL.
Each section in a .DEP file uses the following syntax:
[Component File Name] Dest=<Destination> UsesN=<Dependent File> Register=<Method of Registration> Version=<Component version> Date=<Component Date> Time=<Component Time> ProgramIconTitle=<Title for Shortcut> ProgramIconCmdLine=<Command Line for Shortcut>
The Dest= key indicates the destination folder for the component. Thisvalue may be a relative path, a full path, or a path based on any of thefollowing macros (for example, it may be simply a macro, or it may be amacro followed by a backslash and a relative path):
$(AppPath) Indicates the path the user selects during setup. $(WinSysPath) Indicates the \Windows\System or \Winnt\System32 folder. $(WinPath) Indicates the \Windows or \Winnt folder. $(ProgramFiles) Indicates the folder specified at HKEY_LOCAL_MACHINE\Software\ Microsoft\Windows\CurrentVersion\ ProgramFilesDir. $(CommonFiles) Indicates the folder specified at HKEY_LOCAL_MACHINE\Software\ Microsoft\Windows\CurrentVersion\ CommonFilesDir. $(CommonFilesSys) Indicates $(CommonFiles)\System in Windows 95, Windows 98, NT 4.0, and Windows 2000, or the same as $(WinSysPath) in NT 3.51. $(MSDAOPath) The location stored in the registry for DAO components.
The Dest= key applies only to the component to which the section applies.By default, all files dependent on the component will also be placed in thesame location. To override the location for a "child," you can create asection for the "child" and specify a different destination in thatsection.
The UsesN= key (where N is an integer) indicates a dependent file for thecomponent. A file specified by a UsesN= key is required for the componentdefined by that section. In a section, N must be sequential and must startwith 1. For an illustration, refer to the following sample section:
[MyOCX.OCX] Dest=$(WinSysPath) Uses1=MyDLL.DLL Uses2=MyOCX.TXT
In this example, MyOCX.OCX depends upon (or requires) MyDLL.DLL andMyOCX.TXT.NOTE
: If the UsesN keys are not ordered sequentially, or if a number isskipped, dependent files may not be recognized in the section and may notbe acknowledged by the Setup Wizard or PDW.
The Register= key indicates whether the file should be registered and, ifso, how it should be registered. The valid values for this key are:
None If a value is omitted for this key, the file is not registered. $(DllSelfRegister) The file supports self-registration and self-unregistration via a DLL entry point. $(ExeSelfRegister) The file is a local server that supports self-registration through the command-line parameter "/RegServer" and self-unregistration through the command-line parameter "/UnRegServer." $(TLBRegister) The file is a .TLB file and should be registered. Filename The file is registered by calling Regedit.exe with this filename as a Command-line parameter. $(Remote) Used only by Visual Basic to indicate that the file is a .VBR file.
If the Register= key is omitted altogether, the file is not registered.
The Version= key indicates the version of the component that is needed. TheSetup Wizard and PDW can detect that a .dep file is out-of-date using theVersion= key. The version is specified in the format a.b.c.d, as in thefollowing example:
The Date= key is the date stamp of the component that is needed. The SetupWizard and PDW can detect that a .DEP file is out-of-date using this key.This value must always be in the format d/m/yyyy or dd/mm/yyyy, even whenusing a localized Setup Wizard or PDW. For example:
: This key is ignored if a value is specified for the Version= key.
The Time= key is the time stamp of the component that is needed. The SetupWizard and PDW can detect that a .DEP file is out-of-date using this key.This value must always be in the 24-hour format hh:mm:ss, even when using alocalized Setup Wizard or PDW. For example:NOTE
: This key is ignored if a value is specified for the Version= key.
ProgramIconTitle= and ProgramIconCmdLine=
The ProgramIconTitle= key indicates that a shortcut (or Program Managericon for Windows NT 3.51) should be created if the file is installed. Thevalue for the ProgramIconTitle= key is the title given to the shortcut (oricon). The value may be quoted or unquoted. For example:
ProgramIconTitle=My Program Title
If you indicate that a shortcut should be created, you can give the commandline for the shortcut by specifying a value for the ProgramIconCmdLine=key. The path that you use for the command-line value may contain themacros listed for the Dest= key. For example:
Some components may have different dependencies based on the language. Toinstall a component based on the language setting for the client'scomputer, you may specify a section with the component name followed by thelanguage ID.
For example, VBRUN500.DLL has a satellite DLL for all languages (with theexception of English):
[VBRUN500.DLL] Dest=$(WinSysPath) [VBRUN500.DLL <000C>] ;000C = primary language ID for French Uses1=VB5FR.DLL [VBRUN500.DLL <0007>] ;0007 = primary language ID for German Uses1=VB5DE.DLL
In this example, if VBRUN500.DLL is installed and the client's languagesettings are French, VB5FR.DLL will also be installed. Likewise, ifVBRUN500.DLL is installed and the client's language settings are German,VB5DE.DLL will be installed.
Sample Dependency File
The following is a sample .DEP file for a component named MyOCX.OCX. Thisdependency file would be named MyOCX.DEP:
[MyOCX.OCX] Register=$(DLLSelfRegister) Dest=$(WinSysPath) Date=1/23/1996 Time=10:15:33 Version=188.8.131.52 Uses1=MyDLL.DLL Uses2=MyServer.EXE Uses3=VBRUN500.DLL [MyServer.EXE] Dest=$(WinPath) Date=1/23/1996 Time=18:52:48 Version=184.108.40.206 Uses1=VBRUN500.DLL Register=$(ExeSelfRegister) ProgramIconTitle=My Program ProgramIconCmdLine=$(WinSysPath)\MyOCX.OCX [MyDLL.DLL] Register=$(DLLSelfRegister) Version=220.127.116.11 [VBRUN500.DLL] Dest=$(WinSysPath) ;Additional Files for International Support [VBRUN500.DLL <0007>] Uses1=VB5DE.DLL [VBRUN500.DLL <000C>] Uses1=VB5FR.DLL
MyOCX.OCX is a self-registering file that is installed in theWindows\System folder (or Winnt\System32 folder on NT or Windows 2000). MyOCX.OCX depends upon (requires) three files: MyDLL.DLL, MyServer.EXE, and VBRUN500.DLL.
MyServer.EXE is a self-registering file that is installed in the Windowsfolder (or Winnt folder on NT or Windows 2000). MyServer.EXE has only one dependent file, VBRUN500.DLL. If MyServer.EXE is installed during setup, a shortcut is created with the title "My Program" and the command lineWindows\System\MyOCX.OCX (or Winnt\System32\MyOCX.OCX on NT or Windows 2000).
MyDLL.DLL is also a self-registering file. A destination for MyDLL.DLL isnot specified; thus, it will be placed in the destination path for itsparent, MyOCX.OCX.
VBRUN500.DLL will not be registered because a Register= key is notspecified in its section. VBRUN500.DLL will be placed in the Windows\System(or Winnt\System32) folder. If VBRUN500.DLL is installed during setup,VB5DE.DLL will be installed if the language setting is German and VB5FR.DLLwill be installed if the language setting is French. If the languagesetting is set to something other than French or German, no additionalfiles will be installed.
How Setup Wizard and PDW Search for Dependency Information
When the Setup Wizard and PDW need to find dependency information for afile (for example, MyOCX.OCX), they follow a specific path. The wizards usethe following methods to locate a section entitled [MyOCX.OCX]; when thesection is found, the search ends.
- If the file has been located in a .DEP file, it will use the information in the .DEP file in which it was first found.
- The Setup Wizard will look in the default master dependency file for Visual Basic 5.0 (VB5DEP.INI). The PDW will look in the default master dependency file for Visual Basic 6.0 (VB6DEP.INI). Information that is placed in the default master dependency file overrides that which might be found elsewhere.
- The Setup Wizard and PDW will look for a dependency file named MyOCX.DEP. If the dependency file is found, the wizard will search for the section entitled [MyOCX.OCX].
- It will search for a .DEP file associated with the parent of MyOCX.OCX and possibly continue up the parent chain until a section entitled [MyOCX.OCX] is located.
For additional information about how the Setup Wizard and PDW combinedependency files with the Visual Basic project and the VB5DEP.INI orVB6DEP.INI file to create a setup program, a Setup.LST, and a project .DEPfile, refer to the Distributing Your Application" section of the VisualBasic "Programmer's Guide."