RLM许可证不适用于Windows 8,10上的python 3.5

时间:2018-06-12 07:26:58

标签: python windows licensing

我正在尝试使用python 3.5的RLM(Reprise许可证管理器)许可证。一直在使用RLM与python 2.7,但面临3.5的问题。当我运行RLM提供的示例代码时,它在Windows 7上使用python 3.5但在Windows 8,10上失败。在所有版本的Windows上,相同的代码与python 2.7使用相同的RLM dll。

错误消息是

stat = rlm.rlm_stat(rh)
OSError: exception: access violation reading 0x00000000311E1908

以下是RLM的示例代码。

#
# Example of calling RLM functions from Python.  This example uses Python 3.
# This is not a complete Python language interface for RLM - instead it shows
# how to pass the essential data types back and forth between Python and RLM.
#
#
# Use Python ctypes library to call RLM functions
# There is a good writeup here: https://docs.python.org/3.4/library/ctypes.html
from ctypes import *

import sys

# This loads rlm1122.dll from the current working directory
rlm = cdll.rlm1222

# This loads librlm1122.so from the current working directory - note that on 
# Windows ctypes adds the .dll but on Linux, etc we need to explicitly call 
# LoadLibrary and supply the suffix
# rlm=cdll.LoadLibrary("librlm1122.so")

# Specify the argument types and return type of the RLM functions to be used.  
# In C, rlm_init()'s prototype is 
#   RLM_HANDLE *rlm_init(const char *, const char *, const char *)
# Pass the const char* as c_char_p.  RLM_HANDLE is an opaque pointer - use an 
# unsigned long to represent this and other RLM handle types in Python.
rlm.rlm_init.argtypes = [c_char_p, c_char_p, c_char_p]
rlm.rlm_init.restype = c_ulong

# Argument and return types for rlm_checkout, rlm_stat, rlm_license_stat, 
# rlm_checkin, and rlm_close. Use an unsigned long for the 
# license handle, as we do for the RLM handle returned from rlm_init
rlm.rlm_checkout.argtypes = [c_ulong, c_char_p, c_char_p, c_int]
rlm.rlm_checkout.restype = c_ulong

rlm.rlm_stat.argtypes = [c_ulong]
rlm.rlm_stat.restype = c_int

rlm.rlm_license_stat.argtypes = [c_ulong]
rlm.rlm_license_stat.restype = c_int

rlm.rlm_checkin.argtypes = [c_ulong]
rlm.rlm_checkin.restype = c_int

rlm.rlm_close.argtypes = [c_ulong]
rlm.rlm_close.restype = c_int

# Create a string buffer to pass to rlm_errstring if we need it
errbuf = create_string_buffer(512)

lic = c_ulong(0)
rh = rlm.rlm_init(b"5053@192.168.1.102", b"", b"")
stat = rlm.rlm_stat(rh)
if stat != 0:
    errstring = create_string_buffer(1000)
    rlm.rlm_errstring_num(stat, errstring)
    errMessage = str(errstring.value, 'utf-8')
    print("rlm_init error" + str(stat))
    print(errMessage)
    sys.exit()

product = b"baseApp"
version = b"1.0"
lic = rlm.rlm_checkout(rh, product, version, 1)
stat = rlm.rlm_license_stat(lic)
if stat != 0:
    rlm.rlm_errstring(lic, rh, errbuf)
    print(errbuf.value)
    sys.exit()
print("checkout OK")

rlm.rlm_checkin(lic)
rlm.rlm_close(rh)

0 个答案:

没有答案