==============================
JF Software VB Modules
By Joshua Foster - JF Software
http://www.jfsoftware.net
jfsoftware@jfsoftware.net
August 16, 2002
==============================
FileAssociation class module
============================
Description: Manipulates file associations with applications.


Procedures:
===========
-------
AddVerb
-------
Syntax:       AddVerb(sAppKeyName As String, sVerb As String, sPath As String)
Description:  Adds an action verb to a file association, and makes it the default action (see AddVerbNoDefault for regular
              actions)
Parameters:   sAppKeyName - The application key name of the file association previously created.
              sVerb       - The verb to add to the file association (Example: "Open")
              sPath       - The path of the program to use for the verb

Example:
--------
See the example for Delete


----------------
AddVerbNoDefault
----------------
Syntax:       AddVerbNoDefault(sAppKeyName As String, sVerb As String, sPath As String)
Description:  Adds an action verb to a file association (see AddVerb for default actions)
Parameters:   sAppKeyName - The application key name of the file association previously created.
              sVerb       - The verb to add to the file association (Example: "Open")
              sPath       - The path of the program to use for the verb

Example:
--------
See the example for Delete


------
Create
------
Syntax:       Create(sExtension As String, sAppKeyName As String, sFileTypeName As String, sIconPath As String, intIconIndex _
              As Integer)
Description:  Creates a file association. (default)
Parameters:   sExtension    - The extension of the file to be associated (Example: ".jfs")
              sAppKeyName   - The application key name to associate (Example: "MyApp.Document")
              sFileTypeName - The name of the file type as shown in Windows Explorer (Example: "JFSoftware Document")
              sIconPath     - The path of the icon file or executable to extract an icon from.
              intIconIndex  - The index of the icon to extract.

Example:
--------
See the example for Delete


------
Delete
------
Syntax:       Delete(sExtension As String, sAppKeyName As String, [sVerb As String])
Description:  Deletes an action verb or an entire file association.
Parameters:   sExtension    - The extension of the file whose association is to be used (Example: ".jfs")
              sAppKeyName   - The application key name whose association is to be used (Example: "MyApp.Document")
              [sVerb]       - The action verb to delete from the file association (Example: "Open") (Optional; if not
                              specified, then the entire association will be deleted)

Example:
--------
Private cFileAssc As FileAssociation  'Define a FileAssociation object

Private Sub Form_Load()
Set cFileAssc = New FileAssociation  'Load the cFileAssc object
'Add a file association for .jfs files (will be called "JF Software Document") using the application key name "MyApp.Document"
'and using the icon with a 0 index in C:\MyApp.exe.
cFileAssc ".jfs", "MyApp.Document", "JF Software Document", "C:\MyApp.exe", 0
'Add a default verb to the file association "MyApp.Document" called "Open", to run C:\MyApp.exe
cFileAssc.AddVerb "MyApp.Document", "Open", "C:\MyApp.exe %1"
'Add a verb to the file association "MyApp.Document" called "Print", to run C:\MyApp.exe /p
cFileAssc.AddVerbNoDefault "MyApp.Document", "Print", "C:\MyApp.exe /p %1"
'Delete the "Open" verb.
cFileAssc.Delete ".jfs", "MyApp.Document", "Open"
'Delete the "MyApp.Document" association.
cFileAssc.Delete ".jfs", "MyApp.Document"
End Sub


-------------
GetAppKeyName
-------------
Syntax:       GetAppKeyName(sExtension As String) As String
Description:  Gets the application key name for an already associated file extension.
Return Value: Returns the application key name.
Parameters:   sExtension    - The extension of the file to read (Example: ".jfs")

Example:
--------
Private cFileAssc As FileAssociation  'Define a FileAssociation object

Private Sub Form_Load()
Set cFileAssc = New FileAssociation  'Load the cFileAssc object
MsgBox cFileAssc.GetAppKeyName(".jfs")  'MsgBox the application key name for .jfs files
End Sub


-------
IsAssoc
-------
Syntax:       IsAssoc(sAppKeyName As String, sVerb As String)
Description:  Checks if a verb has already been created.
Parameters:   sAppKeyName - The application key name of the file association to check.
              sVerb       - The verb to check. (Example: "Open")

Example:
--------
Private cFileAssc As FileAssociation  'Define a FileAssociation object

Private Sub Form_Load()
Set cFileAssc = New FileAssociation  'Load the cFileAssc object
MsgBox cFileAssc.IsAssoc("MyApp.Document", "open")  'MsgBox if the verb "open" exists for MyApp.Document files
End Sub
