1
# Licensed under the Apache License, Version 2.0 (the "License");
2
# you may not use this file except in compliance with the License.
3
# You may obtain a copy of the License at
5
# http://www.apache.org/licenses/LICENSE-2.0
7
# Unless required by applicable law or agreed to in writing, software
8
# distributed under the License is distributed on an "AS IS" BASIS,
9
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
# See the License for the specific language governing permissions and
11
# limitations under the License.
18
if sys.platform == "win32":
19
# figure out where the JDK lives
22
import _winreg as wreg
24
class WindowsRegistry:
25
# see the Python Cookbook, #146305, Dirk Holtwick
27
def __init__(self, keyname):
28
" handle registry access "
29
self.reg = wreg.ConnectRegistry(None, wreg.HKEY_LOCAL_MACHINE)
30
self.key = wreg.OpenKey(self.reg, keyname)
33
" get value out of registry "
34
v, t = wreg.QueryValueEx(self.key, name)
38
" close the key finally "
45
def get_registry_value(vname, subname):
46
r = WindowsRegistry(vname)
50
javaversion = get_registry_value(r"SOFTWARE\JavaSoft\Java Development Kit", "CurrentVersion")
51
JAVAHOME = get_registry_value(r"SOFTWARE\JavaSoft\Java Development Kit\%s" % javaversion, "JavaHome")
54
JAVAHOME = 'c:/Program Files/Java/jdk1.6.0_18'