Add Original SDK

This commit is contained in:
2026-05-06 07:47:36 +02:00
parent 2915e04380
commit 0ed627517a
674 changed files with 89334 additions and 0 deletions

View File

@@ -0,0 +1,299 @@
// sample functions for calling DinkeyChange.dll.
// Summary: Displays the error code with a helpful error message. You may want to change the messages.
// Syntax:
//DisplayChangeError (<ret_code> is int, <ext_err> is int)
PROCEDURE DisplayChangeError(ret_code is int, ext_err is int)
SWITCH ret_code
CASE 401: Info("Error! No dongles detected that meet the search criteria!")
CASE 409: Info("Error! The dongle detected has not been programmed by DinkeyAdd.")
CASE 758: Info("Error! Cannot open the Update Code file specified.")
CASE 759: Info("Error! The file specified is not a valid Update Code file.")
CASE 762 TO 764: Info("Error! Update Code is not in a correct format / update code file is corrupt.")
CASE 765: Info("Error! The Update Code does not match any dongle attached to your machine.")
CASE 766: Info("Error! The update number for this Update Code is too high. You need to first enter an update code that was previously sent to you.")
CASE 767: Info("Error! You have already entered this Update Code.")
CASE 1905: Info("Error! There is no Software Key available for download.")
CASE 1907: Info("Error! The Temporary Software Key has expired. Cannot download it.")
CASE 1910: Info("Error! The Software Key has already been downloaded.")
CASE 1921: Info("Error! You specified the 'default model' but there is more than one model available. You need to specify a specific dongle model.")
CASE 1922: Info("Error! The model you requested is not available.")
CASE 1923: Info("Error! The Demo Software Key Template has been disabled.")
CASE 1924: Info("Error! You have run out of Demo Software Key activations. You need to order some more.")
OTHER CASE: Info("An error occurred updating the dongle.","Error: " + ret_code, "Extended Error: " + ext_err)
END
// Summary: gets the product code, dongle number and update number for all dongles attached that meet the specify search criteria
// Syntax:
//[ <Result> = ] GetDongleInfo ()
PROCEDURE GetDongleInfo()
hLib, ret_code are system int
type, model, update_number are fixed array of MAX_USB_DEVICES int
dongle_number is a fixed array of MAX_USB_DEVICES unsigned int
prodcode is a fixed array of MAX_USB_DEVICES fixed strings on MAX_PRODCODE_LEN
num_found is int
sDisplayMsg, sType, sModel are strings
// Load the DinkeyChange.dll
hLib = LoadDLL(changedllname)
IF hLib = 0 THEN
Info("Cannot load " + changedllname, "This DLL should be in the same folder as this executable")
RESULT -1
END
// get dongle information
ret_code = CallDLL32(changedllname, "DCGetInfo", TYPE_MASK_ALL, MODEL_MASK_DEFAULT, Null, MAX_USB_DEVICES, &num_found, &type, &model, &prodcode, &dongle_number, &update_number)
FreeDLL(hLib)
IF ret_code <> 0 THEN
DisplayChangeError(ret_code, 0)
RESULT ret_code
END
// display details on the dongles detected
sDisplayMsg = "Dongle Information:" + CR
FOR i = 1 TO num_found
// get type of dongle
IF type[i] = TYPE_PRO THEN
sType = "Pro"
ELSE
sType = "FD"
END
// get model of dongle
IF model[i] = MODEL_LITE THEN
sModel = "Lite"
ELSE IF model[i] = MODEL_PLUS THEN
sModel = "Plus"
ELSE
sModel = "Net"
END
sDisplayMsg += i + ". Dinkey " + sType + " " + sModel + " with dongle number " + dongle_number[i] + " product code " + ExtractString(prodcode[i], 1, Charact(0)) + " update number " + update_number[i] + CR
END
Info(sDisplayMsg)
// Summary: collect diagnostic information from the system and write to a file
// Syntax:
//[ <Result> = ] GetDiagnosticInfo (<sDiagPath> is string)
PROCEDURE GetDiagnosticInfo(sDiagPath is string)
hLib, ret_code are system int
// Load the DinkeyChange.dll
hLib = LoadDLL(changedllname)
IF hLib = 0 THEN
Info("Cannot load " + changedllname, "This DLL should be in the same folder as this executable")
RESULT -1
END
// get diagnostic info
ret_code = CallDLL32(changedllname, "DCGetDiagnosticInfo", sDiagPath)
FreeDLL(hLib)
IF ret_code = 754 THEN
Info("Could not create the diagnostic file. Please check that the path exists:" + sDiagPath)
RESULT ret_code
END
IF ret_code <> 0 THEN
Info("Error " + ret_code + " writing diagnostic information")
RESULT ret_code
END
Info("Diagnostic file written successfully")
// Summary: updates the dongle attached using the update code passed
// Syntax:
//[ <Result> = ] UpdateCodeString (<sUpdateString> is string)
//
// Parameters:
// sUpdateString (string): <specify the role of sUpdateString>
PROCEDURE UpdateCodeString(sUpdateString is string)
hLib, ret_code are system int
extended_error, confirmation_code are int
// Load the DinkeyChange.dll
hLib = LoadDLL(changedllname)
IF hLib = 0 THEN
Info("Cannot load " + changedllname, "This DLL should be in the same folder as this executable")
RESULT -1
END
// update dongle
ret_code = CallDLL32(changedllname, "DCDoUpdateCodeString", sUpdateString, &confirmation_code, &extended_error)
FreeDLL(hLib)
IF ret_code <> 0 THEN
DisplayChangeError(ret_code, extended_error)
RESULT ret_code
END
Info("Dongle updated successfully.", "Confirmation Code is " + NumToString(confirmation_code, "04x"))
// Summary: updates the dongle attached using the update code passed
// Syntax:
//[ <Result> = ] UpdateCodeFromFile (<sUpdateCodeFile> is string)
//
// Parameters:
// sUpdateCodeFile (string)
PROCEDURE UpdateCodeFromFile(sUpdateCodeFile is string)
hLib, ret_code are system int
extended_error, confirmation_code are int
// Load the DinkeyChange.dll
hLib = LoadDLL(changedllname)
IF hLib = 0 THEN
Info("Cannot load " + changedllname, "This DLL should be in the same folder as this executable")
RESULT -1
END
// update dongle
ret_code = CallDLL32(changedllname, "DCDoUpdateCodeFromFile", sUpdateCodeFile, &confirmation_code, &extended_error)
FreeDLL(hLib)
IF ret_code <> 0 THEN
DisplayChangeError(ret_code, extended_error)
RESULT ret_code
END
Info("Dongle updated successfully.", "Confirmation Code is " + NumToString(confirmation_code, "04x"))
// Summary: attempts to restore a corrupt Dinkey FD Lite dongle
// Syntax:
//[ <Result> = ] RestoreDinkeyFDLite ()
//
// Parameters: none
PROCEDURE RestoreDinkeyFDLite()
hLib, ret_code are system int
// Load the DinkeyChange.dll
hLib = LoadDLL(changedllname)
IF hLib = 0 THEN
Info("Cannot load " + changedllname, "This DLL should be in the same folder as this executable")
RESULT -1
END
ret_code = CallDLL32(changedllname, "DCRetoreDinkeyFDLite")
FreeDLL(hLib)
IF ret_code <> 0 THEN
DisplayChangeError(ret_code, extended_error)
RESULT ret_code
END
Info("Dinkey FD has been restored successfully.")
// Summary: displays the machine ID of the current computer
// Syntax:
//[ <Result> = ] GetMachineID ()
//
PROCEDURE GetMachineID()
hLib, ret_code are system int
extended_error is int
machineID is unsigned int
// Load the DinkeyChange.dll
hLib = LoadDLL(changedllname)
IF hLib = 0 THEN
Info("Cannot load " + changedllname, "This DLL should be in the same folder as this executable")
RESULT -1
END
ret_code = CallDLL32(changedllname, "DCGetMachineID", &machineID, &extended_error)
FreeDLL(hLib)
IF ret_code <> 0 THEN
DisplayChangeError(ret_code, extended_error)
RESULT ret_code
END
Info("Machine ID is: " + NumToString(machineID, "08x"))
// Summary: tries to download an available temporary software key for this machine
// Syntax:
//[ <Result> = ] DownloadTempSoftwareKey ()
//
PROCEDURE DownloadTempSoftwareKey()
hLib, ret_code are system int
extended_error is int
machineID is unsigned int
// Load the DinkeyChange module
hLib = LoadDLL(changedllname)
IF hLib = 0 THEN
Info("Cannot load " + changedllname, "This DLL should be in the same folder as this executable")
RESULT -1
END
// first call GetMachineID to get the machine ID value
ret_code = CallDLL32(changedllname, "DCGetMachineID", &machineID, &extended_error)
IF ret_code <> 0 THEN
DisplayChangeError(ret_code, extended_error)
RESULT ret_code
END
// then try to download a temporary software key for that machine ID
ret_code = CallDLL32(changedllname, "DCDownloadTempSoftwareKey", machineID, &extended_error)
FreeDLL(hLib)
IF ret_code <> 0 THEN
DisplayChangeError(ret_code, extended_error)
RESULT ret_code
END
Info("The Temporary Software Key has been downloaded successfully.")
// Summary: tries to download a demo software key for this machine
// Syntax:
//[ <Result> = ] DownloadDemoSoftwareKey (<sProdCode> is string)
//
// Parameters:
// sProdCode (string)
//
PROCEDURE DownloadDemoSoftwareKey(sProdCode is string)
hLib, ret_code are system int
extended_error is int
machineID is unsigned int
// Load the DinkeyChange module
hLib = LoadDLL(changedllname)
IF hLib = 0 THEN
Info("Cannot load " + changedllname, "This DLL should be in the same folder as this executable")
RESULT -1
END
// first call GetMachineID to get the machine ID value
ret_code = CallDLL32(changedllname, "DCGetMachineID", &machineID, &extended_error)
IF ret_code <> 0 THEN
DisplayChangeError(ret_code, extended_error)
RESULT ret_code
END
// then try to download a demo software key
// (NB we are assuming only one dongle model is set in the Demo Software Template.
// If multiple models are set you will also need to specify the exact model)
ret_code = CallDLL32(changedllname, "DCDownloadDemoSoftwareKey", machineID, sProdCode, SWKEY_MODEL_DEFAULT, &extended_error)
FreeDLL(hLib)
IF ret_code <> 0 THEN
DisplayChangeError(ret_code, extended_error)
RESULT ret_code
END
Info("The Demo Software Key has been downloaded successfully.")

