Hypertrophy Posted June 29, 2009 Share Posted June 29, 2009 (edited) hi i am having trouble with this script. it uses registry entries to determine how long the user has been using the software and after certain time or if user tries setting back the clock it expires it and you have to register. problem is it always says the trial period is over when there are no keys in the registry indicating so. can you please help me. expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiEdit.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> #include <GUIMENU.au3> _nTrialCheck_Proc(); check if program is expired Global $idSave[6] For $i = 0 To 5 $idSave[$i] = 1000 + $i Next Global $wProcOld Global $lastdragIP = -1 Dim $hInput_GUI[6], $Input[6], $wProcsOld[6], $InputMenu[6], $hMenu[6], $idSave[6] Dim $button $gui = GUICreate("", 400, 400) $button = GUICtrlCreateButton("Recall", 100, 100, 50, 50) GUISetState() $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam") $toDelete = 0 $iW = -1 Global $totCreated = 0 While 1 $msg = GUIGetMsg(1) $iW = -1 For $i = 0 To 5 If $msg[1] = $hInput_GUI[$i] Then $iW = $i If $msg[0] = $GUI_EVENT_PRIMARYDOWN Then $sel = -1 GUISwitch($hInput_GUI[$iW]) $aCursorInfo = GUIGetCursorInfo() If Not IsArray($aCursorInfo) Then ContinueLoop $aMouse_Pos = MouseGetPos() $aInputGUI_Pos = WinGetPos($hInput_GUI[$iW]) While IsArray($aCursorInfo) And $aCursorInfo[2] = 1 $aCursorInfo = GUIGetCursorInfo() $aCurrent_Mouse_Pos = MouseGetPos() WinMove($hInput_GUI[$iW], "", _ $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _ $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1]) WEnd EndIf ExitLoop EndIf Next Switch $msg[0] Case $GUI_EVENT_CLOSE Exit Case $button If $totCreated < 6 Then For $i = 0 To 5 If $hInput_GUI[$i] = 0 Then createNextdragIP($i) $totCreated += 1 ExitLoop EndIf Next Else MsgBox(262144, "MAX Reached", "You are omnly allowed 6 Edits!") EndIf EndSwitch WEnd DllCallbackFree($wProcHandle) Func createNextdragIP($nw) $start = WinGetPos($gui) $hInput_GUI[$nw] = GUICreate("No. " & $nw + 1, 120, 22, 300 + 25 * $nw, 300 + 25 * $nw, BitOR($WS_POPUP, $WS_SIZEBOX), $WS_EX_TOOLWINDOW) $Input[$nw] = GUICtrlCreateEdit("", 0, 0, 120, 22, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN)) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $hMenu = _GUICtrlMenu_CreatePopup() $InputMenu[$nw] = $hMenu _GUICtrlMenu_AddMenuItem($hMenu, "Save", $idSave[$nw]) ConsoleWrite("90" & @CRLF) GUISetState() $wProcsOld[$nw] = _WinAPI_SetWindowLong(GUICtrlGetHandle($Input[$nw]), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle)) EndFunc;==>createNextdragIP Func _WindowProc($hWnd, $msg, $wParam, $lParam) Local $wProcOld For $i = 0 To UBound($Input) - 1 If GUICtrlGetHandle($Input[$i]) = $hWnd Then Switch $msg Case $WM_CONTEXTMENU _GUICtrlMenu_TrackPopupMenu($InputMenu[$i], $wParam) Return 0 Case $WM_COMMAND Switch $wParam Case $idSave[$i] ; DONT KNOW WHAT TO PUT HERE? EndSwitch EndSwitch $wProcOld = $wProcsOld[$i] ExitLoop EndIf Next Local $aRet = DllCall("user32.dll", "int", "CallWindowProc", "ptr", $wProcOld, _ "hwnd", $hWnd, "uint", $msg, "wparam", $wParam, "lparam", $lParam) Return $aRet[0] EndFunc;==>_WindowProc ; function for checking the trial days and disabling everythign when trial expires Func _nTrialCheck_Proc() ; Key in registry for trial Global Const $trialKey = "HKEY_CURRENT_USER\Software\Microsoft\InstallDr\driverIco\3D8G8D0TG73C9S047F9JH90G8QW0N0M" ; Number of days to allow Global Const $timeLimit = 14 ; Check key if program has expired; if key does not exist, set to false RegRead($trialKey,"id") If @ERROR Then RegWrite($trialKey,"id","REG_BINARY",StringToBinary(_BooleanToString(false))) EndIf ; Retrieve if the program is expired $expired = _StringToBoolean(BinaryToString("0x"&RegRead($trialKey,"id"))) If $expired Then Global $trialexpired = True Msgbox(0, "", "Program expired") EndIf ; Check if registry key for first run exists; if not, create it with current date and time RegRead($trialKey,"fiRun") If @ERROR Then RegWrite($trialKey,"fiRun","REG_BINARY",StringToBinary(_NowCalc())) EndIf ; Retrieve first run time $fiRun = BinaryToString("0x"&RegRead($trialKey,"fiRun")) ; Compare first run time with current time & date; if negative (current date is earlier than first run) $timeDiff = _DateDiff('s',$fiRun,_NowCalc()) If $timeDiff < 0 Then RegWrite($trialKey,"id","REG_BINARY",StringToBinary(_BooleanToString(true))) Global $trialexpired = True ; Register() <<<<<<< function for user to register EndIf ; Calculate number of days the program hs been used; if >= the time limit $daysUsed = _DateDiff('d',$fiRun,_NowCalc()) If $daysUsed >= $timeLimit Then RegWrite($trialKey,"id","REG_BINARY",StringToBinary(_BooleanToString(true))) Global $trialexpired = True Msgbox(0, "", "Program expired") EndIf ; Calculate how many days remain for the trial Global $daysRemaining = $timeLimit - $daysUsed ; Check if registry key for last run exists; if not, create it with current date and time RegRead($trialKey,"lRun") If @ERROR Then RegWrite($trialKey,"lRun","REG_BINARY",StringToBinary(_NowCalc())) EndIf ; Compare last run time with current time; if negative (i.e. current time is earlier than last run time) $lRun = BinaryToString("0x"&RegRead($trialKey,"lRun")) $timeDiff = _DateDiff('s',$lRun,_NowCalc()) If $timeDiff < 0 Then RegWrite($trialKey,"id","REG_BINARY",StringToBinary(_BooleanToString(true))) Global $trialexpired = True Msgbox(0, "", "Program expired") EndIf EndFunc Func _StringToBoolean($strVal) If $strVal = "False" Then Return False Else Return True EndIf EndFunc;==>_StringToBoolean Func _BooleanToString($boolVal) If $boolVal Then Return "True" Else Return "False" EndIf EndFunc;==>_BooleanToString Edited June 29, 2009 by Hypertrophy Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 2, 2009 Author Share Posted July 2, 2009 does anyone have any ideas? could it be malfunctioning because i upgraded? Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 3, 2009 Author Share Posted July 3, 2009 bump Link to comment Share on other sites More sharing options...
BrettF Posted July 3, 2009 Share Posted July 3, 2009 Have you check out this?http://www.autoitscript.com/forum/index.ph...c=31020&hl=Cheers,Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 3, 2009 Author Share Posted July 3, 2009 Yeah, have read all about it and don't want anything to do with it. Link to comment Share on other sites More sharing options...
Andreik Posted July 3, 2009 Share Posted July 3, 2009 Look at XProTec by Valuater.http://www.autoitscript.com/forum/index.ph...st&p=222095 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
BrettF Posted July 3, 2009 Share Posted July 3, 2009 Yeah, have read all about it and don't want anything to do with it.Why not? Its a proven system that works very well... Look at XProTec by Valuater.http://www.autoitscript.com/forum/index.ph...st&p=222095I already posted that? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Andreik Posted July 3, 2009 Share Posted July 3, 2009 Why not? Its a proven system that works very well... I already posted that? Sorry, you post just link I didn't know that is XProTec. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
GodlessSinner Posted July 3, 2009 Share Posted July 3, 2009 (edited) Hypertrophy, I tell you a few words about your security system: This can be simply hacked! - More fixable - is to lock some function of your code and make demo version. In this case, never lock(or hide) controls by GuiCtrlSetState!! - use code verifying before control creation or function execution or something else. I see, you want to make product for sale... Note: According to the "license" you have no right to add your ©copyright, because an absolute author of all that we "compiled" - is ... you know who... Edited July 3, 2009 by Vitas _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 3, 2009 Author Share Posted July 3, 2009 I know it can be simply "hacked". The only way that I know of though is just to delete those 3 keys in the registry. I am aware of that. And yes I did take precautions in case it does get hacked. Every now and then when creating controls it will check to see if the software is registered. If not it simply won't create those controls. There is no hiding. I don't need XProTec. I opened this thread for issues with my code not XProTec so I'd appreciate advice if anyone has a solution. Link to comment Share on other sites More sharing options...
martin Posted July 3, 2009 Share Posted July 3, 2009 I know it can be simply "hacked". The only way that I know of though is just to delete those 3 keys in the registry. I am aware of that. And yes I did take precautions in case it does get hacked. Every now and then when creating controls it will check to see if the software is registered. If not it simply won't create those controls. There is no hiding. I don't need XProTec. I opened this thread for issues with my code not XProTec so I'd appreciate advice if anyone has a solution. I don't know why your request is being ignored. I think the problem is this line $expired = _StringToBoolean(BinaryToString("0x"&RegRead($trialKey,"id"))) If you don't read anything at the reg key you are getting the boolean value fromBinaryToString of "0x" which I think you think is false, but it isn't. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 3, 2009 Author Share Posted July 3, 2009 Thank you martin for replying. And I've also suspected it being that line because $expired always returns True it seems. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now