I am trying to use 1way activex in a PB program via ComatePlus and I'm having problems with setting up the calls properly.

1way is an ActiveX control which provides a way to create a time-limited trial version of an application. I had used it before in VB
The way it's supposed to be used in the app is as follows:
1) instantiate the activex in the app
2) call GetData(AppID) to retrieve registration info and set AppStatus and AppDaysLeft properties
3) check AppStatus
- if AppStatus = 0, data for app had not been setup yet so a call to SetData(AppID, NewAppStatus, NewAppDaysLeft) will have to be made
- if AppStatus = 1, app is still within the trial period, display days left in trial and let the app continue to run
- if AppStatus = 2, app is expired - show nag screen, disable some functions in the app or exit
- if AppStatus = 3, app is registered, let the app continue to run
I was able to do step 1 but could not get pass step 2 - here is the relevant portion of the code I'm working with:
Code: Select all
IncludeFile "COMatePLUS.pbi"
DataSection
OCXsourceStart:
IncludeBinary "OneWayX.ocx"
OCXsourceEnd:
EndDataSection
Enumeration
#holder_0
EndEnumeration
If OpenWindow(0, #PB_Ignore, #PB_Ignore, 300, 150, "OneWay Test", #PB_Window_SystemMenu|#PB_Window_Invisible)
;I'm making a copy of the ocx and registering it before using it
x = CreateFile(1, GetCurrentDirectory() + "OneWayX.ocx")
If x > 0
WriteData(1, ?OCXsourceStart, ?OCXsourceEnd-?OCXsourceStart)
CloseFile(1)
EndIf
ocxFile.s = "/s " + Chr(34) + GetTemporaryDirectory() + "OneWayX.ocx" + Chr(34)
RunProgram("regsvr32 ", ocxFile, "")
Object_1Way.COMateObject
ContainerGadget(#holder_0, 0, 10, 35, 35)
Object_1Way = COMate_CreateActiveXControl(0, 0, 35, 35, "OneWayX.OneWay") ;"{2BF78C6C-FB88-4F6C-87AB-C6E7F4CE6575}")
Debug "container created...."
Debug "Object_1Way = " + Str(Object_1Way)
Debug "error code = " + Str(COMate_GetLastErrorCode())
Debug "error desc = " + COMate_GetLastErrorDescription()
Debug "=============================="
CloseGadgetList()
HideGadget(#holder_0, 1)
;=========================================
; A A
; | |
; +--------- OKAY UP TO HERE ---------+
;
;=========================================
;
; +-------- PROBLEM DOWN HERE --------+
; | |
; V V
;=========================================
If Object_1Way
appId.s = "testApp"
OneWayGetDataCall.s = "GetData('" + appId + "')" ;<==== how should the invocation
Object_1Way\Invoke(OneWayGetDataCall) ;<==== to GetData() look like
Debug OneWayGetDataCall
Debug "error code = " + Str(COMate_GetLastErrorCode())
Debug "error desc = " + COMate_GetLastErrorDescription()
EndIf
EndIf
Boolean GetData(AppID)
Parameters
AppID : string
Return Value
GetData returns True if it was able to retrieve the saved data correctly:
GetData returns False if there was an error condition and the data could not be retrieved correctly
If I run the code above using the function definition from the 1way help file, I get these results:
Code: Select all
container created....
Object_1Way = 36052624
error code = 0
error desc = Okay.
==============================
GetData('testApp')
error code = -2147352570
error desc = Method/property not supported by this object.
Code: Select all
GetData(a, b)
; a BYVAL AppID INTEGER (#VT_BSTR)
; b BYREF Value BYTE (#VT_BOOL)
If needed, a trial version of the ocx can be downloaded from here: http://atma-software.com/1way/1WaySetup.exe