Thank you ever so much. I've tried it and it compiles. I'll test it if it runs soon.
Once again, thank you.
Hello,
I'm trying to use LimeLM with Metatrader4 (MT4) but I'm struggling adapting the C++ header file to native MT4 library file. Can someone help please?
Here's what I've got so far:
<snipped entire TurboActivate.h header>
But I'm getting errors like:
'uint32_t' - unexpected token TurboActivate.mqh 12 23
'uint8_t' - unexpected token TurboActivate.mqh 13 23
'STRTYPE' - unexpected token TurboActivate.mqh 14 23
'*' - pointer cannot be used TurboActivate.mqh 15 20
'STRCTYPE' - unexpected token TurboActivate.mqh 15 23
'int32_t' - declaration without type TurboActivate.mqh 16 9
'int32_t' - unexpected token TurboActivate.mqh 16 9
'TCHAR' - unexpected token TurboActivate.mqh 17 23
'uint32_t' - unexpected token, probably type is missing? TurboActivate.mqh 23 5
'nLength' - semicolon expected TurboActivate.mqh 23 14
'STRCTYPE' - unexpected token, probably type is missing? TurboActivate.mqh 27 5
'sExtraData' - semicolon expected TurboActivate.mqh 27 14
class type expected, pointer to type 'ACTIVATE_OPTIONS' is not allowed TurboActivate.mqh 30 26
'PACTIVATE_OPTIONS' - unexpected token TurboActivate.mqh 30 27
'uint32_t' - unexpected token, probably type is missing? TurboActivate.mqh 64 5
'nLength' - semicolon expected TurboActivate.mqh 64 14
'uint32_t' - unexpected token, probably type is missing? TurboActivate.mqh 67 5
'flags' - semicolon expected TurboActivate.mqh 67 14
'uint32_t' - unexpected token, probably type is missing? TurboActivate.mqh 70 5
'nDaysBetweenChecks' - semicolon expected TurboActivate.mqh 70 14
'uint32_t' - unexpected token, probably type is missing? TurboActivate.mqh 77 5
'nGraceDaysOnInetErr' - semicolon expected TurboActivate.mqh 77 14
'GENUINE_OPTIONS' - identifier already used TurboActivate.mqh 80 16
see previous declaration of 'GENUINE_OPTIONS' TurboActivate.mqh 60 8
'*' - '{' beginning bracket expected TurboActivate.mqh 80 32
'PGENUINE_OPTIONS' - unexpected token TurboActivate.mqh 80 33
'C' - declaration without type TurboActivate.mqh 153 1
'C' - declaration without type TurboActivate.mqh 172 1
'C' - declaration without type TurboActivate.mqh 188 1
'C' - declaration without type TurboActivate.mqh 201 1
'C' - declaration without type TurboActivate.mqh 236 1
'C' - declaration without type TurboActivate.mqh 255 1
'C' - declaration without type TurboActivate.mqh 268 1
'C' - declaration without type TurboActivate.mqh 290 1
'C' - declaration without type TurboActivate.mqh 314 1
'C' - declaration without type TurboActivate.mqh 338 1
'C' - declaration without type TurboActivate.mqh 352 1
'C' - declaration without type TurboActivate.mqh 368 1
'C' - declaration without type TurboActivate.mqh 414 1
'C' - declaration without type TurboActivate.mqh 440 1
'C' - declaration without type TurboActivate.mqh 452 1
'C' - declaration without type TurboActivate.mqh 472 1
'C' - declaration without type TurboActivate.mqh 489 1
'C' - declaration without type TurboActivate.mqh 517 1
'C' - declaration without type TurboActivate.mqh 537 1
'C' - declaration without type TurboActivate.mqh 564 1
'C' - declaration without type TurboActivate.mqh 580 1
'uint32_t' - declaration without type TurboActivate.mqh 586 36
'C' - declaration without type TurboActivate.mqh 604 1
'C' - declaration without type TurboActivate.mqh 626 1
'C' - declaration without type TurboActivate.mqh 648 1
'C' - declaration without type TurboActivate.mqh 672 1
'C' - declaration without type TurboActivate.mqh 684 1
'C' - declaration without type TurboActivate.mqh 706 1
'C' - declaration without type TurboActivate.mqh 720 1
I've put the TurboActivate.dll file in the Libraries folder under MQL.
Any help appreciated. Thanks.
// Define types and constants
#define TA_SKIP_OFFLINE 1
#define TA_OFFLINE_SHOW_INET_ERR 2
#define TA_SYSTEM 1
#define TA_USER 2
// Define structures
struct ACTIVATE_OPTIONS
{
int nLength; // Equivalent to uint32_t
string sExtraData; // Extra data to pass to LimeLM servers (maximum 255 UTF-8 characters)
};
struct GENUINE_OPTIONS
{
int nLength; // Size of the structure
int flags; // Flags to control TA_IsGenuineEx behavior
int nDaysBetweenChecks; // How often to check with the LimeLM servers (90 days recommended)
int nGraceDaysOnInetErr;// Grace period days in case of an internet error (14 days recommended)
};
// Import functions from the LimeLM DLL
#import "LimeLM.dll"
int TA_IsGenuineEx(GENUINE_OPTIONS &genOpts); // Check if the license is genuine
int TA_ActivateOptions(ACTIVATE_OPTIONS &actOpts); // Activate the license with additional options
// Add any other function you need to import from the LimeLM DLL here
#import
// Function to verify the license
int VerifyLicense()
{
GENUINE_OPTIONS genOpts;
genOpts.nLength = sizeof(GENUINE_OPTIONS);
genOpts.flags = TA_SKIP_OFFLINE;
genOpts.nDaysBetweenChecks = 90;
genOpts.nGraceDaysOnInetErr = 14;
int result = TA_IsGenuineEx(genOpts);
if(result == 0) // TA_OK
{
Print("License is valid.");
}
else
{
Print("License verification failed: ", result);
}
return result;
}
// Function to activate the license with additional options
int ActivateLicense(string extraData)
{
ACTIVATE_OPTIONS actOpts;
actOpts.nLength = sizeof(ACTIVATE_OPTIONS);
actOpts.sExtraData = extraData;
int result = TA_ActivateOptions(actOpts);
if(result == 0) // TA_OK
{
Print("Activation successful.");
}
else
{
Print("Activation failed: ", result);
}
return result;
}
// Usage example
void OnStart()
{
// Verify the license at the start of the script or EA
int license = VerifyLicense();
// If activation is required, activate the license
if(license != 0) // If not TA_OK
{
string extraData = "Example extra data";
ActivateLicense(extraData);
}
}
Thank you ever so much. I've tried it and it compiles. I'll test it if it runs soon.
Once again, thank you.
That likely *almost* works. It's missing the handle
parameters (the first parameters) and the TA_GetHandle() function. And other functions you need to make verification accurate. But you should be able to modify the code SymaFR_ provided to fix those things and get a working example.
Ok, thanks.
There was one function I can't convert and that's this:
typedef void(TA_CC * TrialCallbackType)(uint32_t, void *);
TURBOACTIVATE_API HRESULT TA_CC TA_SetTrialCallback(uint32_t handle, TrialCallbackType callback, void * userDefinedPtr);
How would you convert this please?
I'm unfamiliar with metatrader language, but it looks like they support function pointers (which is all that TrialCallbackType
is. See: https://stackoverflow.com/a/56154900/124805
Thank you.