LexActivator (Python) returning ctype errors


#1

Made a simple hello.py to test the python API code but I am having problems with the error below, all my python paths are set up correctly and I have placed the activator.dll in the same folder as the LexActivator.py but it keeps returning an error in the ctypes library
Does anybody know how to fix this or am I doing something completely wrong here
Thanks

Traceback (most recent call last):
File “C:/Users/philb/PycharmProjects/Cryptlex/Hello.py”, line 2, in
import LexActivator
File “C:\Users\philb\PycharmProjects\Cryptlex\LexActivator.py”, line 39, in
library = load_library(get_library_path())
File “C:\Users\philb\PycharmProjects\Cryptlex\LexActivator.py”, line 33, in load_library
return ctypes.cdll.LoadLibrary(path)
File “C:\Python36\lib\ctypes_init_.py”, line 426, in LoadLibrary
return self.dlltype(name)
File "C:\Python36\lib\ctypes_init
.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found


#2

Hi Phil,

You are executing the code from a different working directory which is causing the error.

The LexActivator.py has been updated to account for this. Please download the LexActivator.py from github again and it should work.


#3

Thanks for the updated code, I have tried this but it is still producing the same error, I put print statement in that shows it gets the correct path see below.

C:\Users\philb\PycharmProjects\Cryptlex
File “C:/Users/philb/PycharmProjects/Cryptlex/LexActivator.py”, line 48, in
library = load_library(get_library_path())
File “C:/Users/philb/PycharmProjects/Cryptlex/LexActivator.py”, line 37, in load_library
return ctypes.cdll.LoadLibrary(path)
File “C:\Python36\lib\ctypes_init_.py”, line 426, in LoadLibrary
return self.dlltype(name)
File "C:\Python36\lib\ctypes_init
.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

Process finished with exit code 1


#4

Did you try executing the code using python command?

python sample.py


#5

Yes see below

PS C:\Users\philb\PycharmProjects\Cryptlex> python hello.py
C:\Users\philb\PycharmProjects\Cryptlex
Traceback (most recent call last):
File “hello.py”, line 2, in
import LexActivator
File “C:\Users\philb\PycharmProjects\Cryptlex\LexActivator.py”, line 48, in
library = load_library(get_library_path())
File “C:\Users\philb\PycharmProjects\Cryptlex\LexActivator.py”, line 37, in load_library
return ctypes.cdll.LoadLibrary(path)
File “C:\Python36\lib\ctypes_init_.py”, line 426, in LoadLibrary
return self.dlltype(name)
File "C:\Python36\lib\ctypes_init
.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
PS C:\Users\philb\PycharmProjects\Cryptlex>


#6

I have attached a working sample which runs fine on Windows 64 bit machine:


#7

This error can also happen if VS2010 runtime is not already installed in the system (which usually is for Windows 7 and above)

LexActivator has dependency of VS2010 runtime. If the runtime dlls are not present in the system, they should be placed in parallel to LexActivator.dll if you plan to ship them in the installer of your product.

You can download them from following urls:

https://dl.cryptlex.com/downloads/native/vs2010/vs2010_x86.zip

https://dl.cryptlex.com/downloads/native/vs2010/vs2010_x64.zip

Or you can install the runtime on the target machines if not present:

https://www.microsoft.com/en-us/download/details.aspx?id=13523

https://www.microsoft.com/en-us/download/details.aspx?id=8328


#8

I installed the runtime from MS and looks to be working now so I can move on with the testing
Much appreciated

Now gives me the response
Product trial activated successfully!
hello world :slight_smile:


#9

Just as a further update, I then tried the alternative approach of dropping the 2 runtime dll’s in parallel and I got a better result as below

Trial days left: 1.9905914150938133
hello world

I then removed the installed runtime and the code failed again

So it looks like you need to install it AND use the 2 dll’s in parallel, this is going to be a problem for users who do not already have the runtime installed and they then download the product unless the product is packaged in msi and installs the runtime firsts?
Not to mention if the 2 dll’s are updated by MS then this could also be an issue


#10

In order to be safe, just include the dlls with your package, that’s what is usually done

You don’t need to install the runtime if two dlls are in the same directory as LeActivator. Windows first checks for the runtime in the directory of the file being executed, if it doesn’t find the runtime dll’s then only it looks for the system installed dll’s.

So the safest option is, if you can’t make installation of runtime part of your setup, to ship dll’s with your setup.