View File

@@ -0,0 +1,15 @@
Calling DinkeyChange.dll from WinDev
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You should copy all the code in the file "global variables.txt". These data
structures and functions are used by the API sample code. Then copy the
appropraite function(s) from the "protection check functions.txt" file. These
functions implement all the various routines in DinkeyChange.dll
Note - if you are producing a 64-bit Windows executable you need to use DinkeyChange64.dll
(instead of DinkeyChange.dll) and change the "changedllname" to be "DinkeyChange64.dll"
(this is found in the global variables and functions.txt).
Similarly for Linux you will need to use DinkeyChange.so (32-bit Linux) or
DinkeyChange64.so (64-bit Linux).
Tested under Windev Express v12

View File

@@ -0,0 +1,50 @@
// DinkeyChange constants
// maximum number of USB devices that can be attached to a machine at any time
CONSTANT
MAX_USB_DEVICES = 128 // max number of USB devices that can be attached to the system
MAX_PRODCODE_LEN = 9 // one extra character for null-terminated strings
END
// mask values
CONSTANT
TYPE_MASK_PRO = 1
TYPE_MASK_FD = 2
TYPE_MASK_ALL = 3
MODEL_MASK_LITE = 1
MODEL_MASK_PLUS = 2
MODEL_MASK_NET = 4
MODEL_MASK_ALL = 7
MODEL_MASK_DEFAULT = 6 // Plus and Net
END
// type values for DCGetInfo (returned in the array)
CONSTANT
TYPE_PRO = 1
TYPE_FD = 2
END
// model values for DCGetInfo (returned in the array)
CONSTANT
MODEL_LITE = 1
MODEL_PLUS = 2
MODEL_NET5 = 4
MODEL_NETU = 7
END
// model values for DCDownloadDemoSoftwareKey
CONSTANT
SWKEY_MODEL_DEFAULT = -1 // NB this assumes that the Demo Software Key Template was created with only one valid dongle model
SWKEY_MODEL_PRO_LITE = 0
SWKEY_MODEL_PRO_PLUS = 1
SWKEY_MODEL_PRO_NET = 2
SWKEY_MODEL_FD_LITE = 3
SWKEY_MODEL_FD_PLUS = 4
SWKEY_MODEL_FD_NET = 5
END
// name for DinkeyChange.dll (you can rename it if you like)
changedllname is a string = "DinkeyChange.dll"