Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-10

Reading and writing volume IDs

4 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Aitor Santamaria Merino

Hi all,

I thought the following:

FindFirst ('c:\', volumeID, SR);
mylabel := sr.name;

would work in order to get the volume ID, but it doesn't. THe strange thing is that (except for misprints) such a code gives me a 'no more files' DOSerror under TP, and a 'file not found' (I think) under FPK. Now how can I read such a volume ID?

And what about modifying it? Is there any unit out there that I can use to do this?

Thanks!

Aitor

Reply by email

Pierre Muller
to Aitor Santamaria Merino

At 00:12 02/10/01 , vous avez écrit:

Show quoted text 6 lines
Hi all, I thought the following: FindFirst ('c:\', volumeID, SR); mylabel := sr.name;
Maybe you should try
FindFirst ('c:\*.*', volumeID, SR);

The pattern is important here !
if the volume ID doesn't match the given pattern, you will get NO_MORE_FILE (Dos error 18) as for usual files.

would work in order to get the volume ID, but it doesn't. THe strange thing is that (except for misprints) such a code gives me a 'no more files' DOSerror under TP, and a 'file not found' (I think) under FPK. Now how can I read such a volume ID?

Reply by email

Aitor Santamar�a

Ooops!! You're right, sorry.

Well, what about writing labels?
Anyone has something written? Otherwise I am afraid I would have to use a DOS call and mess up with real mode pointers, etc.

Aitor

Show quoted text 26 lines
At 00:12 02/10/01 , vous avez �crit: >Hi all, > >I thought the following: > >FindFirst ('c:\', volumeID, SR); >mylabel := sr.name; Maybe you should try FindFirst ('c:\*.*', volumeID, SR); The pattern is important here ! if the volume ID doesn't match the given pattern, you will get NO_MORE_FILE (Dos error 18) as for usual files. >would work in order to get the volume ID, but it doesn't. THe strange >thing is that (except for misprints) such a code gives me a 'no more >files' DOSerror under TP, and a 'file not found' (I think) under FPK. >Now how can I read such a volume ID? _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_____________________________________________________________________ Si no encuentras lo que buscas... �a qu� est�s esperando para entrar en www.wanadoo.es? Con nuestro nuevo motor de b�squeda conseguir�s m�s r�pido resultados de actualidad, personalizados y renovados diariamente.

Reply by email

Unknown author
to Aitor Santamar�a

Date sent: Tue, 2 Oct 2001 10:37:26 +0200
Subject: Re: [fpc-pascal]Reading and writing volume IDs From: "Aitor Santamaría"
To:
Send reply to:

Ooops!! You're right, sorry.

In fact, you should use:

FindFirst ('c:\*.*', VolumeID, SR);
while (DosError = 0) and SR.Attr and VolumeID  VolumeID do
   FindNext (SR);

This is because you can get ordinary files (with no attributes set at all) with this mask as well.

Well, what about writing labels?

In theory you could create a zero-length file in the root directory and call SetFAttr afterwards. I haven't checked it, so I don't know, whether it really works. Anyway, there are at least two problems with this solution. First, you should make sure no other item with this attribute exists there (and delete it first otherwise). Second, the preferred (more universal - can be used on non-FAT volumes as well) way of setting volume labeles is using the BPB (i.e. in the boot sector). However, you can't avoid calling DOS or BIOS function calls for this.

Tomas

Reply by email