Code:
Function W_Email_Tape_MCM() As Long 'z_mcm_DoTheShellEx () As Long Local SEI As ShellExecuteInfo, Stat As Long, E As Long Local hWaitProcess As Long Local lpVerb As Asciiz * 20, lpParameters As Asciiz * 20, lpDirectory As Asciiz * 20, lpFile As Asciiz * %MAX_PATH Local TimeOut2 As Long ' "timeout" is another un-hilited "reserved" word which is truly only reserved ' in the context of a TCP or UDP verb and can only be found with "search." ' The error message if you use 'timeout' as a variable name is ' "statement expected," which is a useless error message. ' ' ******************************************************* ' My stuff common_Locals ' Local ppr As String Pointer Local subj, body As String 'find name only i = InStr(-1, Prm.Current_File_Name, "\") + 1 subj$ = Mid$(Prm.Current_File_Name, i) subj$ = $Title & " - " & Trim$(subj$) ' Body$ = Tape_to_String Replace $CrLf With "%0a " In Body$ s$ = "MailTo:" & _ "?Subject=" & subj$ & _ "&Body=" & Body$ & _ Chr$(0) ? s$, %top, "body" 'shows fine lpVerb = "Open" ' lpParameters = "" lpFile = s$ '"C:\TestShExec.txt" Timeout2 = 30 * 1000 ' 30 secs ' ' ******************************************************* ' ' Select Case ControlId ' Case %IDC_OPEN_DOCUMENT ' lpVerb = "Open" ' lpParameters = "" ' lpFile = "C:\TestShExec.txt" ' Timeout2 = 30 * 1000 ' 30 secs ' Case %IDC_PRINT_DOCUMENT ' lpVerb = "PRINT" ' lpFile = "C:\TestShExec.txt" ' lpParameters = "" ' Timeout2 = 60 * 1000 ' 60 secs ' Case %IDC_OPEN_PROGRAM ' 'Windows Program ' lpVerb = "Open" ' lpFile = "notepad.exe" ' lpParameters = "C:\TestShExec.txt" ' ' DOS PROGRAM ' lpFile ="C:\Software_Development\Pb-Dos\Exe\horse.exe" ' lpParameters = "" ' Timeout2 = 30 * 1000 ' 30 secs ' End Select ' SEI.cbSize = SizeOf(SEI) SEI.fmask = %SEE_MASK_NOCLOSEPROCESS SEI.hWnd = hdlg 'hWnd SEI.lpVerb = VarPtr(lpVerb) SEI.LpFile = VarPtr(lpFile) SEI.lpParameters = VarPtr (lpParameters) SEI.lpDirectory = %Null SEI.nShow = %SW_SHOW ' should be zero for a document file PER MSDN DOC. ' MSDN DOC IS WRONG, use SW_SHOW! SEI.hInstApp = 0 ' updated by function SEI.lpIdList = %Null ' here down to hprocess ignored unless appropriate mask included in fmask SEI.lpClass = %Null SEI.hkeyClass = %Null SEI.dwHotKey = %Null SEI.Item = %Null SEI.hProcess = 0 ' will be updated by ShellExecuteEx If IsTrue ShellExecuteEx(SEI) Then ' function succeeded and returned hWaitProcess = SEI.hProcess Stat = WaitForSingleObjectEx (hWaitProcess, Timeout2, 0) 'No different Sleep 10000 '10 secs Select Case Stat Case -1& E = GetLastError 'gives Invalid Handle error 6 MsgBox "Wait Failed:" & SystemErrorMessageText (E) Case %WAIT_OBJECT_0 MsgBox "Wait returned from " & lpVerb & " on process completion" Case %WAIT_TIMEOUT MsgBox "Wait returned from " & lpVerb & " on Timeout" Case Else MsgBox "Unexpected Return, code=" & Str$(Stat) End Select CloseHandle hWaitProcess Else E = GetLastError MsgBox "ShellExecuteEx failed:" & Str$(e) ' SystemErrorMessageText(E) End If End Function '/mcm '
Code:
Sub W_Email_Tape '_NotUsed common_Locals Local ppr As String Pointer Local subj, body As String 'find name only i = InStr(-1, Prm.Current_File_Name, "\") + 1 subj$ = Mid$(Prm.Current_File_Name, i) subj$ = $Title & " - " & Trim$(subj$) ' Body$ = Tape_to_String Replace $CrLf With "%0a " In Body$ ' Body$ = Right$(Body$, 2012) em20: ln = Len(Body$) If ln > 2000 Then ?"The detailed Tape is too long to send from here." & $CrLf & $CrLf & _ " Try just sending the totals and summary (File Stuff>E),"& $CrLf & _ "and Attaching the file saved as '.Txt' from ." & _ "your email client." _ ,%top, $Title Exit Sub End If '2529 in orig too long? ' n = 2000 ' Body$ = Left$(body$, n) ' Subj$ = Using$(" used #, of #, ", Len(Body$), ln) s$ = "MailTo:" & _ "?Subject=" & subj$ & _ "&Body=" & Body$ & _ Chr$(0) ppr = StrPtr(s$) ShellExecute 0, "open", ByVal ppr, ByVal 0&, ByVal 0&, %SW_SHOWNORMAL ' n = 5000 ' w_WaitShell(s$, n) End Sub '
The same Tape to send was used in each case.
======================================================
"Men are not disturbed by things,
but the view they take of things."
Epictetus (55-135 A.D.)
"What about things like bullets?"
Herb Kimmel, Behavioralist, Professor of Psychology,
upon hearing the above quote (1981)
======================================================
Leave a comment: