abuela
asked on
Version numbers
Has anyone found any code that puts version numbers on any file, and not just the *.exe (Delphi code if possible).
Is there any where on a text file or any file that I can store a 16 bit number.
Is there any where on a text file or any file that I can store a 16 bit number.
ASKER
Edited text of question.
hmmm, saving projects in a structure like:
dev/projectX/version0.1
dev/projectX/version0.2
dev/projectX/version0.3
with the latest version in
dev/projectX/
works good.
What do you want to accomplish?
Floris.
dev/projectX/version0.1
dev/projectX/version0.2
dev/projectX/version0.3
with the latest version in
dev/projectX/
works good.
What do you want to accomplish?
Floris.
If you don't want to have the 16bit number appearing in any text editor than you cannot assign such a number to a text file. Floris' suggestion is ok, as well as using the file data stamp.
Ciao, Mike
Ciao, Mike
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There is a tool you can use to change the properties of all files in a directory, with this you can easily set all descriptions in one directory. I have it at home.
Floris.
Floris.
You could also do what we did in the old (DOS) days and put the version number in the "time" field for the file... all Version 1.0 files "created" at 1:00PM, Version 1.5 at 1:50PM etc. (just don't make a version 1.7)
runebj
runebj
I think there's a possibility on the NTFS-level to save save a file-specific stream on the disk. Don't aks me how it works or about a source snippet.... (see NT Internals)
ASKER
Do you know how to append version info to the end of the file.
OK, I show you sample, just a moment....
Hi,
The code is bellow:
const VersionPrefix = $1234DC1A; // some unical value, used as version prefix
// result is cureent version if present, or -1 if no version label
function GetFileVersion(aFileName : string) : integer;
var F : TFileStream;
U,V : integer;
begin
result:=-1;
F:=TFileStream.Create(aFil eName,fmOp enRead);
F.Seek(-SizeOf(Integer)*2, 2);
F.Read(U,SizeOf(Integer));
if U = VersionPrefix // have a version prefix?
then F.Read(result,SizeOf(Integ er));
F.Free;
end;
// set version to file, true if success
function SetFileVersion(aFileName : string; aVersion : integer) : boolean;
var F : TFileStream;
U,V : integer;
begin
result:=false;
V:=GetFileVersion(aFileNam e); // have a version?
if V = aVersion then result:=true else
try // set version if file have no version or have different from aVersion
F:=TFileStream.Create(aFil eName,fmOp enWrite);
if V >= 0
then F.Seek(-SizeOf(Integer)*2, 2)
else F.Seek(0,2);
U:=VersionPrefix;
F.Write(U,SizeOf(Integer)) ;
F.Write(aVersion,SizeOf(In teger));
F.Free;
result:=true;
except end;
end;
//------------------------ ---------
Best regrads,
Igor.
PS: it will add some extra characters in text files.
The code is bellow:
const VersionPrefix = $1234DC1A; // some unical value, used as version prefix
// result is cureent version if present, or -1 if no version label
function GetFileVersion(aFileName : string) : integer;
var F : TFileStream;
U,V : integer;
begin
result:=-1;
F:=TFileStream.Create(aFil
F.Seek(-SizeOf(Integer)*2,
F.Read(U,SizeOf(Integer));
if U = VersionPrefix // have a version prefix?
then F.Read(result,SizeOf(Integ
F.Free;
end;
// set version to file, true if success
function SetFileVersion(aFileName : string; aVersion : integer) : boolean;
var F : TFileStream;
U,V : integer;
begin
result:=false;
V:=GetFileVersion(aFileNam
if V = aVersion then result:=true else
try // set version if file have no version or have different from aVersion
F:=TFileStream.Create(aFil
if V >= 0
then F.Seek(-SizeOf(Integer)*2,
else F.Seek(0,2);
U:=VersionPrefix;
F.Write(U,SizeOf(Integer))
F.Write(aVersion,SizeOf(In
F.Free;
result:=true;
except end;
end;
//------------------------
Best regrads,
Igor.
PS: it will add some extra characters in text files.
ASKER
Thanks for the code.
I think you are asking too much. Where will you store version information, say, for a text file? There is no room planned to keep version information in other then exe, dll, vxd etc. files. So you have no other choice than to live with that...
Ciao, Mike