Iam trying to create amibroker (www.amibroker.com) dll plugins using amibroker adk http://www.amibroker.com/devlog/2006/12/15/amibroker-development-kit-adk-for-cc-now-available-to-everyone/ and licensing it with LimeLM. Just to mention that Iam a junior when comes to VC++ coding.
Local Machine OS : Win10Tested Machine OS : Win7 and Win 2008 Server
Here is the modal dllmain function which iam testing with created amibroker dll plugin.
// dllmain.cpp : Defines the entry point for the DLL application.#include "stdafx.h"#include <stdio.h>#include <stdlib.h>#include <Windows.h>
// Support Unicode compilation and non-Windows compilation#ifdef _WIN32#include <tchar.h>#else#define _T(x) xtypedef char TCHAR;#endif
// To use the static version of TurboActivate then uncomment the next line//#define TURBOACTIVATE_STATIC
#define TURBOACTIVATE_STATIC#include "TurboActivate.h"#pragma comment(lib, "TurboActivate-MD.lib")
static int i = 0;uint32_t taHandle;/* The handle used for TurboActivate function calls. */
void CheckLicense() {
//MessageBox(NULL, _T("Valid License1"), _T("message"), MB_OK | MB_SYSTEMMODAL);
uint32_t trialFlags = TA_VERIFIED_TRIAL | TA_SYSTEM;
/* Used to store TurboActivate responses. */ HRESULT hr; GENUINE_OPTIONS opts = { 0 }; opts.nLength = sizeof(GENUINE_OPTIONS);
// In this example we won't show an error if the activation // was done offline by passing the TA_SKIP_OFFLINE flag opts.flags = TA_SKIP_OFFLINE;
// How often to verify with the LimeLM servers (90 days) opts.nDaysBetweenChecks = 1;
// The grace period if TurboActivate couldn't connect to the servers. // after the grace period is over TA_IsGenuineEx() will return TA_FAIL instead of // TA_E_INET or TA_E_INET_DELAYED opts.nGraceDaysOnInetErr = 1;
/* Get the handle that will be used for TurboActivate function calls.
TODO: paste your Version GUID here. */ taHandle = TA_GetHandle(_T("MYGUID")); if (taHandle == 0) {
MessageBox(NULL, _T("Failed to get the handle for the Version GUID specified"), _T("message"), MB_OK | MB_SYSTEMMODAL); ExitProcess(1); }
MessageBox(NULL, _T("Before Activation Entry"), _T("message"), MB_OK | MB_SYSTEMMODAL); hr = TA_IsActivated(taHandle); MessageBox(NULL, _T("Before Activation Exit"), _T("message"), MB_OK | MB_SYSTEMMODAL);
if (hr == TA_OK || hr == TA_E_FEATURES_CHANGED || hr == TA_E_INET || hr == TA_E_INET_DELAYED) {
MessageBox(NULL, _T("Valid License"), _T("message"), MB_OK | MB_SYSTEMMODAL);
} else { MessageBox(NULL, _T("InValid License"), _T("message"), MB_OK | MB_SYSTEMMODAL); ExitProcess(1); }
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved){
switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH:
break;
}
if(i==0) { i++; CheckLicense(); } return TRUE;}
Let me know if you need more details.