Environment and Process Functions
Environment and Process Functions
Environment and process functions allow you to get and set registry and environment values; and also to run internal and external commands.
GetEnv (env_name)
Returns the value of the environment variable given in env_name. Returns an empty string if the environment variable does not exist.
GetReg (reg_key_name)
Returns the value associated with the registry key named reg_key_name. The key value is stored under the key path: HKEY_CURRENT_USER/Software/Source Dynamics/Source Insight/4.0. Returns an empty string if the key does not exist.
The SetReg and GetReg functions give you a way to store your own Source Insight related information between sessions.
IsCmdEnabled (cmd_name)
Returns TRUE if the command specified in cmd_name is currently enabled. A command would not be enabled if Source Insight cannot run it due the state of the program. For example, the Save command is not enabled if there are no open source file windows.
PutEnv (env_name, value)
Sets the environment variable named env_name to value.
RunCmd (cmd_name)
Runs the command specified by cmd_name. This allows you to run special commands, namely custom commands, which are defined with the Custom Commands command.
RunCmdLine (sCmdLine, sWorkingDirectory, fWait)
Spawns the given command line string in sCmdLine. This returns non-zero if successful, or zero if errors.
If sWorkingDirectory is not Nil, then the working directory is used. If sWorkingDirectory is Nil, then the current project home directory iis used.
If fWait is non-zero, then the function will not return until the process is finished. Otherwise, it returns immediately. If the process is another windows application, it returns immediately regardless of fWait.
SetReg (reg_key_name, value)
Sets the value associated with the registry key named reg_key_name. The key value is stored under the key path: HKEY_CURRENT_USER/Software/Source Dynamics/Source Insight/4.0. The key is created if it doesn't exist already.
The SetReg and GetReg functions give you a way to store your own Source Insight related information between sessions.
ShellExecute (sVerb, sFile, sExtraParams, sWorkingDirectory, windowstate)
Performs a "ShellExecute" function on the given file. This lets you tell the Windows shell to perform an operation on a specified file.
The nice thing about ShellExecute is that you don't need to know what specific application is registered to handle a particular type of file. For technical background information, see the "ShellExecute" function in the
Windows Shell API documentation.
Source Insight 4 User Guide 391
Environment and Process Functions
ShellExecute Parameters
Table 5.7: ShellExecute Parameters
Parameter Meaning
sVerb sFile sExtraParams sWorkingDir windowstate
A single word that specifies the action to be taken.
See the table below for possible values.
The filespec parameter can be any valid path. Use double quotes around complex path names with embedded spaces. It can also be the name of an executable file.
Optional parameters: It specifies the parameters to be passed to the application that ultimately runs . The format is determined by the verb that is to be invoked, and the application that runs.
The working directory when the command runs. If empty, then the project home directory is used.
An integer that specifies the size and state of the window that opens. Valid values are: 1 = normal, 2 = minimized, 3 = maximized.
sVerb Values
The sVerb parameter is a single word string that specifies the action to be taken by Shell Execute.
Table 5.8: Values for sVerb Parameter sVerb Value
edit explore open
Meaning
Opens an editor for the file.
The function explores the folder specified.
print
The function opens the file specified. The file can be an executable file or a document file. It can also be a folder.
The function prints the document file specified. If filespec is not a document file, the function will fail.
Displays the file or folder's properties. properties find
Launches the Find Files application found on the Start menu.
"" (empty string) Ships this parameter to ShellExecute.
392 Source Insight 4 User Guide