Ver Mensaje Individual
  #181  
Antiguo 17-11-2008
Khronos Khronos is offline
Miembro
 
Registrado: abr 2007
Posts: 298
Reputación: 18
Khronos Va por buen camino
Bueno, veo que el hilo esta un poco abandonado y pensé: "vamos a revivir el hilo con más código inútil"

Bueno el siguiente código son copias "baratas" de las funciones ExtractFileName, ExtractFileExt y ExtractFilePath pero menos sofisticadas que las que vienen en la unidad SysUtils

Código Delphi [-]
function ExtractFileNameW(const FileName: string): string;
var
i: integer;
begin
  result:= EmptyStr;
  for i := Length(FileName) downto 0 do
      begin
        if FileName[i] = '\' then
          begin
            result:= Copy(FileName, i + 1, length(FileName));
            break;
          end;
      end;
end;

function ExtractFileExtW(const FileName: string): string;
var
i: integer;
begin
result:= EmptyStr;
for i := Length(FileName) downto 0 do
  begin
      if FileName[i] = '.' then
        begin
          result:= Copy(FileName, i + 1, length(FileName));
          break;
        end;
  end;
end;

function ExtractFilePathW(const FileName: string): string;
var
i: integer;
begin
result:= EmptyStr;
  for I := Length(FileName) downto 0  do
    begin
      if FileName[i] = '\' then
        begin
          result:= Copy(FileName, 0, i);
          Break;
        end;
    end;

end;

Un ejemplo de llamada:

Código Delphi [-]
   showmessage(ExtractFilePathW(paramstr(0)));
   showmessage(ExtractFileExtW(paramstr(0)));
   showmessage(ExtractFileNameW(paramstr(0)));

Salu2
Responder Con Cita