'CoolPROJECT Version 1.0 'To create an .ini file to hold the registration infomation 'Created by: Jon Michael Bevar 'With help from Rapid-Q Yahoo user members: dakodamc and Chris, thanks- I own you two :) 'If this can help then GREAT! I am here with the rest of you and sometimes we get lucky. $Include "rapidq.inc" Declare Sub StartRegApp Declare Sub StartMainApp Declare Sub StartUnRegMainApp Declare Sub ReadIniFile Declare Sub SaveIniFile Declare Sub ExitIniFile Declare Sub ExitMainForm 'The embedded Regristration Code 'Note: any combination could be used, I used the Program Name & Version (cpro1), then my birthdate 'but entered backwards (19600701) is really 01/07/1960 and the last is just the current year (2002) 'put it together and you get cpro1-19600701-2002. the RegName is any name the user cares to enter. Dim RegNumCheck as string RegNumCheck = "cpro1-19600701-2002" 'Main App Window Create Form as QForm Caption = "" Width = 400 Height = 300 Center Create mainmenu as QMainmenu Create menuitem1 as Qmenuitem Caption = "&Registration" OnClick = StartRegApp Enabled = true End Create Create menuitem2 as Qmenuitem Caption = "E&xit" OnClick = ExitMainForm End Create End Create End Create 'Registration Form Window Create RegIniForm As QForm Caption = "Registration Window" Width = 290 Height = 250 Center Create RSerial as QLabel Caption = "Product Serial Number:" Width = 200 Left = 40 Top = 10 End Create Create RName as QLabel Caption = "Registration Name:" Width = 200 Left = 40 Top = 60 End Create Create RCode as QLabel Caption = "Registration Code:" Width = 200 Left = 40 Top =110 End Create Create RegSerial as QEdit Width = 200 Left = 40 Top = 30 End Create Create RegName as QEdit Width = 200 Left = 40 Top = 80 End Create Create RegCode as Qedit Width = 200 Left = 40 Top = 130 End Create Create SaveButton As QButton Align = alNone Height = 24 Width = 80 Top = 180 Left = 40 Caption = "&Save" Enabled = ReSet OnClick = SaveIniFile End Create Create ExitButton As QButton Align = alNone Height = 24 Width = 80 Top = 180 Left = 160 Caption = "E&xit" OnClick = ExitIniFile End Create End Create 'First thing is to check to see if the app is registered or not by reading the ini file Call ReadIniFile '-----------------Sub Routines------------------- 'To read the .ini file Sub ReadIniFile Dim File as QFileStream Dim Serial as string, Name as string, Code as string 'Checking to see if a .ini file exists If FileExists("C:\rapidq\cpro1.ini") Then File.Open("c:\rapidq\cpro1.ini",fmOpenRead) File.Read(Serial) File.Read(Name) File.Read(Code) RegSerial.text=File.ReadLine(Serial) RegName.text=File.ReadLine(Name) RegCode.text=File.ReadLine(Code) File.Close 'If .ini file exists then start Main App with regname on Tille bar End If If RegCode.text = RegNumCheck then Call StartMainApp Exit Sub End If 'If .ini file does not exists then create ini file then start Main App with 'Un-Registered Version' on Title bar If RegCode.text <> RegNumCheck then File.Open("C:\rapidQ\cpro1.ini",fmCreate) File.Close Call StartUnRegMainApp End If End Sub 'To Save the ini file if RegCode is correct Sub SaveIniFile Dim File as QFileStream If RegCode.text <> RegNumCheck then ShowMessage "This is not a Valid Registration Code!" Exit Sub End If 'You will need to change the directory path if diferent then shown File.Open("c:\rapidq\cpro1.ini",fmCreate) File.WriteLine(RegSerial.text) File.WriteLine(RegName.text) File.WriteLine(RegCode.text) File.close Call ExitIniFile End Sub 'Start the Registration proccess after you click on the Registration menuitem Sub StartRegApp savebutton.enabled = True RegIniForm.ShowModal End Sub 'If not registered then show Un-Registered Version 'Also turn on the registration menuitem Sub StartUnRegMainApp Form.Caption = "CoolPROJECT - Un-Registered Version" menuitem1.enabled = True Form.ShowModal End Sub 'If registered then show Main Title and the users RegName 'Also turn off the registration menuitem Sub StartMainApp RegIniForm.Close Form.Caption = "CoolPROJECT - " + RegName.text menuitem1.enabled = False Form.ShowModal End Sub 'to exit out of the Reg Window Sub ExitIniFile RegIniForm.Close If RegCode.text = RegNumCheck then Form.Caption = "CoolPROJECT - " + RegName.text menuitem1.enabled = False Else Form.Caption = "CoolPROJECT - Un-Registered Version" menuitem1.enabled = True End If End sub 'Exit out of the CoolPROJECT App Sub ExitMainForm Form.Close End Sub