Assoc function
Requires: GfaWinx.lg32
Requires: shlwapi.inc
Purpose
Assoc is a wrapper for the AssocQueryString API which retrieves a file association-related string from the registry.
Syntax
a$ = Assoc(file$ [,assocstr%])
a$, file$ | : string expressions |
assocstr% | : integer expression |
Description
By default Assoc returns the full path of the executable for a file or for an extension (or ProgID and CLSID). By passing a different value for assocstr% other properties of the file can be obtained. Gfawinx does not define the constants used in AssocQueryString, but shlwapi.inc does. After including shlwapi.inc the following constants can be used:
- ASSOCSTRCOMMAND = 1, // shell\verb\command string
- ASSOCSTREXECUTABLE, // the executable part of command string
- ASSOCSTRFRIENDLYDOCNAME, // friendly name of the document type
- ASSOCSTRFRIENDLYAPPNAME, // friendly name of executable
- ASSOCSTRNOOPEN, // noopen value
- ASSOCSTRSHELLNEWVALUE, // query values under the shellnew key
- ASSOCSTRDDECOMMAND, // template for DDE commands
- ASSOCSTRDDEIFEXEC, // DDECOMMAND to use if just create a process
- ASSOCSTRDDEAPPLICATION, // Application name in DDE broadcast
- ASSOCSTRDDETOPIC, // Topic Name in DDE broadcast
- ASSOCSTRINFOTIP, // info tip for an item, or list of properties to create info tip from
- ASSOCSTRQUICKTIP, // same as ASSOCSTRINFOTIP, except, this list contains only quickly retrievable properties
- ASSOCSTRTILEINFO, // similar to ASSOCSTRINFOTIP - lists important properties for tileview
- ASSOCSTRCONTENTTYPE, // MIME Content type
- ASSOCSTRDEFAULTICON, // Default icon source
- ASSOCSTRSHELLEXTENSION, // Guid string pointing to the Shellex\Shellextensionhandler value.
- ASSOCSTRDROPTARGET, // The CLSID of DropTarget
- ASSOCSTRDELEGATEEXECUTE, // The CLSID of DelegateExecute
- ASSOCSTRSUPPORTEDURIPROTOCOLS,
- ASSOCSTRPROGID, // The ProgId provided by the app associated with the file type or uri scheme based on user default settings.
- ASSOCSTRAPPID, // The AppUserModelID of the app associated with the file type or uri scheme based on user default settings.
- ASSOCSTRAPPPUBLISHER, // THe publisher of the app associated with the file type or uri scheme based on user default settings.
- ASSOCSTRAPPICONREFERENCE // The icon reference of the app associated with the file type or uri scheme based on user default settings.
Example
$Library "gfawinx"
$Library "shlwapi.inc"
Debug.Show
Trace Assoc(".txt")
Trace Assoc(".txt", ASSOCSTR_FRIENDLYAPPNAME)
Displays something like this:
TRACE:(1):Assoc(".txt") = D:\Develop\notepad2\Notepad2.exe
TRACE:(2):Assoc(".txt", ASSOCSTR_FRIENDLYAPPNAME) = Notepad2
{Created by Sjouke Hamstra; Last updated: 09/05/2020 by James Gaite}