! 發展單位:風禹科技驗證有限公司 ! 撰寫人:鄭子璉(Tzu-Lien, Cheng, 璉璉) ,成大水博肄,微軟最有價值專家 ! Web: http://tlcheng.twbbs.org/TLCheng/ E-Mail: qvb3377@ms5.hinet.net ! -------------------------------------------------------------------------------------- Module modShell Use dfwinty Use shell32 Use kernel32 Use modFileTool Integer, Parameter :: lpOperation_edit = 1 Integer, Parameter :: lpOperation_explore = 2 Integer, Parameter :: lpOperation_open = 3 Integer, Parameter :: lpOperation_print = 4 Integer, Parameter :: lpOperation_properties = 5 Contains Character(MAX_PATH) Function myFindExecutable(lpFullFilename) Character*(*) :: lpFullFilename Character(MAX_PATH) :: lpResult, lpFile, lpDirectory Integer :: summy, pFile pFile = Loc(lpFile) summy = GetFullPathName(lpFullFilename, MAX_PATH, lpDirectory, pFile) summy = FindExecutable(lpFile, lpDirectory, lpResult) myFindExecutable = lpResult End Function Integer Function myWinExec(lpFile, lpParameters, lpDirectory, nShowCmd, bWait) Character*(*) :: lpFile, lpParameters, lpDirectory Integer :: nShowCmd Logical(4) :: bWait Optional :: lpParameters, lpDirectory, nShowCmd, bWait Integer :: pShowCmd Logical :: lWait Character(MAX_PATH) :: sOldPath Character(2*MAX_PATH) :: RunFilename If (Present(bWait)) Then lWait = bWait Else lWait = .True. End If If (Present(nShowCmd)) Then pShowCmd = nShowCmd Else pShowCmd = SW_SHOWNORMAL End If If (Present(lpDirectory)) Then sOldPath = mySetCurrentDirectory(lpDirectory) End If If (.Not. Present(lpParameters)) Then RunFilename = lpFile // Char(0) Else RunFilename = lpFile // " " // lpParameters // Char(0) End If myWinExec = WinExec(RunFilename, pShowCmd) If (Present(lpDirectory)) Then sOldPath = mySetCurrentDirectory(sOldPath) End If End Function Integer Function myShellExecute(hWnd, nOperation, lpFile, lpParameters, lpDirectory, nShowCmd) Character*(*) :: lpFile, lpParameters, lpDirectory Integer :: hWnd, nOperation, nShowCmd, pShowCmd Optional :: lpParameters, lpDirectory, nShowCmd !DEC$ Attributes Reference, Allow_Null :: lpFile, lpParameters, lpDirectory Character(12) :: lpOperation If (Present(nShowCmd)) Then pShowCmd = nShowCmd Else pShowCmd = SW_SHOWNORMAL End If Select Case (nOperation) Case (lpOperation_edit) lpOperation = 'edit'C Case (lpOperation_explore) lpOperation = 'explore'C Case (lpOperation_open) lpOperation = 'open'C Case (lpOperation_print) lpOperation = 'print'C Case (lpOperation_properties) lpOperation = 'properties'C Case Default lpOperation = ''C End Select myShellExecute = ShellExecute(hWnd, lpOperation, lpFile, lpParameters, lpDirectory, pShowCmd) End Function End Module