This library will allow you to execute any kind of instruction that you could run, for example, in the Start --> Run... window. You can run files, and the associated program will open the file, URLs and they will be open with the default browser, programs, folders... anything. You can also set what kind of window you want the program to be open in or shell a program and wait till it finishes or times-out. The library will return well documented errors or the handle of the executed program.
In fact this library is a very simple one, and will just save you the dirty job of calling the ShellExecute API.
09.03.98: Published version 1.0.
23.03.98 Version 1.01: Fixed a problem with the Hide option. From now on you should use the HideWindow option, although the old one is still there to maintain compatibility.
03.05.98 Version 1.02: Added the ShellNWait function.
11.06.98 Version 1.03: There was an error in the protection module of the library, that blocked the library and didn't allow it to work anymore. To solve it, I have removed the protection code; the 'Code' property is still there for compatibility reasons, but is not necessary anymore.
Function Execute (Operation As Operation, Command As String, Window As ShowWindow, [Parameters As String], [Directory As String], [hWnd As Long]) As Boolean.
ShellNWait (sInstruc As String, [lWait As Long], [WindowType As VbAppWinStyle = 1]) As Boolean. This method is not as flexible as the Execute one. Just put an instruction in sIntruc, set a time-out value in lWait (default is 0, which means there is not time-out) and the type of window you want to open in WindowType. The program will be shelled and the library will wait till the program shelled finishes or that time-out value expires.
Explanation about the Execute function:
Operation is one of this three options: "open", "explore" or "print", depending on what kind of operation you want to execute over the file or the command. At design-time the library will offer you these options.
Command is right that, the command that you want to execute.
The parameter Window lets you specify what kind of window you want to open the program with. The library has some predefined constants that will offer you. These are: HideWindow (the Hide option is obsolete), ShowMaximized, ShowMinimized, ShowMinimizedNoActive, ShowNoActivate, ShowNormal and ShowRestore. I hope that the constants explain themselves well.
Parameters are any additional parameters that you want to pass to the program. Optional.
Directory lets you set what directory you want the program to be run in. Optional.
In hWnd you can introduce the handle of the window that will be the parent of the executed program.
The function will return True if successful or False if there is an error.
Code (write-only). Here is where you have to introduce the right code for the library to work. This is not necessary after version 1.03.
LastError (read-only). If the command cannot be run, the library will store here the error code generated. it is one of the error constants that the library has, that are: AREX_ACCESS_DENIED, AREX_BAD_FORMAT, AREX_DDE_BUSY, AREX_DDE_FAIL, AREX_DDE_TIMEOUT, AREX_DLL_NOT_FOUND, AREX_FILE_NOT_FOUND, AREX_LIBRARY_IS_LOCKED, AREX_INVALID_ASSOCIATION, AREX_NO_ASSOCIATION, AREX_NO_ERROR, AREX_NOT_ENOUGH_MEMORY, AREX_OUT_OF_RESOURCES, AREX_PATH_NOT_FOUND, AREX_SHARING_VIOLATION, AREX_TIMEOUT and AREX_UNKNOWN_ERROR.
LastErrorDescription (read-only). If the command cannot be run, the library will store in this variable a description of the error, that you can use in a log file or a message box.
LastHandle (read-only). If the command is run successfully, here the library will store the handle of the program (when appropiate). This doesn't work with the ShellNWait method.
UnLocked (read-only). True or False, depending on if the right code was introduced and the library is unlocked, so you can use it. Always True after version 1.03.
© Alvaro Redondo, 1998. All Rights Reserved.