'-Begin-----------------------------------------------------------------
'-Resource section----------------------------------------------------
#Resource TypeLib 1, "COMMsgBox.tlb"
'-Directives----------------------------------------------------------
#Compile DLL
#Dim All
'-Constants-----------------------------------------------------------
$LIBID = Guid$("{D1AA85A8-F8AD-4A0E-9DE8-942543A3741F}")
$CLSID = Guid$("{084BDEC8-ACA0-4068-A6B7-778785D64521}")
$IID = Guid$("{A5EBE762-82A4-44A9-9A2E-2BE6CF102564}")
'-COM directives------------------------------------------------------
#Com Doc "COMMsgBox"
#Com Name "COMMsgBox", 1.0
#Com Guid $LIBID
#Com TLib On
'-Main----------------------------------------------------------------
Class COMMsgBox $CLSID As Com
Interface ICOMMsgBox $IID : Inherit IDispatch
'-Method BoxMsg-------------------------------------------------
Method BoxMsg()
MsgBox("This is a Test")
End Method
End Interface
End Class
'-End-------------------------------------------------------------------
"-Begin-----------------------------------------------------------------
Program Z_TEST.
"-TypePools---------------------------------------------------------
Type-Pools OLE2.
"-Variables---------------------------------------------------------
Data MsgBox Type OLE2_Object.
"-Main--------------------------------------------------------------
Create Object MsgBox 'COMMSGBOX'.
If sy-subrc = 0 And MsgBox-handle <> 0 And MsgBox-type = 'OLE2'.
Call Method Of MsgBox 'BoxMsg'.
Free Object MsgBox.
EndIf.
"-End-------------------------------------------------------------------
; Begin-----------------------------------------------------------------
; Directives----------------------------------------------------------
EnableExplicit
; Function Terminate Processes----------------------------------------
Procedure TerminateProcesses(Name.s, ExitCode = 0)
; Variables-------------------------------------------------------
Protected result
Protected processID
Protected hProcess
Protected Process.PROCESSENTRY32
Protected ProcSnap = CreateToolhelp32Snapshot_(#TH32CS_SNAPPROCESS, 0)
If ProcSnap <> #ERROR_INVALID_HANDLE
Process\dwsize = SizeOf(PROCESSENTRY32)
If Process32First_(ProcSnap, Process) = #True
While Process32Next_(ProcSnap, Process) <> #False
If Trim(PeekS(@Process\szExeFile,#MAX_PATH)) = Name.s
processID = Process\th32ProcessID
If processID
hProcess = OpenProcess_(#PROCESS_TERMINATE, #False, processID)
If hProcess
If TerminateProcess_(hProcess, ExitCode)
result = #True
EndIf
CloseHandle_(hProcess)
EndIf
EndIf
EndIf
Wend
EndIf
CloseHandle_(ProcSnap)
EndIf
ProcedureReturn result
EndProcedure
; Main----------------------------------------------------------------
If Not TerminateProcesses(ProgramParameter(0))
MessageRequester("TerminateProcess",
"Failed to terminate " + ProgramParameter(0) + " processes")
EndIf
; End-------------------------------------------------------------------
End
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
6 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 |