Board index » delphi » Problem with Assembler in Delphi

Problem with Assembler in Delphi

I would like write a function named GetLongPathName (like the function
GetShortPathName in Win32 API).
I have found  "Interrupt 21h Function 7160h  Get Long Path Name" in the
API windows
So I must write it in Assembler in Delphi with the following code

asm
    mov ax, 7160h
    mov cl, 2                  ; Get Long Path Name
    mov ch, SubstExpand
    mov si, seg SourcePath
    mov ds, si
    mov si, offset SourcePath
    mov di, seg DestPath
    mov es, di
    mov di, offset DestPath
    int 21h
end;

But the compiler refuse the lines which contain "seg". It gives me the
message :
SEG is not declared!!!

My question is : where's  the problem?
How can I pass the segment of the variables?

Thank you for your help

 

Re:Problem with Assembler in Delphi


I would like write a function named GetLongPathName (like the function
GetShortPathName in Win32 API).
I have found  "Interrupt 21h Function 7160h  Get Long Path Name" in the
API windows
So I must write it in Assembler in Delphi with the following code

asm
    mov ax, 7160h
    mov cl, 2                  ; Get Long Path Name
    mov ch, SubstExpand
    mov si, seg SourcePath
    mov ds, si
    mov si, offset SourcePath
    mov di, seg DestPath
    mov es, di
    mov di, offset DestPath
    int 21h
end;

But the compiler refuse the lines which contain "seg". It gives me the
message :
SEG is not declared!!!

My question is : where's  the problem?
How can I pass the segment of the variables?

Thank you for your help

Re:Problem with Assembler in Delphi


No assembler needed!

http://www.preview.org/q/q2003.shtml

has code (Object Pascal) to convert between short and long names:

function GetShortName(sLongName : string) : string;
function GetLongName(sShortName : string) : string;

More Delphi Tips at http://www.preview.org/e/help.shtml?n

Peter

Quote
Christophe LE CORFEC wrote in message <355B3D51.98D66...@wanadoo.fr>...
>I would like write a function named GetLongPathName (like the function
>GetShortPathName in Win32 API).
>I have found  "Interrupt 21h Function 7160h  Get Long Path Name" in the
>API windows
>So I must write it in Assembler in Delphi with the following code

>asm

[..]

Re:Problem with Assembler in Delphi


: Christophe LE CORFEC <Christophe.Lecor...@wanadoo.fr> wrote:

Quote
>I would like write a function named GetLongPathName (like the function
>GetShortPathName in Win32 API).
>I have found  "Interrupt 21h Function 7160h  Get Long Path Name" in the
>API windows
>So I must write it in Assembler in Delphi with the following code

There is no need to use assembler here.

AFAIR, what you will do is to recursively use FindFirst and FindNext
to identify the long equivalent to a short name.

AFAIR Ray Lischner (http://www.tempest-sw.com) has published a small
routine to do this.

Quote
>asm
>    mov ax, 7160h
>    mov cl, 2                  ; Get Long Path Name
>    mov ch, SubstExpand
>    mov si, seg SourcePath
>    mov ds, si
>    mov si, offset SourcePath
>    mov di, seg DestPath
>    mov es, di
>    mov di, offset DestPath
>    int 21h
>end;

>But the compiler refuse the lines which contain "seg". It gives me the
>message :
>SEG is not declared!!!

>My question is : where's  the problem?

You are (obviously) using a 32bit compiler. Segments are not supported
in 32bit BASM.

Quote
>How can I pass the segment of the variables?

You don't do this. You are taking the wrong approach.
--
mailto:Stefan.Hoffmeister (at) Uni-Passau.de
http://kakadu.rz.uni-passau.de/~w4hoff01/
   DIR: Delphi FAQs, KBs, docs
   PGP public key at homepage

Other Threads