File.GetDefaultViewer

string File.GetDefaultViewer ( 

string FileExtension )

Example 1

pdf_viewer = File.GetDefaultViewer(".pdf");

Gets the path to the program that is used by default to view PDF files on the user's system, and stores it in the pdf_viewer variable.

Example 2

default_text_editor = File.GetDefaultViewer(".txt");

Gets the path to the user's default viewer for text files, and stores it in a variable called default_text_editor.

Example 3

-- Get the default viewer for files with the extension .sf7.
viewer_path = File.GetDefaultViewer(".sf7");

-- If there is no program association for .sf7, display a message.
-- If there is, get the directory where the program is located.
if viewer_path == "" then
    result = Dialog.Message("Notice", "There is no program association for the .sf7  file extension.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
else
    -- Split the path into drive, folder and filename to store in a table.
    tbPath = String.SplitPath(viewer_path);

    -- Concatenate the drive and folder parts.
    Folder_Path = String.Concat(tbPath.Drive, tbPath.Folder);

    -- Display the path to the user.
    result = Dialog.Message("Target Path", "The associated program is located in "..Folder_Path, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end

Gets the path to the user's default viewer for files with the extension .sf7 in order to get the directory of that program. If there is no program association for that file type, a message is shown to the user. If there is, the drive and folder is extracted and shown to the user.

See also:  Related Actions