Serial number + App & stack bundle

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Serial number + App & stack bundle

Post by gyroscope » Sun Feb 01, 2009 10:26 pm

Hi, is there an easy way to get the user's computer serial number, in an "on preOpenCard" handler, for instance :?: (Hopefully cross-platform bit of code)

Also, I'm going down the route for all my apps of making the splash screen the app and all other substacks kept as stacks when the app is built (because of the ease of saving data, this way).

For the Mac, this bundles all the files together but I seem to remember reading that for a PC it shows these stacks as separate files. Is there a way of bundling them like the Mac does? Or is there no point, providing these stacks are protected from being opened :?:

Any advice appreciated, thanks.

:)

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sun Feb 01, 2009 11:33 pm

Hi Gyroscope,

On the Mac, it is possible to use a shell command that reads the serial number from the system profile. You should keep in mind though that many old computers don't have a serial number as a result of repairs. Right now I have five Macs running and only the newest has a serial number.

I don't think that it makes sense to read a serial number from PC's, as very many PC's are assembled at the store rather than in the factory. Perhaps you should try something else.

If you want to bundle your files, you should use an installer. Windows users may not understand that they can copy a programme to the application folder and many will get confused if shortcuts don't appear automatically on the desktop and in the start menu.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Mon Feb 02, 2009 12:24 pm

Instead of a serial number for the computer, you could interrogate the volume serial number, for example. (This would be prone to change due to hardware replacement, but may suit your purposes).
Ken Ray shows how for Windows http://www.sonsothunder.com/devres/revo ... isk001.htm and I expect there is something similar for Mac.
Otherwise getting some other info from the WMI interface (see http://forums.runrev.com/phpBB2/viewtop ... 57&start=0 for some background relating to hard disks, but http://www.microsoft.com/technet/script ... _fxkq.mspx will show you some other information available, such as the properties of the operating system from which you could retrieve the serial number.

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Mon Feb 02, 2009 3:56 pm

On the Mac, it is possible to use a shell command that reads the serial number from the system profile.
Instead of a serial number for the computer, you could interrogate the volume serial number, for example.
Thank you for your replies, Mark and SparkOut. The reason why I wanted to get the user's serial number registered was to script so that if my app was copied and run on another computer, and the serial numbers didn't match, then the app wouldn't open.

As Mark pointed out, some earler machines might not have a serial number, etc; I'm revisiting preferences info to distinguish which computer the app was registered on, so that if the software was run on another computer, matching saved info in the stack with the absence of a preferences file would be a good way to know that the software is being run on another computer.

(I'd point out, in a Read Me file, that if a user changes computers, that the software would need to be re-registered).

OK, preferences files; I've had a few "fights" with different preferences code form different people, not able to get any to work (my lack of understanding; preferences files code have always slightly confused me for some unknown reason...).

Mark, I've finally got some of your code to work (which you posted in a previous thread) but can't put the info back into fields:

Code: Select all

on mouseUp pMouseBtnNo
    savePrefs
end mouseUp

    global gPrefsVar 
on savePrefs 
  put gPrefsVar & cr & the cPrefsProp of stack "Untitled 2" & cr &\
    "Whatever information you want" & cr & field "FieldA" \
    & cr & field "FieldB" & cr & field "FieldC" into myPrefs
  put specialfolderpath("preferences") & "/ISaGo.prefs" into myFilePath 
  open file myFilePath 
  write myPrefs to file myFilePath 
  close file myFilePath 
end savePrefs 
and

Code: Select all

on mouseUp pMouseBtnNo
  savePrefs  
end mouseUp

global gPrefsVar 
on savePrefs 
  put specialfolderpath("preferences") & "/ISaGo.prefs" into myFilePath 
  open file myFilePath 
  read from file myFilePath until EOF 
  close file myFilePath 
  put line 1 of it into gPrefsVar 
  set the cPrefsProp of stack "Untitled 2" to line 2 of it 
  return line 3 of it -- "Whatever information...."
  ---I've added these lines, but it doesn't work......
put line 3 of URL "file:ISaGo.prefs" into field "FieldD"
  put line 4 of URL "file:ISaGo.prefs" into field "FieldA"
  put line 5 of URL "file:ISaGo.prefs" into field "FieldB"
end savePrefs 
I'd be obliged if you or anyone else could tell me how to put the lines of data back into specific fields again please.

:)

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Mon Feb 02, 2009 4:32 pm

Open File, Read/Write, Close File may be a bit OTT for a simple preferences file, assuming there's not a huge amount of data, I'd read the whole file in and out in one go.

(You seem to have started on that variation in your second routine, but you would need to set the path in the URL line appropriately)

Code: Select all

on savePrefs
  local tPrefs, myFilePath
  put field "FieldA" into line 1 of tPrefs
  put field "FieldB" into line 2 of tPrefs
  put field "FieldC" into line 3 of tPrefs
  put field "FieldD" into line 4 of tPrefs
  put specialFolderPath("preferences") & "/ISaGo.prefs" into myFilePath
  put tPrefs into URL ("file:"& myFilePath)
end savePrefs

Code: Select all

on readPrefs
  local tPrefs, myFilePath
  put specialFolderPath("preferences") & "/ISaGo.prefs" into myFilePath
  put URL ("file:"& myFilePath) into tPrefs
  put line 1 of tPrefs into field "FieldA"
  put line 2 of tPrefs into field "FieldB"
  put line 3 of tPrefs into field "FieldC"
  put line 4 of tPrefs into field "FieldD"
end readPrefs
Once you are happy with the file being read in and out OK, if you wanted to obfuscate the settings and hopefully prevent any circumvention of registration control, you could also base64Encode the tPrefs and compress them, (as well as perhaps going to some longer lengths to prevent unauthorised intervention) before putting into the URL, and after reading the URL back into memory, decompressing and unencoding the tPrefs before putting the lines back into the fields.

Bear in mind that there is no "Preferences" folder for Windows.
You should probably use the CSIDL_LOCAL_APPDATA folder for application specific options relating to a user - specialFolderPath(28)

See Ken Ray's tips: http://www.sonsothunder.com/devres/revo ... ile010.htm for info about what folder path codes relate to standard locations on Windows systems.

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Mon Feb 02, 2009 8:37 pm

Excellent SparkOut, just what's needed, thanks!
Bear in mind that there is no "Preferences" folder for Windows.
So for Windows, I replace

Code: Select all

put specialFolderPath("preferences") & "/ISaGo.prefs" into myFilePath
with

Code: Select all

put specialFolderPath(28) & "/ISaGo.prefs" into myFilePath
Would that be correct :?:

(I seem to be quick on the uptake with certain things, and not so much on others... :wink:)

Also, I would want to check first if the preferences file exists; I tried this:

Code: Select all

 if there is no specialfolderpath("preferences") & "/ISaGo.prefs" then
  beep
  else
.....
Which didn't work. Could someone tell me what the correct code would be, please :?:

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Mon Feb 02, 2009 11:00 pm

Code: Select all

if there is no file (specialFolderPath("Preferences") & "/IsaGo.prefs") then...
should work

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Mon Feb 02, 2009 11:24 pm

It certainly does; thanks again, Sparkout.

:)

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Tue Feb 03, 2009 12:00 am

Good oh, and yes, btw, replace specialFolderPath("preferences") with specialFolderPath(28) on a Windows system (to have it use the local Application Data folder under the user's documents and settings directory, anyway). See Ken's page for lots of info about the locations you can use.

Post Reply