Board index » delphi » Problems getting command.com's date and time with TP6

Problems getting command.com's date and time with TP6

Hi,

I am trying to find out the date and time of command.com
from within my program.

I do the folowing:

var
  f: file of byte;
  ft: longint;

begin
  assign(f, 'c:\command.com');
  reset(f);
  GetFTime(f, ft);
  close(f);
end;

I get an 'access denied' message at the 'reset(f)' line.

The file attributes for command.com are set to read only.

Has anyone got any ideas?

Thanks for your help,

Mike Watson

 

Re:Problems getting command.com's date and time with TP6


In article <817235822...@d-m-g.demon.co.uk>, m...@d-m-g.demon.co.uk says...

Quote
>I am trying to find out the date and time of command.com
...
>I get an 'access denied' message at the 'reset(f)' line.

Before assigning the file, do the following:
filemode := 0;
This will open the file as read-only.

Good luck - Ike

Re:Problems getting command.com's date and time with TP6


Quote
Mayes uk <m...@d-m-g.demon.co.uk> wrote:
>Hi,

>I am trying to find out the date and time of command.com
>from within my program.

>I do the folowing:

>var
>  f: file of byte;
>  ft: longint;

>begin
>  assign(f, 'c:\command.com');
>  reset(f);
>  GetFTime(f, ft);
>  close(f);
>end;

>I get an 'access denied' message at the 'reset(f)' line.

>The file attributes for command.com are set to read only.

This appears to be a bug. If you remove the read only attribute it works fine,
but it is kind of strange that you can't open for reading read-only files...

--
Jos van Kan           http://dutita0.twi.tudelft.nl/users/vankan
Math Dept, Delft Univ of Technology, Delft Netherlands.

Re:Problems getting command.com's date and time with TP6


Quote
Mayes uk <m...@d-m-g.demon.co.uk> writes:
>begin
>  assign(f, 'c:\command.com');
>  reset(f);
>  GetFTime(f, ft);
>  close(f);
>end;
>I get an 'access denied' message at the 'reset(f)' line.
>Has anyone got any ideas?

Add FileMode:=0 before reset(). This way, the file will not be opened
read-write, but read-only.

Quote
>Mike Watson

Ciao
Dirk
--
"Hier ist es doof. Das Fruehstuecksbuffet ist zu karg und das Abendessen eine
Frechheit. Ibiza ist toll. Da gab es ein riesiges Fruehstuecksbuffet" -
"Mallorca ist auch gut. Da gab es Abends ordentlich was zu essen" -
"Fuerteventura ist auch nicht so schoen, der Kaffee..." - auf Kreta belauscht

Re:Problems getting command.com's date and time with TP6


In article <DIp4st....@dutiws.twi.tudelft.nl> Jos van Kan <j.van...@math.tudelft.nl> writes:

Quote
>From: Jos van Kan <j.van...@math.tudelft.nl>
>Subject: Re: Problems getting command.com's date and time with TP6
>Date: Mon, 27 Nov 1995 09:53:17 GMT
>Mayes uk <m...@d-m-g.demon.co.uk> wrote:
>>Hi,

>>I am trying to find out the date and time of command.com
>>from within my program.

>>I do the folowing:

>>var
>>  f: file of byte;
>>  ft: longint;

>>begin
>>  assign(f, 'c:\command.com');
>>  reset(f);
>>  GetFTime(f, ft);
>>  close(f);
>>end;

>>I get an 'access denied' message at the 'reset(f)' line.

>>The file attributes for command.com are set to read only.
>This appears to be a bug. If you remove the read only attribute it works fine,
>but it is kind of strange that you can't open for reading read-only files...
>--
>Jos van Kan           http://dutita0.twi.tudelft.nl/users/vankan
>Math Dept, Delft Univ of Technology, Delft Netherlands.

It's not a bug.  By default, the RESET function opens a file for
read/write access.  Since you don't have write access to the file,
the RESET function fails.  You need to modify the TP built-in
variable, FILEMODE.  Its default value is 2 (read/write).  Before you
perform the RESET, set its value to 0 (read-only), by simply inserting
the command, FILEMODE := 0; before the RESET line.

Re:Problems getting command.com's date and time with TP6


