Hello nrmuduli,
Interesting question you are asking here.
If I understand correctly, you want your users to be able to copy/paste the install folder from one computer to another, but if MVD detects that it is running on a new system for the first time, all data from database must be erased.
Hmmmm....
Here is what I would do. All this must take place on the Form1 OnShow event because this is the first thing that happens when you launch application made with MVD (or whatever the name of your first form).
each time your application is launched, you must check if the computer unique ID is present in database
if present and the same as before, OK, the application runs normally
if present but not the same, then all tables must be erased and the application starts from fresh
if not present, then it's the same, clear all tables and start from fresh
With what MVD has to offer today, I would suggest using the getHardDiskSerial as unique ID. It's the best I can think of for the moment.
Then, this serial must be inserted into database, and checked each time the application starts.
Something like :
procedure Form1_OnShow (Sender: string; Action: string);
var
unique_id : String;
HD : String;
known_id : Integer;
begin
HD := GetHardDiskSerial('C'); //generate unique ID from hard drive serial
known_id := SQLExecute('SELECT COUNT(id) FROM new_install WHERE unique_id="'+HD+'"'); //count this ID from database
if known_id = 0 then //if result of count = 0 then this is not the same hard drive
begin
SQLExecute('DELETE FROM new_install'); //delete everything from all tables
SQLExecute('DELETE FROM tableA');
SQLExecute('DELETE FROM tableB');
SQLExecute('DELETE FROM tableC');
SQLExecute('DELETE FROM tableD');
SQLExecute('INSERT INTO new_install(unique_id) VALUES("'+HD+'")'); //insert new ID for next start test
end;
end;
What I've done here is :
generate an ID from the serial number of drive C
check in database if this serial is known
if not known then erase all tables and insert that ID in table new_install
on next start on the same computer, serial is known and nothing happens, the application starts normally
but if the folder has moved from computer A to computer B, the Hard Drive serial will change, and everything is erased with insertion of a new serial
CAUTION : this is far from perfect. For example, if Hard Drives are the same, I suppose that serial numbers will be different, but that's just a guess on my part. And what if the folder is copied on the second computer of the same user who needs his data to work ? Or if he moves his install folder from drive C to drive D on the same computer ?
Anyway, let see what the others think of all that.
Cheers
Mathias
I'm a very good housekeeper !
Each time I get a divorce, I keep the house
Zaza Gabor