ParsePath

InstallShield 2014 » InstallScript Language Reference

The ParsePath function retrieves the specified part of an existing path. The function works with any valid path, including short paths, long paths, and UNC paths that may or may not include a specific file name. These are some sample paths that can be parsed with this function.

\Path1\Path2\Filename.exe
FileName
Filename.exe
\Path1\Path2\Filename
D:
D:\
\\Server Name\Share Name\Share Directory
Any other legal DOS path

Syntax

ParsePath ( svReturnString, szPath, nOperation );

Parameters

ParsePath Parameters

Parameter

Description

svReturnString

Returns the part of the path in szPath that is specified by nOperation.

szPath

Specifies the path to parse. When specifying a path that does not include a file name, you must append a backslash to the end of the path before passing it to ParsePath; otherwise the last part of the path will be interpreted as a file name.

nOperation

Specifies which element of the path to return. Pass one of the following predefined constants in this parameter:

DIRECTORY—Indicates that the path minus the disk drive letter and file name should be returned in svReturnString. When this option is used with a UNC path, ParsePath returns the path without the server and shared device name, and without the file name if one was specified. For example, the UNC path \\TheServer\TheSharedDevice\TheApp\TheFile.exe is returned in svReturnString as \TheApp\.
DISK—Indicates that the disk drive designation (drive letter followed by a colon) should be returned in svReturnString. When this option is used with a UNC path, ParsePath returns the server and shared device name. For example, the UNC path \\TheServer\TheSharedDevice\TheApp\TheFile.exe is returned in svReturnString as \\TheServer\TheSharedDevice.
EXTENSION_ONLY—Indicates that the file extension should be returned in svReturnString. It does not include the period.
FILENAME—Indicates that the complete file name (that is, with its file extension) should be returned in svReturnString.
FILENAME_ONLY—Indicates that the file name only (that is, without its file extension) should be returned in svReturnString.
PATH—Indicates that the path minus the file name should be returned in svReturnString. This option differs from DIRECTORY in that the drive designation (if specified in szPath) is included in the returned path. When szPath specifies a UNC path the server and shared device name are included in the returned path. For example, the UNC path \\TheServer\TheSharedDevice\TheApp\TheFile.exe is returned in svReturnString as \\TheServer\TheSharedDevice\TheApp\.

Return Values

ParsePath Return Values

Return Value

Description

0

Indicates that the function successfully parsed the path string.

< 0

Indicates that the function was unable to parse the path string.

See Also