Quote
On Mon, 27 Nov 1995, Jos van Kan wrote:
> Mayes uk <m...@d-m-g.demon.co.uk> wrote:
> >Hi,

> >I am trying to find out the date and time of command.com
> >from within my program.

> >I do the folowing:

> >var
> >  f: file of byte;
> >  ft: longint;

> >begin
> >  assign(f, 'c:\command.com');
> >  reset(f);
> >  GetFTime(f, ft);
> >  close(f);
> >end;

> >I get an 'access denied' message at the 'reset(f)' line.

> >The file attributes for command.com are set to read only.

> This appears to be a bug. If you remove the read only attribute it works fine,
> but it is kind of strange that you can't open for reading read-only files...

I thought that the file had to be closed to get the file date/time.  
Anyway, isn't command.com always reading from command.com (even when it's
loaded /p)?

    ________________________________________________________________________
   / Joshua Shagam                    /    (Quantum Porcupine / Versatile) /
  / mailto:JSha...@nmsu.edu          /       http://web.nmsu.edu/~jshagam /
 / phone://1.505.645.3856/~joshua   /  for the Quantum Porcupine Archive /
/__________________________________/____________________________________/
 Stop the execution of King Louis XIV!  If you agr-- oops, too late! :)

Re:Problems getting command.com's date and time with TP6


On Mon, 27 Nov 1995 09:53:17 GMT,
Jos van Kan   <j.van...@math.tudelft.nl> wrote:

Quote
>Mayes uk <m...@d-m-g.demon.co.uk> wrote:
>>Hi,

>>I am trying to find out the date and time of command.com
>>from within my program.

>>I do the folowing:

>>var
>>  f: file of byte;
>>  ft: longint;

>>begin
>>  assign(f, 'c:\command.com');
>>  reset(f);
>>  GetFTime(f, ft);
>>  close(f);
>>end;

>>I get an 'access denied' message at the 'reset(f)' line.

>>The file attributes for command.com are set to read only.

>This appears to be a bug. If you remove the read only attribute it works fine,
>but it is kind of strange that you can't open for reading read-only files...

This is because TP's "reset" procedure doesnt just open a file for reading.
The default is read/write.  This is just fine if you are going to
read and write records of an existing file.  Not so good if you want
to just read.   You have to set the "FileMode" variable to a different
setting to get reset to open just for reading.

-----------------------------------------------------------------------
George R. Gonzalez                        g...@boombox.micro.umn.edu
Sr. Sys. Programmer                       University of Minnesota

6AF6 = 2 * 6E5?

Re:Problems getting command.com's date and time with TP6


In <817235822...@d-m-g.demon.co.uk>, Mayes uk <m...@d-m-g.demon.co.uk> writes:

Quote
>Hi,

>I am trying to find out the date and time of command.com
>from within my program.

>I do the folowing:

>var
>  f: file of byte;
>  ft: longint;

>begin
>  assign(f, 'c:\command.com');
>  reset(f);
>  GetFTime(f, ft);
>  close(f);
>end;

>I get an 'access denied' message at the 'reset(f)' line.

>The file attributes for command.com are set to read only.

>Has anyone got any ideas?

>Thanks for your help,

>Mike Watson

Instead of opening the file, you could always use the FINDFIRST()
procedure to get the time and date.

--
Wayne D. Hoxsie Jr. <hoxs...@crl.com>
finger or http://www.crl.com/~hoxsiew for PGP key

Re:Problems getting command.com's date and time with TP6


Quote
In article <817235822...@d-m-g.demon.co.uk>, Mayes uk <m...@d-m-g.demon.co.uk> writes:
> Hi,

> I am trying to find out the date and time of command.com
> from within my program.

> I do the folowing:

> var
>   f: file of byte;
>   ft: longint;

> begin
>   assign(f, 'c:\command.com');
>   reset(f);
>   GetFTime(f, ft);
>   close(f);
> end;

> I get an 'access denied' message at the 'reset(f)' line.

> The file attributes for command.com are set to read only.

> Has anyone got any ideas?

> Thanks for your help,

> Mike Watson

You could copy command.com into another file an open this copy...

   Sacha Schaer

Other Threads