Calling Lime from Intel Fortran

Below is code I use for checking a Lime license from Intel Fortran.Folks at the Intel Fortran support forum were instrumental in producing this.I can't explain the code, but it works for me.The code can go in a single file e.g. LimeLM.f90Add the file to a fortran project which builds a console program.In the fortran main program add a declaration line INTEGER rtn, CheckLimeKeyNear the start of the program do rtn = CheckLimeKeyThen do whatever depending on the value of rtn.One more thing. In visual studio I had to add Turboactivate.lib to the list of source code files in the project.As is, this code does minimal checking of the license. Modify/extend to suit your needs. I hope someone finds it useful. The code was nicely indented when I posted it, but I don't know if it will stay that way.module turboactive_api_mod use, intrinsic :: iso_c_binding implicit none type, bind(C) :: GENUINE_OPTIONS ! The size, in bytes, of this structure. Set this value to the size of the GENUINE_OPTIONS structure. integer(c_int32_t) :: nLength; ! Flags to pass to TA_IsGenuineEx() to control its behavior. integer(c_int32_t) :: flags; ! How often to contact the LimeLM servers for validation. 90 days recommended. integer(c_int32_t) :: nDaysBetweenChecks; ! If the call fails because of an internet error, how long, in days, should the grace period last (before ! returning deactivating and returning TA_FAIL). 14 days is recommended. integer(c_int32_t) :: nGraceDaysOnInetErr; end type GENUINE_OPTIONS interface ! TURBOACTIVATE_API HRESULT TA_CC TA_PDetsFromPath(STRCTYPE filename); function TA_PDetsFromPath(filename) result(retval) bind(C, name="TA_PDetsFromPath") import integer(c_short), dimension(*) :: filename ! LPCWSTR integer(c_long) :: retval ! HRESULT end function ! TURBOACTIVATE_API uint32_t TA_CC TA_GetHandle(STRCTYPE versionGUID); function TA_GetHandle(guid) result(retval) bind(C, name="TA_GetHandle") import integer(c_short), dimension(*) :: guid ! LPCWSTR integer(c_long) :: retval ! HRESULT end function ! TURBOACTIVATE_API HRESULT TA_CC TA_IsDateValid(uint32_t handle, STRCTYPE date_time, uint32_t flags); function TA_IsDateValid(handle, date_time, flags) bind(c, name = 'TA_IsDateValid') result(retval) import integer(c_int32_t), value :: handle ! Note that Fortran doesn't have unsigned integer types integer(c_short), dimension(*) :: date_time ! LPCWSTR is a "Long Pointer to Constant Wide String". integer(c_int), value :: flags ! Note the value attribute here integer(c_long) :: retval ! HRESULT is typedef long end function ! TURBOACTIVATE_API HRESULT TA_CC TA_GetFeatureValue(uint32_t handle, STRCTYPE featureName, STRTYPE lpValueStr, int cchValue); function TA_GetFeatureValue(handle, featureName, lpValueStr, cchValue) bind(c, name = 'TA_GetFeatureValue') result(retval) import integer(c_int32_t), value :: handle ! Note that Fortran doesn't have unsigned integer types integer(c_short), dimension(*) :: featureName ! LPCWSTR is a "Long Pointer to Constant Wide String". integer(c_short), dimension(*) :: lpValueStr ! LPWSTR is a pointer to a string of 16-bit Unicode characters, which MAY be null-terminated. integer(c_int), value :: cchValue ! Note the value attribute here integer(c_long) :: retval ! HRESULT is typedef long end function ! TURBOACTIVATE_API HRESULT TA_CC TA_IsGenuineEx(uint32_t handle, PGENUINE_OPTIONS options); function TA_IsGenuineEx(handle, options) bind(c, name = 'TA_IsGenuineEx') result(retval) import integer(c_int32_t), value :: handle ! Note that Fortran doesn't have unsigned integer types type(GENUINE_OPTIONS) :: options integer(c_long) :: retval ! HRESULT is typedef long end function end interface end module turboactive_api_mod integer Function CheckLimeKey! return 0 if key checks out ok, nonzero otherwise USE, INTRINSIC :: ISO_C_BINDING use turboactive_api_mod implicit none type(GENUINE_OPTIONS) :: opts integer(c_long) taHandle integer(c_int) iint integer(c_long) hr integer(c_short), dimension(100) :: featureValue character(len=:,kind=C_CHAR), allocatable :: result2 opts%nLength = 16 opts%flags = 1 opts%nDaysBetweenChecks = 90 opts%nGraceDaysOnInetErr = 14 hr = TA_PDetsFromPath(IACHAR(transfer(Turboactivate.dat'//C_NULL_CHAR,[C_NULL_CHAR]),KIND=C_SHORT)) if( hr.ne.0 ) then CheckLimeKey = hr return endif taHandle = TA_GetHandle(IACHAR(transfer('your.guid.goes.here'//C_NULL_CHAR,[C_NULL_CHAR]),KIND=C_SHORT)) ! GUIDkey if( taHandle.eq.0 ) then CheckLimeKey = -1 ! -1 will indicate couldn't get handle return endif hr = TA_GetFeatureValue(taHandle, IACHAR(transfer('ExpirationDate'//C_NULL_CHAR,[C_NULL_CHAR]),KIND=C_SHORT), featureValue, 0) iint = hr ! length of string stored in the feature value, including terminating null character hr = TA_GetFeatureValue(taHandle, IACHAR(transfer('ExpirationDate'//C_NULL_CHAR,[C_NULL_CHAR]),KIND=C_SHORT), featureValue, hr) if( hr.ne.0 ) then CheckLimeKey = hr return endif hr = TA_IsGenuineEx(taHandle, opts) if( hr.ne.0 ) then CheckLimeKey = hr return endif hr = TA_IsDateValid(taHandle, featureValue, 1) CheckLimeKey = hr !result2 = transfer(achar(featureValue), repeat('A',iint-1)) end function CheckLimeKey

Slight correction for goes in the main program.

integer rtninteger, external :: CheckLimeKeyrtn = CheckLimeKey()