Ashish, I managed to make it work by changing the functions slightly.
It seems to work perfectly when "hasp_windows_x64_demo.dll" file is besides the executable.
But when this file is absent, my exe still runs, but displays the same error irregularly. If I press retry enough times, it may or may not continue to work without a particular pattern.
What is the purpose of the hasp_windows_x64_demo.dll file which is generated by the Envelope?
Should it be always besides the main executable? Why does my exe run even that dll file is absent?