Platforms to show: All Mac Windows Linux Cross-Platform

HASPHLDMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Dongle MBS Dongle Plugin 11.1 ✅ Yes ✅ Yes ✅ Yes ❌ No Desktop, Console & Web
A class for accessing HASP HL or Sentinel dongles.
Example
// Load your vendor library or the demo one
dim LibFile as FolderItem = GetFolderItem("hasp_darwin_12345.dylib")

if HASPHLDMBS.LoadLibrary(LibFile) then
'MsgBox "OK"
else
MsgBox "Failed to load library."
Return
end if

// init dongle
' This method runs the actual tests on the given program number
dim blob as MemoryBlock // container for data for en-/decryption

dim FeatureID = HASPHLDMBS.HASP_DEFAULT_FID
dim VendorCode = "123456" // your vendor code here, some big Base64 encoded block

dim hasp as new HASPHLDMBS(FeatureID, VendorCode)
Select case hasp.Lasterror
case HASPHLDMBS.HASP_STATUS_OK
// ok
case HASPHLDMBS.HASP_HASP_NOT_FOUND
MsgBox "Dongle not found."
return
case HASPHLDMBS.HASP_INV_VCODE
MsgBox "Invalid vendor code"
Return
else
MsgBox "Error: "+str(hasp.Lasterror)
return
end Select

// read a file ID
dim fileid as Integer = 65524
dim size as Integer = hasp.GetSize( fileid )

if hasp.Lasterror = HASPHLDMBS.HASP_STATUS_OK then // ONLY IF FILE IS SUPPORTED

// read to memoryblock
blob = hasp.ReadMemory( fileid, 0, size )
if hasp.Lasterror = HASPHLDMBS.HASP_STATUS_OK then
// show in MsgBox
s = Blob.stringvalue(0,blob.size)
MsgBox DefineEncoding(s,Encodings.UTF8)
end if
end if

Please use HASP Master Wizard Suite to generate your own runtime libraries. Than you get a couple of DLLs which you can load with this class. For the demo keys, you can use the demo DLLs.
The demo DLL for example is named "hasp_windows_x64_demo.dll" or including your vendor code "hasp_windows_x64_12345.dll" (64bit). 32bit Windows DLL is named hasp_windows_12345.dll, hasp_windows_demo.dll or haspvlib_12345.dll.

Now when you have the platform dependent libraries, you can use LoadLibrary() function in this class to load the right one.

HASPHLMBS uses a linked in library. This is okay for older HASP HL versions. But newer versions require you to create your own signed libraries. For them use the HASPHLDMBS class.

  • 2 properties
  • 23 methods
    • method Close
    • method Constructor(FeatureID as Integer, scope as string, VendorCode as string)
    • method Constructor(FeatureID as Integer, VendorCode as string)
    • method DateTimeToHaspTime(day as Integer, month as Integer, year as Integer, hour as Integer, minute as Integer, second as Integer) as memoryblock
    • method DecryptMemory(Data as Memoryblock, DataOffset as Integer, Size as Integer)
    • method DecryptString(Data as string) as string
    • method EncryptMemory(Data as Memoryblock, DataOffset as Integer, Size as Integer)
    • method EncryptString(Data as string) as string
    • method GetRTC as memoryblock
    • method GetSessionInfo(format as string) as string
    • method GetSize(FileID as Integer) as Integer
    • method HaspTimeToDateTime(time as memoryblock, byref day as Integer, byref month as Integer, byref year as Integer, byref hour as Integer, byref minute as Integer, byref second as Integer)
    • method LegacyDecryptMemory(Data as Memoryblock, DataOffset as Integer, Size as Integer)
    • method LegacyDecryptString(Data as string) as string
    • method LegacyEncryptMemory(Data as Memoryblock, DataOffset as Integer, Size as Integer)
    • method LegacyEncryptString(Data as string) as string
    • method LegacySetIdleTime(idletime as Integer)
    • method LegacySetRTC(time as memoryblock)
    • method ReadMemory(FileID as Integer, Offset as Integer, Size as Integer) as Memoryblock
    • method ReadString(FileID as Integer, Offset as Integer, Size as Integer) as string
    • method Update(data as string) as string
    • method WriteMemory(FileID as Integer, FileOffset as Integer, Data as Memoryblock, DataOffset as Integer, Size as Integer)
    • method WriteString(FileID as Integer, FileOffset as Integer, Data as String)
  • 7 shared methods
    • shared method Available as boolean
    • shared method Detach(detachAction as string, scope as string, VendorCode as string, recipient as string, byref info as string) as Integer
    • shared method GetInfo(scope as string, format as string, VendorCode as string, byref info as string) as Integer
    • shared method GetVersion(byref MajorVersion as Integer, byref MinorVersion as Integer, byref BuildServer as Integer, byref BuildNumber as Integer, VendorCode as string) as Integer
    • shared method LoadLibrary(file as folderitem) as boolean
    • shared method LoadLibrary(path as string) as boolean
    • shared method Transfer(action as string, scope as string, VendorCode as string, recipient as string, byref info as string) as Integer
  • 120 constants

This class has no sub classes.

Some examples using this class:

Blog Entries

Xojo Developer Magazine

Release notes

  • Version 23.2
    • Removed CallHASPMBS function and HASPHLMBS class. Please use HASPHLDMBS class.

The items on this page are in the following plugins: MBS Dongle Plugin.


GZipFileMBS   -   HIDAPIDeviceInfoMBS


The biggest plugin in space...