Article ID: 192352
Article Last Modified on 7/1/2004
*-- Code begins here.
PROCEDURE ShellDoc()
LPARAMETERS lsFile
*-- Defines from Winuser.h
*-- These constants will be used with the
*-- ShellExecute function.
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_SHOWMAXIMIZED 3
#define SW_MAXIMIZE 3
#define SW_SHOWNOACTIVATE 4
#define SW_SHOW 5
#define SW_MINIMIZE 6
#define SW_SHOWMINNOACTIVE 7
#define SW_SHOWNA 8
#define SW_RESTORE 9
#define SW_SHOWDEFAULT 10
#define SW_FORCEMINIMIZE 11
#define SW_MAX 11
#define SE_ERR_NOASSOC 31
*-- GetDesktopWindow gives us a window handle to
*-- pass to ShellExecute.
DECLARE INTEGER GetDesktopWindow IN user32.dll
DECLARE INTEGER GetSystemDirectory IN kernel32.dll ;
STRING @lsBuffer, ;
INTEGER liSize
*-- ShellExecute is of the following format:
*-- HINSTANCE ShellExecute(
*-- HWND hwnd,
*-- LPCTSTR lpOperation,
*-- LPCTSTR lpFile,
*-- LPCTSTR lpParameters,
*-- LPCTSTR lpDirectory,
*-- INT nShowCmd
*-- );
DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER, ;
STRING @lsOperation, ;
STRING @lsFile, ;
STRING @lsParameters, ;
STRING @lsDirectory, ;
INTEGER liShowCmd
lsOperation = "open"
liRet = ShellExecute(GetDesktopWindow(), @lsOperation, @lsFile, ;
"", "", SW_SHOWNORMAL)
IF liRet = SE_ERR_NOASSOC && No association exists
lsSysDir = SPACE(260) && MAX_PATH, the maximum path length
*-- Get the system directory so that we know
*-- where Rundll32.exe resides.
liRet = GetSystemDirectory(@lsSysDir, LEN(lsSysDir))
lsSysDir = SUBSTR(lsSysDir, 1, liRet)
lsRun = "RUNDLL32.EXE"
lsParameters = "shell32.dll,OpenAs_RunDLL "
liRet = ShellExecute(GetDesktopWindow(), "open", lsRun,;
lsParameters + lsFile, lsSysDir, SW_SHOWNORMAL)
ENDIF
ENDPROC
*-- Code ends here.
SET PROCEDURE TO ShellDoc
DO ShellDoc WITH <cFilename>
Keywords: kbhowto kbapi kbffc KB192352