Quantcast
Channel: Scripting Languages
Viewing all articles
Browse latest Browse all 42

How to make SAP ROT Wrapper library available in a 64-bit environment

$
0
0

Hello community,

 

the SAP ROT (Running Object Table) Wrapper library offers the possibility to get access to the ROT. But the library is only for x86 - 32-bit. With the standard installation is it not possible to use the library with x64 programming languages. Here is a description how to make the SAP ROT Wrapper library available for this kind of environments:

 

  1. Add in the registry the entry DllSurrogate in the key HKCR\Wow6432Node\AppID\{E2779C61-F87E-4038-98A0-1D9E71334706} without a value.
    999.JPG
  2. Create a new key in HKLM\Software\Classes\AppID with the GUID {E2779C61-F87E-4038-98A0-1D9E71334706} without any values.

 

That is all, now you can enjoy the the SAP GUI ROT Wrapper in an x64 environment.

 

Here a test script in PowerShell:

 

#-Begin-----------------------------------------------------------------

 

  #-Sub Main------------------------------------------------------------

    Function Main() {

 

      [Reflection.Assembly]::LoadFile($PSScriptRoot + "\saprotwrlib.dll") > $Null

      [Reflection.Assembly]::LoadFile($PSScriptRoot + "\sapfewselib.dll") > $Null

 

      $Size = [System.IntPtr]::Size

      If ($Size -eq 4) {

        Write-Host "`r`nVersion x86`r`n"

      }

      ElseIf ($Size -eq 8) {

        Write-Host "`r`nVersion x64`r`n"

      }

 

      $Wrapper = New-Object -ComObject "SapROTWr.SapROTWrapper"

      #[Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic") > $Null

      #$Wrapper = [Microsoft.VisualBasic.Interaction]::CreateObject("SapROTWr.SapROTWrapper")

      If ($Wrapper -eq $Null) {

          Break

      }

 

      $RotSAPGUI = $Wrapper.GetROTEntry("SAPGUI")

      If ($RotSAPGUI -eq $Null) {

        Break

      }

 

      $Application = $RotSAPGUI.GetType().InvokeMember("GetScriptingEngine",

        [System.Reflection.Bindingflags]::InvokeMethod,

        $null, $RotSAPGUI, $null, $null, $null, $null)

      [sapfewselib.GuiApplication]$Application =

        [System.Runtime.InteropServices.Marshal]::CreateWrapperOfType($Application,

        [sapfewselib.GuiApplicationClass])

      If ($Application -eq $Null) {

        Break

      }

 

      $Connection = $Application.Children.Item(0)

      [sapfewselib.GuiConnectionClass]$Connection =

        [System.Runtime.InteropServices.Marshal]::CreateWrapperOfType($Connection,

        [sapfewselib.GuiConnectionClass])

      If ($Connection -eq $Null) {

        Break

      }

 

      $Session = $Connection.Children.Item(0)

      [sapfewselib.GuiSession]$Session =

        [System.Runtime.InteropServices.Marshal]::CreateWrapperOfType($Session,

        [sapfewselib.GuiSessionClass])

      If ($Session -eq $Null) {

        Break

      }

 

      $SessionInfo = $Session.Info

      [sapfewselib.GuiSessionInfo]$SessionInfo =

        [System.Runtime.InteropServices.Marshal]::CreateWrapperOfType($SessionInfo,

        [sapfewselib.GuiSessionInfoClass])

      If ($SessionInfo -eq $Null) {

        Break

      }

 

      Write-Host $SessionInfo.SystemName

      Write-Host $SessionInfo.Client

      Write-Host $SessionInfo.Transaction

 

    }

 

  #-Main----------------------------------------------------------------

    Main

 

#-End-------------------------------------------------------------------

 

998.jpg

 

Hint:It could be possible that the SAP GUI ROT wrapper has another GUID. You can find it in the GuidAttribute of the manifest of the assembly.

 

Enjoy it.

 

Cheers

Stefan


Viewing all articles
Browse latest Browse all 42

Trending Articles