News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

BaseName

Started by DerCoder, December 11, 2011, 08:50:57 PM

Previous topic - Next topic

DerCoder

Hey guyz,

is there a possibility to get a paths basename. For example:
.DATA
    szPath DB "C:\folder1\folder2\file.ext", 0
...
.CODE
    invoke BaseName, ADDR szPath

would store "file.ext" in eax register.

Maybe there is a macro?

Greetz DerCoder

Gunner

Open \masm32\help\masmlib.chm there is a function called NameFromPath
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

DerCoder

WOOW Big thx for 1) the fast reply and 2) for the nice answer =)

jj2007

Another option ;-)

include \masm32\MasmBasic\MasmBasic.inc   ; Download
   Init
   Inkey Mid$(CL$(), Rinstr(CL$(), "\")+1)   ; CL$() means CommandLine$
   Exit
end start

ragdog

Or use from Shlwapi.lib PathFindFileName

PTSTR PathFindFileName(
  __in  PTSTR pPath
);

Invoke PathFindFileName,addr szPath

And other Path function in Shlwapi can your read here.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb773559%28v=VS.85%29.aspx

Or use my old code

invoke  lstrlen,addr szPath
    lea  esi,szPath
   add  eax,esi
.while BYTE PTR [eax] != '\'
        dec  eax
.endw
inc  eax


Greets,