VirtualBox

Changeset 66617 in vbox for trunk/src/VBox/Main/glue


Ignore:
Timestamp:
Apr 20, 2017 1:00:29 AM (8 years ago)
Author:
vboxsync
Message:

VBox/Main: bugref:3300: VBoxSVC from terminal server session is not 'visible' - fixed issues in Python VirtualBox API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/vboxapi.py

    r62900 r66617  
    439439        self.winerror = winerror
    440440
     441        # Setup client impersonation in COM calls
     442        try:
     443            pythoncom.CoInitializeSecurity(None,
     444                                       None,
     445                                       None,
     446                                       pythoncom.RPC_C_AUTHN_LEVEL_DEFAULT,
     447                                       pythoncom.RPC_C_IMP_LEVEL_IMPERSONATE,
     448                                       None,
     449                                       pythoncom.EOAC_NONE,
     450                                       None)
     451        except:
     452            # handle RPC_E_TOO_LATE (repeat call of CoInitializeSecurity)
     453            print("Warning: CoInitializeSecurity was already called")
     454            pass
     455       
     456
    441457        pid = GetCurrentProcess()
    442458        self.tid = GetCurrentThreadId()
     
    465481        win32com.client.gencache.EnsureDispatch('VirtualBox.VirtualBox')
    466482        win32com.client.gencache.EnsureDispatch('VirtualBox.VirtualBoxClient')
     483
     484        # instance of client used to support lifetime of VBoxSDS
     485        self.client = None
    467486
    468487        self.oIntCv = threading.Condition()
     
    508527        import win32com
    509528        from win32com.client import Dispatch
    510         client = win32com.client.Dispatch("VirtualBox.VirtualBoxClient")
    511         return client.virtualBox
     529        # Caching self.client is the trick for SDS
     530        # It's allows to keep the VBoxSDS in the memory
     531        # until the end of PlatformMSCOM lifetme
     532        if self.client is None:
     533            self.client = win32com.client.Dispatch("VirtualBox.VirtualBoxClient")
     534        return self.client.virtualBox
    512535
    513536    def getType(self):
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette