
#-Begin-----------------------------------------------------------------
$VBCode = @"
Option Strict On
Imports System
Imports Microsoft.VisualBasic
Namespace VBCode
Public Class VB
Public Shared Function Hello1() As String
Return "Hello World!"
End Function
Public Function Hello2(ByVal Name As String) As String
Return "Hello " & Name & "!"
End Function
Public Sub Hello3(ByVal Name As String)
MsgBox(Name, MsgBoxStyle.OkOnly, "Hello")
End Sub
End Class
End Namespace
"@;
Add-Type -TypeDefinition $VBCode -Language VisualBasic
$VB = new-Object VBCode.VB
[VBCode.VB]::Hello1()
$VB.Hello2("Stefan")
$VB.Hello3("Stefan")
#-End-------------------------------------------------------------------
"-Begin-----------------------------------------------------------------
Program zUseVBSharp.
"-TypePools---------------------------------------------------------
Type-Pools OLE2 .
"-Constants--------------------------------------------------------
Constants OUTPUT_CONSOLE Type i Value 0.
Constants OUTPUT_WINDOW Type i Value 1.
Constants OUTPUT_BUFFER Type i Value 2.
"-Variables---------------------------------------------------------
Data PS Type OLE2_OBJECT.
Data Result Type i Value 0.
Data strResult Type String Value ''.
Data tabResult Type Table Of String.
Data PSCode Type String Value ''.
Data InclName Type SOBJ_NAME Value 'ZPOWERSHELL'.
"-Main--------------------------------------------------------------
Create Object PS 'SAPIEN.ActiveXPoSHV3'.
If sy-subrc = 0 And PS-Handle <> 0 And PS-Type = 'OLE2'.
Call Method Of PS 'Init' = Result Exporting #1 = 0.
If Result = 0.
Call Method Of PS 'IsPowerShellInstalled' = Result.
If Result <> 0.
Set Property Of PS 'OutputMode' = OUTPUT_BUFFER.
"-Read PowerShell code from include file--------------------
Call Function 'ZREADINCLASSTRING'
Exporting I_InclName = InclName
Importing E_strIncl = PSCode.
Call Method Of PS 'Execute' Exporting
#1 = PSCode.
Call Method Of PS 'OutputString' = strResult.
Split strResult At cl_abap_char_utilities=>cr_lf
Into Table tabResult.
Loop At tabResult Into strResult.
Write: / strResult.
EndLoop.
EndIf.
EndIf.
Free Object PS.
EndIf.
"-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 |
---|---|
3 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |