如何返回NULL

时间:2017-12-10 00:10:51

标签: c# windows registry

即使密钥存在且我的应用程序已安装,我的C#应用​​程序许可证管理器在检查密钥存在时返回NULL。我尝试以管理员身份运行,并在密钥路径中添加或删除反斜杠。

import math, operator, collections   

# Assumes L has at least one digit set
# f({'string':'12', 'digit_frequencies':[0,1,1,0,0,0,0,0,0,0], 'num_digit_frequencies': 2}, 6)
def f(L, N):
  R = N - len(L['string'])

  count = 0
  counted = False

  for digit_frequency in L['digit_frequencies']:       
    start = int(math.ceil(N / 2.0)) - digit_frequency
    if start > R:
      continue

    for i in xrange(start, R + 1):
      if not (N & 1) and not counted:
        if L['num_digit_frequencies'] == 1 and not digit_frequency and i == N / 2:
          count = count - choose(R, i)

        if L['num_digit_frequencies'] == 2 and digit_frequency and not any([x > N / 2 for x in L['digit_frequencies']]) and i + digit_frequency == N / 2:
          count = count - choose(R, i)
          counted = True

      m = 9**(R - i)
      n = R - i + 1
      k = i

      count = count + m * choose(n + k - 1, k)

  return count


# A brute-force function to confirm results 
# check('12', 6)
def check(prefix, length):
  result = [x for x in xrange(10**(length - 1), 10**length) if len(str(x)) == length and str(x).startswith(prefix) and isValid(str(x))]

  print result
  return len(result)

def isValid(str):
  letters = collections.Counter(str)
  return any([x >= math.ceil(len(str) / 2.0) for x in letters.values()])


# https://stackoverflow.com/questions/4941753/is-there-a-math-ncr-function-in-python
def choose(n, r):
  r = min(r, n-r)
  if r == 0: return 1
  numer = reduce(operator.mul, xrange(n, n-r, -1))
  denom = reduce(operator.mul, xrange(1, r+1))
  return numer//denom

proof it exists

注意:我正在构建为x64!

1 个答案:

答案 0 :(得分:1)

正如@RbMm指出的那样,问题在于32位和64位之间的注册表反射。以下问题向我展示了如何选择我看到的视图。 Here它是。