Can the EBook display the activation code somewhere? SOLVED

Hi,

This is a pre-sales question. I haven’t even downloaded HTMLExe to try it yet, hoping to get this answered first…

Is there any way during either startup or display of the ebook, that it can display the user’s activation code?

I would like either a splash screen or panel at the bottom of the viewer, etc., to display something like “Licensed to James C. Doe”. We feel it is a great deterrent to unauthorized copying to have the user’s name embedded in the activation code, but without the hassles of online access to an activation server.

(We’re software developers, so if the solution involves some scripting, etc., we’re up for that…)

FlagTech

You can retrieve the user name or his activation code with HEScript. Then, it’s up to you to display it where you want, for instance in your index page or in the status bar for instance.
Some code that you may use to store the registered user name in a global variable:

 if GetGlobalVar("hepubregistered", "0") = "1" then
  begin
   S := GetGlobalVar("hepubuserdata1", ""); 
   if S <> "" then S := " (" + S + ")";
   S := GetGlobalVar("hepubusername", "") + S;
   SetGlobalVar("RegisteredUser", "Licensed to " + S), false);
  end
  else
  begin
   SetGlobalVar("RegisteredUser", "Not licensed", false);
  end;
 end;  

Then, you can get the value of this RegisteredUser global variable with JavaScript or HEScript as explained here:
http://www.htmlexe.com/help/globalvariables.htm

Excellent…thanks.

Can these techniques be used to display this information in either the Start Prompt message or the Please Wait dialog box?

I’m trying to figure out how/where to display it so that the licensed/registered user readily understands that if he passes a copy to someone else, his name & registration code will appear prominently…identifying the copy as one licensed to him/her.

Or where would you suggest is the best place/opportunity to show this information? Maybe on the Index page, as you mentioned?

Maybe “About Message” is the best place :shock:

You can’t display it in the “Please wait” dialog box, because registered user info is not loaded at this time. However, it’s possible to display a message box at startup, something like “Program licensed to …, distribution is prohibited”.
The index page is a good place in my opinion. The about box too, but HTMLExe already inserts the name of the registered user in the about box.

So would the code above be inserted into the UserMain script?

Yes, you can insert it in the UserMain script (the best place would be in the OnStartMainWindow event).

When I add the script to the UserMain, I get the following error;

Error in script:
Line 43, column 4: Unknown identifer "S"
Fatal error: script not compiled.

The following line is then highlighted in red;
S := GetGlobalVar(“hepubuserdata1”, “”);

You need to declare S before you can use it in the procedure itself. Try this:

procedure ThisIsMyProcedure;  

var
S:string  

....rest of code goes here...  

Cheers,

Rich

Many thanks, that’s brilliant. Just what I wanted.

Kindest regards and Season’s Greetings for 2011,

Jamie

I am new to scripting but would like to be able to do it!

Could someone please tell me exactly (code and instructions) how to display the user name and registration key on the front page of my book. I have tried to make sense of the help section but cannot get the data to display using any of the suggestions in the help text.

This is the script I am using (based on above posts in this section, with corrected syntax):

procedure Details;
var
S: string
begin
if GetGlobalVar(“hepubregistered”, “0”) = “1” then
begin
S := GetGlobalVar(“hepubuserdata1”, “”);
if S <> “” then S := " (" + S + “)”;
S := GetGlobalVar(“hepubusername”, “”) + S;
SetGlobalVar(“RegisteredUser”, "Licensed to " + S, false);
end;
else
begin
SetGlobalVar(“RegisteredUser”, “Not licensed”, false);
end;
end;

I set this up in User Scripting as “test” and tried using hescript://test.Details as an html link and also tried calling in the script with javascript routines but just cannot get the info to display. I am, of course using a registered version of my book to test this so the registered name and registration key are available.

Help much appreciated.

Use this JavaScript code:

<script type="text/javascript">
window.external.runHEScriptCom("test.Details");
document.write(window.external.GetGlobalVariable("RegisteredUser"));
</script>

The first line calls your test.Details HEScript procedure that creates the RegisteredUser variable.
The second line writes the value of RegisteredUser into the HTML document.

Thanks, I really appreciate your help.

Unfortunatly, when I run the script I get a JavaScript error:

http://heserver/index.html
0 9:1
Wrong number of arguments or invalid property assignment

This is line 9:
9 document.write(window.external.GetGlobalVariable(“RegisteredUser”));

Also,
Can you please tell me the name of the global variable assigned to the registration key so I can attempt to modify the script to call both the user name and the registration key? If you have the time to suggest how the script could be modified to call up both variables that would be wonderful.

Regards

My bad. The correct script:

<script type="text/javascript">
window.external.runHEScriptCom("test.Details");
document.write(window.external.GetGlobalVariable("RegisteredUser", "Not registered"));
</script>

And for the activation code, modify the first script like this:

procedure Details;
var
S: string
begin
if GetGlobalVar("hepubregistered", "0") = "1" then
begin
S := GetGlobalVar("hepubuserdata1", "");
if S <> "" then S := " (" + S + ")";
S := GetGlobalVar("hepubusername", "") + S;
SetGlobalVar("RegisteredUser", "Licensed to " + S + ", key: " + GetProperty("UserKey", ""), false);
end;
else
begin
SetGlobalVar("RegisteredUser", "Not licensed", false);
end;
end; 

This topic was automatically closed after 24 hours. New replies are no longer allowed.