View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Licence Verification

Brevity of code.

In my production stuff I use the APIs, in case there is a downer on
installing WSH.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"RB Smissaert" wrote in message
...
oWSH.RegRead


Interesting, first time I have seen this. Any reason why you prefer this
above
reading the registry with the Windows API?

RBS


"Bob Phillips" wrote in message
...
Don't know about all the pfaffing about with the main.xls, and not

really
understanding how you would validate the licence value, but you could

put
this in the workbook open event (ThisWorkbook code module). It checks
whether there is a licence key, so just change the registry key to suit.

Private Sub Workbook_Open()
Dim oWSH As Object
Dim sResult

Set oWSH = CreateObject("WScript.Shell")

On Error Resume Next
'Read language registry key information
sResult = oWSH.RegRead("HKLM\Software\Alan\myApp\Licence\")
If Err.Number < 0 Or sResult = "" Then
MsgBox "No valid licence" & vbCrLf & _
"Contact Alan for a valid version"
Me.Close savechanges:=False
End If
Err.Clear

On Error GoTo 0

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"alanford" wrote in message
oups.com...
I have built a module to ensure that my managers follow the correct
procedure for their risk assessment, now the company has shown an
interest in my work, however I would like to limit the access to the
program in the following manner if possible.
During install I can input a string in LOCALMACHINE as a licence number
I need to build a workbook called main.xls wich will run once after
intall with a inputbox which will look into localmachine and read the
string, after verification that the string matches it will rename
itself as main.old and rename another file main2.xls as main.xls. if
the string does not match a msgbox would prompt the user to contact me
to obtain a installable version of the program with a valid licence. I
hope this makes sence. thank you for your help.

Alan