ShellExecuteW() を使用します。このようにして、より詳細に制御できます
1) SHELL32.dll の一部として外部関数として含めます。
Library name: SHELL32.DLL
ThreadSafe: No
Function: ShellExecuteW
Description: The ShellExecute function opens or prints a specified file. The file can be an executable file or a document file. See ShellExecuteEx also.
Export Ordinal: 0
Returns
Number: DWORD
Parameters
Window Handle: HWND
String: LPWSTR
String: LPWSTR
String: LPWSTR
String: LPWSTR
Number: INT
2)次の構文でexeを実行します(または詳細については「ShellExecute」を参照してください)
Call ShellExecuteW( hWndNULL, "open", "C:\\Program Files (x86)\\Gupta\\TeamDeveloper6.2.1\\Your.exe", STRING_Null, STRING_Null, SW_SHOWNORMAL )
3) 必要に応じてラッパー関数を記述して、必要なリターン コードを確認できるようにします。
Select Case nRet
Case SE_ERR_FNF
If spApplication
Set sError = 'Either the Application, or the specified file was not found. ' || sCTRL || sCTRL ||
'Check the Application ' || spApplication || ' and any Compatibility Packs have been installed on this machine .' || sCTRL || sCTRL ||
'Check the file ' || spFile || ' exists. '
Else
Set sError = 'The specified file was not found. ' || sCTRL || sCTRL ||
'Check the file ' || spFile || ' exists. '
Break
Case SE_ERR_PNF
Set sError = 'The specified Path was not found'
Break
Case SE_ERR_ACCESSDENIED
Set sError = 'The operating system denied access to the specified file.'
Break
Case SE_ERR_ASSOCINCOMPLETE
Set sError = 'The filename association is incomplete , invalid, or has not been defined within Windows'
Break
Case SE_ERR_DDEBUSY
Set sError = 'The DDE transaction could not be completed because other DDE transactions are being processed.'
Break
Case SE_ERR_DDEFAIL
Set sError = 'The DDE transaction failed.'
Break
Case SE_ERR_DDETIMEOUT
Set sError = 'The DDE transaction could not be completed because the request timed out'
Break
Case SE_ERR_NOASSOC
Set sError = 'There is no application associated with the given filename extension'
Break
Case SE_ERR_OOM
Set sError = 'There was not enough memory to launch the application'
Break
Case SE_ERR_SHARE
Set sError = 'Another user has this document open.'
Break
Case 0
Set sError = 'The operating system is out of memory or resources'
Break
Default
Break
If nRet <=32
If spApplication
Call SalMessageBox( sError || sCTRL || sCTRL ||
'File Name = ' || spFile || sCTRL || sCTRL ||
'Application Name = ' || spApplication , 'Application or File Open Error' , MB_IconStop | MB_Ok )
Else
Call SalMessageBox( sError || sCTRL || sCTRL ||
'File Name = ' || spFile , 'File Open Error' , MB_IconStop | MB_Ok )
If nRet = SE_ERR_NOASSOC or nRet = SE_ERR_ASSOCINCOMPLETE
! Now open the OpenAs dialog from Windows to select an application from a list or browse.
Call ShellExecuteW( hWndNULL, "open", "rundll32.exe", "shell32.dll,OpenAs_RunDLL " || spFile, STRING_Null, npShowState )
Set bOk = FALSE