import _winreg
import os
from _winreg import *

is_64="SOFTWARE\\WOW6432Node\\TeamViewer"
is_32="SOFTWARE\\TeamViewer"

if 'PROGRAMFILES(X86)' in os.environ.keys():
    try:
        hKey = _winreg.OpenKeyEx(_winreg.HKEY_LOCAL_MACHINE, is_64,0,_winreg.KEY_READ | _winreg.KEY_WOW64_64KEY)
        path=is_64
    except:
        path = is_32
else:
    path=is_32


    
def getMDACversion(path):
    
    # Open the key and return the handle object.
    hKey = _winreg.OpenKeyEx(_winreg.HKEY_LOCAL_MACHINE, path,0,_winreg.KEY_READ | _winreg.KEY_WOW64_64KEY)
                          
    # Read the value.                      
    result = _winreg.QueryValueEx(hKey, "ClientID")

    # Close the handle object.
    _winreg.CloseKey(hKey)

    # Return only the value from the resulting tuple (value, type_as_int).
    return result[0]

try:
    k = OpenKeyEx(HKEY_LOCAL_MACHINE, path,0,_winreg.KEY_READ | _winreg.KEY_WOW64_64KEY)

    if k:
        print "\nTEAM VIEWER is installed in this Endpoint\n"
        client_ID=getMDACversion(path)
        print "Client ID : "+str(client_ID)
        
except:
    print "Please ensure that the Endpoint has TEAM VIEWER INSTALLED"