import os, configparser, winreg

def registrytest(keypath):
    key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, keypath, 0, winreg.KEY_ALL_ACCESS)
    try:
        i = winreg.QueryInfoKey(key)[0]  #sub keys 
        for j in range( 0, i):
            subkey_name = winreg.EnumKey(key, j)
            print ("1:", subkey_name)
            subkey = winreg.OpenKey(key, subkey_name)
            try:
                m = winreg.QueryInfoKey(subkey)[1]  #values 
                print ("2:", m)
                for n in range( 0, m):
                    print ("3:", winreg.EnumValue(subkey, n))
                InstallPath,d1 = winreg.QueryValueEx(subkey, u"InstallPath" )
                print ("4:", InstallPath,d1)
            except Exception:
                print ("exception")
            winreg.CloseKey(subkey)
    except WindowsError:
        print ("exception")
    finally:
        winreg.CloseKey(key)

def RttSetting():
    settingPath = "../setting.ini"
    if os.path.exists(settingPath):
        conf = configparser.ConfigParser()
        conf.read(settingPath)
        dllPath = conf.get("globals", "Dll_Path")
        mapPath = conf.get("globals", "Map_Path")
        if False == os.path.exists(dllPath):
            print(dllPath + " is not found.")
            print(registrytest(r"Software\SEGGER\J-Link"))
            #key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\SEGGER\J-Link")
            #print(key)
        print(dllPath)
        print(mapPath)
            
    else:
        print("Error:setting.ini not found.")
        
RttSetting()

@@ -30,28 +30,24 @@
 eg%0A%0Adef 
-registrytest
+RegSeach
 (keypath
@@ -1155,32 +1155,100 @@
 s%22, %22Map_Path%22)%0A
+        print(%22dllPath%22, dllPath)%0A        print(%22mapPath%22, mapPath)%0A
         if False
@@ -1334,22 +1334,17 @@
         
-print(
+#
 registry
@@ -1374,17 +1374,16 @@
 J-Link%22)
-)
 %0A       
@@ -1387,17 +1387,16 @@
         
-#
 key = wi
@@ -1477,51 +1477,168 @@
     
-#print(key)%0A        print(d
+InstallPath,d1 = winreg.QueryValueEx(key, u%22InstallPath%22 )%0A            InstallPath += %22JLinkARM.dll%22%0A            print (%22InstallPath%22, Insta
 llPath)
-%0A
+ %0A   
         
 prin
@@ -1637,35 +1637,131 @@
     
-print(mapPath)%0A            
+ conf.set(%22globals%22, %22Dll_Path%22, InstallPath)%0A            conf.write(open(settingPath, 'w'))%0A            return InstallPath
 %0A   
@@ -1805,32 +1805,49 @@
 ni not found.%22)%0A
+        return 0%0A
         %0ARttSett

add read jlink regedit