Fórum Cluster de um arquivo no HD #184345

26/09/2003

0

:?
[b:03a5d32920]
Olá pessoal !

Estou precisando saber o cluster que esta um tal arquivo. tem uma rotina de exemplo em asm no help do delphi, mas nao funciona ja tentei escreve-la no proprio assembly mas retorna varios caracteres.
A rotina usa int 21 subfunção 440Dh menor codigo 71h.

Gostaria de saber se tem uma função, componente ou qqr coisa q me retorne um numero do cluster ou algo do tipo.

Quem puder ajudar, será de muito agradecimento.

Até +.
[/b:03a5d32920]


Batelli

Batelli

Responder

Posts

26/09/2003

Aroldo Zanela

Colega,

[quote:260cd29133=´raphael_perez@uol.com.br´]
People,

I am making a work for the university and in this work the teacher asked to
do the following:

in delphi, using any programming type ( object pascal, assembler,...), to
discover the first cluster of the specified file and to record of the
specified file of the specified cluster.

Seeking in Help of the windows, I discovered a code that the first cluster
of the specified file. the problem is that don´t get to do to work.

the code is the following:

[New - Windows 95]

mov ax, 440Dh ; generic IOCTL
mov bx, CharSet ; see below
mov ch, 08h ; device category
mov cl, 71h ; Get First Cluster
mov dx, seg PathName ; see below
mov ds, dx
mov dx, offset PathName
int 21h

jc error


Retrieves the first cluster of the specified file or directory.

· Clears the carry flag and sets DX:AX to the first cluster number if
successful. Otherwise, the function sets the carry flag and returns either
the ERROR_INVALID_FUNCTION or ERROR_ACCESS_DENIED value in AX.

CharSet

Character set of PathName. This parameter must be one of these values:

BCS_WANSI (0) Windows ANSI character set
BCS_OEM (1) Current OEM character set
BCS_UNICODE (2) Unicode character set
PathName

Address of a null-terminated string containing the path of the file or
directory to retrieve the first cluster for.

The first cluster of a file is the first cluster of the FAT cluster chain
describing the data associated with the file. The first cluster of a
directory is the first cluster of the FAT cluster chain associated with the
directory. It is the cluster that contains the ´.´ and ´..´ entries. The
function finds any file or directory regardless of attribute (system,
hidden, or read-only). It does not find volume labels.
If your application is unable to accommodate a 32-bit cluster number, you
must check to see if the value returned in the DX register is greater than
zero.

if(MAKELONG(regAX,regDX) > 0x0000FFF8)
b32BitNum = TRUE;
else
b32BitNum = FALSE;


It is the calling application´s responsibility to check to see if the
returned cluster number is valid.

if((MAKELONG(regAX,regDX) < 2L) || (MAKELONG(regAX,regDX) > maxClus))
bInvalidNum = TRUE;
else
bInvalidNum = FALSE;


In the preceding example, the maxClus variable is the maximum legal cluster
number, as a DWORD type, computed from the drive parameters.

the code that I am trying to use is the following:

procedure TForm1.Button1Click(Sender: TObject);
var nome : pchar;
p : ^pchar;
begin
nome := ´a:\file.txt´;
p := @nome;
asm
mov ax, 440Dh
mov bx, 0
mov ch, 08h
mov cl, 71h
mov dx, seg p
mov ds, dx
mov dx, offset p
int 21h

jc error
end;

end;


I need your help to solve this problem and to get some function where I can
record of the specified file of the specified cluster (in the diskette,
winchester,...)

I thank any help.

raphael
raphael_perez@uol.com.br
[/quote:260cd29133]

[quote:260cd29133=´Peter Below (TeamB)´]
Remove the p, nome is already a pointer so you can use seg nome, offset
nome. But this code will only work in Delphi 1 since it is 16 bit assembler
code. Use

Call Dos3Call

instead of int 21h.

In 32 bit Delphi you would have to use the DeviceIOControl API function
with the VWIN32 device to be able to execute a DOS function. Would also not
work on NT, of course. There such work would require a device driver and
would not make sense for NTFS partitions anyway, since they are totally
different from the old FAT file system organization.

Peter Below (TeamB) 100113.1101@compuserve.com)
[/quote:260cd29133]


Responder

Gostei + 0

29/09/2003

Batelli

Agradeço a atenção.

Mas pelo que eu entendi, só funciona no delphi 1 (16bits) ?

Se eu precisar usar no delphi 5, preciso usar a function deviceiocontrol.
Como faço ?

Muito Obrigado .


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar