Applies To:
  • CitectSCADA 6.10, 7.xx
  • CitectHMI 6.10, 7.xx

Summary:
How do you open an external application, document, folder, shortcut, e-mail, or web page from Citect? 

Solution:
The Cicode Exec() function will run an application (EXE file). Unfortunately, it can't open documents in the associated application unless you specify the exact application path and name (Q4241), or open a DOS window (Q2138). However, the Windows ShellExecute() API function is much more flexible. The attached Cicode function ExecEx() shows how to use this in a variety of ways: 
  • Open Windows' Find dialog
  • Open Windows Explorer for a specific folder
  • Open a document in its associated application
  • Print a document
  • Open an application
  • Open a web page
  • Create an email message
  • Open a shortcut
  • Run a DOS (command prompt) command
  • Find files or folders

The CSV_Include project has a similar function named CSV_WinUtl_ShellExec(), but it does not accept path substitutions and it uses the old DLLCall() function which limits the combined argument length. As of Citect 7.00, its help page is incomplete and has the arguments in the wrong order. This is being corrected.

Note: This code uses the DLLCallEx() function which is only available in Citect 6.10 and later. In older releases, the DLLCall() function can be used, but it is necessary to combine all the DLL function arguments into one string which will limit the length of the arguments to 255 characters. 


Keywords: