* 라이브러리(OCX,DLL)를 등록해서 사용해야 할경우
* 설치프로그램 없이 프로그램을 실행하기 위한 코드
* 프로젝트 .dpr 에 삽입한다.

uses
   ComObj
begin
  Application.Initialize;
  WFileName := ExtractFilePath(Application.ExeName)+DLLNAME; //driver
  if FileExists(WFileName) then begin
    RegisterComServer(WFileName);
  end
  else begin
    Application.Terminate;
  emd;

  Application.Title := 'Image Clear'; 
  Application.CreateForm(TFmMain, FmMain);
  Application.Run;
end.

 간단히 만들어본 파일 크기 표시하는 함수 입니다.

Function FileSizeFormat(Size: Double):String;
const 
  sUnit: array[0..3] of string = ('KB', 'MB', 'GB', 'TB');
var 
  nUnit: ShortInt; 
  nDec : Integer; 
  nTmp: Double;
begin 
  nUnit := 0; 
  nTmp := Round( Size / 1024); 
  while (nTmp > 1024) do begin 
    nTmp := nTmp / 1024; 
    Inc(nUnit); 
  end; 
  nDec := Integer(Trunc((nTmp * 10) - Trunc(nTmp) * 10)  > 0); 
  Result := Format('%1.*n%s', [nDec,nTmp, sUnit[nUnit]]);
end;
사용법은 FileSizeFormat(파일크기) 입니다.
PS : 드라이브 사이즈 표시하는 데 사용하셔도 됩니다^^

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
© 2010 Namul's Blog Suffusion WordPress theme by Sayontan Sinha