Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

delphi--->C++ Builder pomoc oko "prevodjenja"

[es] :: C/C++ programiranje :: delphi--->C++ Builder pomoc oko "prevodjenja"

[ Pregleda: 1380 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

ik0
Ivan Cekov
Information System Developer
Planning Authority Malta
Floriana, Malta

Član broj: 222385
Poruke: 158
92.55.109.*



+3 Profil

icon delphi--->C++ Builder pomoc oko "prevodjenja"01.10.2010. u 09:47 - pre 164 meseci
ove funkcije napisane u delphiju nemogu nikako da napisem u c++...evo kodo a pod njega i mog koda (ono sto sam uspeo da napisem)

Code:

function GetParentDirectory(path : string) : string;
begin
  result := ExpandFileName(path + '..')
end;

function AddFilter(path,filter: string): string;
begin
  if length(path) > 0 then
  begin
    if path[length(path)] = '' then
      result := path + filter
    else
      result := path + '' + filter;
  end
  else
   result := filter;

end;


type
  TFileInfo = record
    Icon : hIcon;
    Image : Integer;
    DisplayName : String;
    TypeName : String;
    Size : Integer;
    SizeDescription : String;
    DateTime : TDateTime;
    AttrArchive : Boolean;
    AttrReadOnly : Boolean;
    AttrSystem : Boolean;
    AttrHidden : Boolean;
    AttrVolume : Boolean;
    AttrDirectory : Boolean;
  end;

// ----------------------------------------------------------------
// Return string with formatted file size (bytes, Kb, Mb or Gb)
// ----------------------------------------------------------------
function scGetSizeDescription(const IntSize : Int64) : String;
begin
  if IntSize < 1024 then
    Result := IntToStr(IntSize)+' bytes'
  else
  begin
    if IntSize < (1024 * 1024) then
      Result := FormatFloat('####0.##',IntSize / 1024)+' Kb'
    else
      if IntSize < (1024 * 1024 * 1024) then
        Result := FormatFloat('####0.##',IntSize / 1024 / 1024)+' Mb'
      else
        Result := FormatFloat('####0.##',IntSize / 1024 / 1024 / 1024)+' Gb';
  end;
end;

// ----------------------------------------------------------------
// Return record with all information about given file
// How to use icon : ImageFile.Picture.Icon.Handle:=Info.Icon;
// ----------------------------------------------------------------
procedure scGetFileInfo(StrPath : String; var Info : TFileInfo);
var
  SHFileInfo : TSHFileInfo;
  SearchRec : TSearchRec;
begin
  if Trim(StrPath) = '' then
    Exit;

  ShGetFileInfo(PChar(StrPath), 0, SHFileInfo, SizeOf (TSHFileInfo),
    SHGFI_TYPENAME or SHGFI_DISPLAYNAME or SHGFI_SYSICONINDEX or SHGFI_LARGEICON or SHGFI_ICON);

  with Info do
  begin
    Icon  := SHFileInfo.hIcon;
    Image := SHFileInfo.iIcon;
    DisplayName := SHFileInfo.szDisplayName;
    TypeName := SHFileInfo.szTypeName;
  end;

  FindFirst(StrPath, 0, SearchRec);
  with Info do
  begin
    try
      DateTime := FileDateToDateTime(SearchRec.Time);
    except
      DateTime := Now();
    end;

    {$WARNINGS OFF}
    AttrReadOnly := ((SearchRec.Attr and faReadOnly) > 0);
    AttrSystem := ((SearchRec.Attr and faSysFile) > 0);
    AttrHidden := ((SearchRec.Attr and faHidden) > 0);
    AttrArchive := ((SearchRec.Attr and faArchive) > 0);
    AttrVolume := ((SearchRec.Attr and faVolumeID) > 0);
    AttrDirectory := ((SearchRec.Attr and faDirectory) > 0);
    {$WARNINGS ON}
    Size := SearchRec.Size;

    SizeDescription := scGetSizeDescription(Size);
  end;
end;


Kude tumbe i tri bandere
 
Odgovor na temu

ik0
Ivan Cekov
Information System Developer
Planning Authority Malta
Floriana, Malta

Član broj: 222385
Poruke: 158
92.55.109.*



+3 Profil

icon Re: delphi--->C++ Builder pomoc oko "prevodjenja"01.10.2010. u 10:13 - pre 164 meseci
ovo sam nesta kuco ama i tu javlja greske...

Code:

AnsiString GetParentDirectory(AnsiString path)
{
return ExpandFileName(path + '..');
}

AnsiString AddFilter(path, AnsiString filter)  //e sad ova funkcija mi nesta nije dobro deklarirana??
{
if(Lenght(path) >0)
  if(path[Lenght(path)]=="")
return path+filter;
else
return path + ""+filter;
else
return filter;

//to type ne znam sta bi biilo 
type
 TFileInfo = record //ovaprva dva ne znam kako bi bili u c++
  Icon : hIcon;
  int Image;
  AnsiString DispleyName, TypeName;
  int Size;
  AnsiString SizeDescription;
  TDateTime DateTimel
  bool AttrArchive , AttrReadOnly , AttrSystem, AttrHidden, AttrVolume, AttrDirectory ;


AnsiString scGetSizeDescription (const int IntSize)
{
if(IntSize <1024)
return IntToStr(IntSize)+" bytes";
else
if(IntSize<(10214*1024)
return float("####0,##", IntSize /1024)+" Kb";
else
return float("####0,##:, IntSize/1024/ 1024 /1024)+" Gb";
}


Posle ovo nije mi bas najasnije kako i sta treba....Ako moze neko neka me ispravi gde sam gresio i ako moze neka sklopi taj zadnji deo koda....Hvalaaaaaa


Kude tumbe i tri bandere
 
Odgovor na temu

[es] :: C/C++ programiranje :: delphi--->C++ Builder pomoc oko "prevodjenja"

[ Pregleda: 1380 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.