Explore

Function Syntax (LM:explore <target>)
Current Version 1.0
Donate
Arguments
Symbol Type Description
target String / Integer Directory or ShellSpecialFolderConstants enumeration
Returns
Type Description
Boolean T if target is opened successfully, else nil.

Function Description

This subfunction uses the 'Explore' method of the Shell Object to open either a directory or special folder represented by a ShellSpecialFolderConstants Enumeration (a reference for which may be found here) in Windows Explorer.

The function will return T if the folder is opened successfully, else nil if either the folder is not valid, or if the method returned an error during execution.

The ShellSpecialFolderConstants Enumeration may be used to open special folders (such as Fonts, Program Files etc); note that the hexadecimal value for the enumeration found in the aforementioned reference should be converted to decimal before being supplied to the function.

Select all
;; Explore  -  Lee Mac
;; Opens a specified folder in a Windows Explorer window.
;; target - [int/str] Directory or ShellSpecialFolderConstants enum

(defun LM:explore ( target / rtn shl )
    (if (and (or (= 'int (type target)) (vl-file-directory-p target))
             (setq shl (vla-getinterfaceobject (vlax-get-acad-object) "shell.application"))
        )
        (progn
            (setq rtn (vl-catch-all-apply 'vlax-invoke (list shl 'explore target)))
            (vlax-release-object shl)
            (if (vl-catch-all-error-p rtn)
                (prompt (vl-catch-all-error-message rtn))
                t
            )
        )
    )
)

Example Function Calls

Example to Explore a Directory:

(LM:explore "C:\\My Folder\\My Subfolder")

Example to Explore the Printers Special Folder:

(LM:explore 4)

textsize

increase · reset · decrease

Designed & Created by Lee Mac © 2010