ShellExt (signEZ)
Sub ShellExt(pCode As String, pPar1 As String, pCode2 As String)
Parameters
pCode | Command code for the action to perform See Command Line for more details |
pCode2 | Optional command code |
pPar1 | Expected parameter of the specified command code |
Example
...
NoteID$ = doc.NoteID
Call ShellExt("be", NoteID$, "")
ShellExt.lss code:
Option Declare
Declare Sub w32OSGetExecutableDirectory Lib "nnotes.dll" Alias "OSGetExecutableDirectory" (Byval directory As Lmbcs String)
Declare Sub w32OSGetIniFileName Lib "nnotes.dll" Alias "OSGetIniFileName" (Byval directory As Lmbcs String)
Declare Function w32GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long
Declare Function w32ShellExecute Lib "shell32.dll" Alias "ShellExecuteW" (Byval hwnd As Long, Byval lpszOp As Unicode String, Byval lpszFile As Unicode String, Byval lpszParams As Unicode String, Byval LpszDir As Unicode String, Byval FsShowCmd As Long) As Long
Function StripTerminator(Byval strString As String) As String
Dim intZeroPos As Integer
intZeroPos% = Instr(strString$, Chr$(0))
If intZeroPos% > 0 Then
StripTerminator$ = Left$(strString$, intZeroPos% - 1)
Else
StripTerminator$ = strString$
End If
End Function
Public Sub ShellExt( pCode As String, pPar1 As String, pCode2 As String )
Dim ns As New NotesSession
Dim db As NotesDatabase
Dim txt As String
Dim reply As Integer
Dim DataDir As String
Dim IniDir As String
Dim ExeDir As String
Dim DbPath As String
Dim tmp1 As String*255, tmp2 As String*255
Dim hDC As Long
Set db = ns.CurrentDatabase
Call w32OSGetIniFileName(tmp1$)
IniDir$ = StripTerminator( tmp1$ )
' Normaly, shouldn't be the case... always return a full path with the file.... But in case...
If Instr( IniDir$, ".ini" ) = 0 Then
If Right$( IniDir$, 1 ) <> "\" Then IniDir$ = IniDir$ + "\"
IniDir$ = IniDir$ + "notes.ini"
End If
Call w32OSGetExecutableDirectory(tmp2$)
ExeDir$ = StripTerminator( tmp2$ )
' Normaly, shouldn't be the case... always return a path with the \.... But in case...
If Right$( ExeDir$, 1 ) <> "\" Then ExeDir$ = ExeDir$ + "\"
ExeDir$ = ExeDir$ + "signEZ.exe"
DataDir$ = ns.GetEnvironmentString("Directory", True)
DataDir$ = Ucase$( DataDir$+"\" )
DbPath$ = db.FilePath$
If db.Server = "" Then ' We are using a database localy : get the Notes Data Root directory
If Instr(1, db.filePath$, DataDir$, 1) = 1 Then
DbPath$ = Right$( db.FilePath$ , Len(db.filePath$) - Len(DataDir$))
End If
End If
txt$ = { "=}+IniDir$+{" -unicode "}+Trim$(db.Server)+{" "}+Trim$(DbPath$)+{" -}+pCode$
If pCode2$ <> "" Then txt$ = txt$ + { -}+pCode2$
If pPar1$ <> "" Then txt$ = txt$ + { "}+pPar1$+{"}
Print ExeDir$+txt$
Const SW_SHOWNORMAL& = 1
hDC&= w32GetDesktopWindow()
Reply% = w32ShellExecute(hDC&, "open", ExeDir$, txt$, DataDir$, SW_SHOWNORMAL&)
End Sub