MSI Factory 2.3

File.GetDefaultViewer

File.GetDefaultViewer

This is the first topic This is the last topic  

File.GetDefaultViewer

This is the first topic This is the last topic  

OverviewExamples

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 .jpg.

viewer_path = File.GetDefaultViewer(".jpg");

 

-- If there is no program association for .jpg, 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 .jpg  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 .jpg 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


Learn More: Indigo Rose Software - MSI Factory - Buy Now - Contact Us