Is it possible for a TB program to read some unique identifier of the individual computer on which the program is being run?

Thanks for any help.
Regards, Mike C


Using the Hard drive serial number

Hi folks,
I posted a short piece of code that allows a program to find the HD serial number. Once you have this number, you can use it to prevent unauthorized use of a program on any other computer.
The way to do this is to write a short additional program that modifies one small piece of data in the original executable program. This only works because string constants are stored verbatim in the executable program.
For example suppose you create a string constant of eight characters, e.g. let serial$="ZZZZZZZZ". Insert this line of code into you own program and then bind it into an executable version. So far so good.
Now let's turn to the additional program (or it could even be a routine within the original executable program). The sole purpose of this program is to find the volume serial number and to embed it in place of the string constant (ZZZZZZZZ) in your original executable program.
In simple terms you can read all the bytes in your executable program and use something like:
Let target=pos(totalbyte$,"ZZZZZZZZ")
This locates the byte number in your executable where the string constant starts. You now substitute the 8 characters of the serial number in place of ZZZZZZZZ and save this new modified version of your executable file.
A simple line of code in your program will allow you to compare the volume number with the variable serial$. If they do not match then your program is not being run on the same machine when it was run for the very first time.
I have used this strategy countless times in virtually all my commercial programs.
NOTE: I have a similar program called ICONEX which searches an executable program for the TrueBasic standard toolbox icon. Since icons are 32x32 pixel bitmaps, the toolbox icon can be replaced with any other icon as long as it is the same format. In other words ICONEX works in exactly the same way as the HD serial number procedure above.
I hope that this clarifies the method.
Regards, BigJohn

Using Hard Drive SN

Hi BigJohn,

I have tried that code you posted below, that allows a program to find the HD serial number, but it will not work for me. Silver 5.33 and Gold 5.5b19.

All I get is "Program not available for CHAIN. (10005) in Main program"

I can get the HD SN from the Command Prompt with the command "vol", and also with the "wmic diskdrive get serialnumber".

What am I doing wrong that your code isn't working? I want to use this for exactly the same code protecting purpose you mentioned above.

Thanks for any help.
Mike C.

Hard drive volume

This little bit of code will find the hard drive serial number.

OPEN #1:name "hd.ser",access outin,create newold,org byte
ASK #1: FILESIZE total
SET #1: RECSIZE total
READ #1: txt$
LET location$= "Volume Serial Number is "
LET location=pos(txt$,location$)
LET volume$=txt$[location:maxnum]
print volume$


No version of TB ever allowed the user to access the computer ID, but the Hard Drive volume number can be accessed. I have used this technique to protect software - when the software is first loaded onto a computer it reads the volume number and writes this number into the software program. Every time the program is run, it checks to see if the current volume number corresponds to the original number. Nice and simple.

How to read volume etc

Thanks for this information. But I don't know how to actually do that.
Presumably there would be some lines of code to insert into the program before binding it.
I don't see anything in the manual about it, so could you please explain exactly what to do?
I surely would appreciate it.

Mike C.

re:machine id

I don't think so. It would be in the Sysinfo Method and the closest thing there is the MACHINE identifier but that only indicates MAC, WIN32, etc., not the actual machine ID. This is something to put on the wish list should there ever actually be a Version 7 produced.


machine ID

Thanks, rwt
I figured it couldn't be done. I looked everywhere and tried everything.

By the way, are we the last of the the TB posters? Since new postings do not appear unless one logs in, I suspect that by now everyone thinks the site is defunct and nobody even bothers to look anymore. I mentioned to admin some time back that this should be fixed.

What a sad 50th anniversary for True Basic.