Q&A

  • 실행파일 용량 줄일수 없나요??
델파이로 컴파일하면 만들어지는 exe 파일 용량이 너무 크네요..-_-;;

보통 인터넷 공개자료실에 돌아다니는 프로그램 보다 더 단순한 프로그램인데도 용량이 큰 이유가 뭐죠??

간단한 덧셈 뻴셈.. IF 문 정도가 고작인데--;

델파이로 만들면 기본 300-400Kb 의 용량이 되네요..

델파이로 만들면 용량을 작게 해서 프로그램을 만들수는 없는 건가요??
(런타임 없이 1개의 exe로 실행된다는것은 좋은데.. 용량이-_-;;)

예를들어 smisync 같은 프로그램은 용량이 28.0Kb   28,675 Byte 밖에 안되는데...

비주얼베이직 의 경우는 별도로 런타임 구성요소가 있어야 되니까...
(런타임 요소가 2Mb 정도 되더군요-_-;;)

smisync 뒤에 등록정보 보니깐 MFC 응용프로그램 이라 되어있네요..-_-;;
이건 C++ 로 만들어 졌다는 건지--;
근데 C++ 은 어떻게 런타임 요소도 없이 용량도 작으면서 exe 만으로 실행이 되나요?
3  COMMENTS
  • Profile
    머슴 2002.06.10 23:20

    델파이 실행프로그램이 그리 크지가 않습니다..(제가 느끼기에는)

    혹시 다른 원인이 있지 않을까 생각 됩니다...

    제가 코딩을 하면서 실행화일의 크기에 대해서 느낀 부분을
    몇자 적습니다..


    1. 이미지

        이미지를 포함하게 되면 이미지사이즈까지 포함되어  

       프로그램사이즈가 커지게 됩니다..

       따라서 이미지는 그냥 화일상태로 둔 상태에서 화일을
      
       실행시 호출하는 방식으로 바꾸면 사이즈가 줄어 듭니다.

       아니면 리소스 화일로 만들어서 사용하는 방법도 있습니다.

    2.Bulid with runtime  Packages 체크

        project Option중에 Packages탭에서  Bulid with runtime  Packages 를

       체크후  컴파일하게 되면 실행화일에서 컴퍼넌트 코드 부분이

       빠지게 되므로 실행화일의 크기가 작아집니다..
  • Profile
    티모니 2002.06.10 21:25
    Use CASE.. statments rather than IF..ELSE.. clauses.
                             In every .PAS-file that will be linked in your project, place the following line to the top of your code:

                                     {$D-,L-,O+,Q-,R-,Y-,S-}
                                    

                             Also add this line to your project source (.DPR).
                             {$D-} will prevent placing Debug info to your code.
                             {$L-} will prevent placing local symbols to your code.
                             {$O+} will optimize your code, remove unnecessary variables etc.
                             {$Q-} removes code for Integer overflow-checking.
                             {$R-} removes code for range checking of strings, arrays etc.
                             {$S-} removes code for stack-checking. USE ONLY AFTER HEAVY TESTING !
                             {$Y-} will prevent placing smybol information to your code.
                             After doing this, recompile the whole project - your .EXE-size should magically have been reduced by
                             10-20 %..
                             If you link in graphics, they don't need to have more than 16 or 256 colors.
                             If the goal is really and only .EXE size, load your graphics by code ("manually") instead of embedding
                             them already during design time in each and every form which uses them. A detailled description of this tip
                             can be found on this page after clicking here.
                             If you include resource-files, they should only content the resources you really need - and nothing more.
                             If you use Delphi 1, finally run W8LOSS.EXE on your .EXE file (not required for 32bit-Apps).
                             Delphi 2 produces larger .EXE sizes than Delphi 1 - 32 bit code demands its tribute..
                             Delphi 3 produces larger .EXE sizes than Delphi 2 - main reason: market pressure leads to more
                             "fundamental" support of "bells and whistles" - quality and usefulness/efficiency/productivity doesn't seem
                             to be a real criteria in M$-times...
                             Delphi 4 produces larger .EXE sizes than Delphi 3 - main reason: market pressure leads to more
                             "fundamental" support of "bells and whistles" - (..to be continued like above)
                             check the "Show Hints" and "Show Warnings" options on the Project|Options|Compiler page, then rebuild
                             your project. It will show you every variable and proc/func that isn't being used. You might be able to trim
                             a little there, too.
                             Clean your USES.. clauses for all unneeded units!
                             The so-called "SmartLinking" doesn't always remove all unused code. In a large project you could
                             possibly spare 100k in the EXE by that.
                             Place Bitmaps/Glyphs/etc. in DLL's instead of in *.RES/*.DCR files !
                             If you place fx some large bitmaps in a .RES, these will compiled into the EXE. Remove the
                             .RES-declarations, instead place them in a new project like this:

                                 LIBRARY My_Extern_RESes;
                                     USES EmptyUnit;
                                 {$R MyRes1.RES}
                                 {$R MyRes2.RES}
                                 ...
                                 INITIALIZATION
                                 END.
                                    

                             The unit AEmptyUnit is a completely empty unit. You have to use a unit like this because any other unit will
                             place unnecessary code in the final DLL. When you want to use an image (and typically, you only want to
                             load it once), you can do it like this :

                                 MyHandle := LoadLibrary('My_Extern_RESes.DLL');
                                 TButton1.Glyph.Handle := LoadBitmap(MyHandle,'My_Glyph');
                                    

                             Placing Glyphs, Bitmaps, String-const's etc. in DLL's can really reduce a projects EXE-size. (Tip came from
                             David Konrad)
                             Basis rule: the more forms and units you add, the larger your exe becomes. When you had one huge form,
                             you only had one form class - even when you had 500+ things on it! This creates only one runtime type
                             information for that class. Now, when you split this into 17 units, each class in that unit requires its own
                             RTTI. Now, this runtime information can get large, collectively, with a lot of redundant information
                             compared to when you only had one huge class. Also, if each of the 17 units had its own form, your end
                             product must contain resource information for all 17 of those forms even though most of that information
                             may be redundant. One reason why this happens is because the Delphi compiler doesn't optimize
                             resources - but I don't know of any compiler that does. So, if you had two separate forms which are
                             identical in look, you'll have 2 copies of the resource in your .EXE.
                             This leaves some work for the programmer to be creative in maximizing resource reuseability. (Tip came from
                             Young Chung)
                             Delphi 3 and 4 allows you to use packages (runtime libraries) which can be easily enabled in your Project
                             options. Especially if you have to update your application often, this could be interesting for you: the
                             runtime libraries just have to be deployed once (there is even a chance that important Delphi packages like
                             vcl30.dpl or vcl40.bpl already exist on your user's computer) and to update your (then shrinked) executable
                             whenever an update is required (please consult the helpfile for further details).
                             If your EXE file has to be super-small and you can go without Delphi's powerful IDE and design features,
                             you can also program without including the VCL (visual component library) in your USES clause. Here is a
                             small EXE program which compiles to about 30 kb (by Frank Peelo):

                             Program HelloWin;
                             { Standard Windows API application written in Object Pascal. }
                             Uses
                               Windows,
                               messages,
                               MMSystem;
                             Const
                               AppName : pChar = 'HelloWin';

                             Function WindowProc(Window:HWnd; AMessage, WParam, LParam:LongInt):
                                     LongInt; StdCall; Export;
                             { The message handler for the new window }
                             Var
                               h : hdc;
                               ps: tPaintStruct;
                               r : tRect;
                             Begin
                               Result := 0;
                               Case AMessage of
                               WM_Create:Begin
                                                     PlaySound('C:WINDOWSMEDIAMusica Windows Start.wav', 0,
                                                     Snd_FileName or Snd_Async);
                                                     Exit;
                                                     End;
                               WM_Paint: Begin
                                                     h := BeginPaint(Window, Ps);
                                                     GetClientRect(Window, r);
                                                     DrawText(h, 'Hello Winblows!', -1, r,
                                                     DT_SingleLine or DT_Center or DT_VCenter);
                                                     EndPaint(Window, ps);
                                                     Exit;
                                                     End;
                               WM_Destroy:Begin
                                                     PostQuitMessage(0);
                                                     Exit;
                                                     End;
                               End;
                               Result := DefWindowProc(Window, AMessage, WParam, LParam);
                             End;
                             { Register the window class }
                             Function WinRegister:Boolean;
                             Var
                               WindowClass: TWndClass;
                             Begin
                               WindowClass.Style := cs_HRedraw or cs_VRedraw;
                               WindowClass.lpfnWndProc := @WindowProc;
                               WindowClass.cbClsExtra := 0;
                               WindowClass.cbWndExtra := 0;
                               WindowClass.hInstance := HInstance;
                               WindowClass.hIcon := LoadIcon(0, idi_Application);
                               WindowClass.hCursor := LoadCursor(0, idc_Arrow);
                               WindowClass.hbrBackground := HBrush(GetStockObject(White_Brush));
                               WindowClass.lpszMenuName := NIL;
                               WindowClass.lpszClassName := AppName;
                               Result := RegisterClass(WindowClass)<>0;
                             End;

                             Function WinCreate:HWnd;
                             Var
                               HWindow:HWnd;
                             Begin
                               hWindow := CreateWindow(AppName,
                                                       'The Hello Program',
                                                       WS_OverlappedWindow,
                                                       CW_UseDefault,CW_UseDefault,
                                                       CW_UseDefault,CW_UseDefault,
                                                       0,0,HInstance,NIL);
                               If hWindow<>0 then Begin
                                 ShowWindow(hWindow, CmdShow);
                                 UpdateWindow(hWindow);
                               End;
                               Result := hWindow;
                             End;
                             { Main: Set up window, then give it messages until done.}
                             Var
                               AMessage: TMsg;
                               hWindow: HWnd;
                             Begin
                               If not WinRegister then Begin
                                 MessageBox(0, 'Register Failed', NIL, mb_Ok);
                                 Exit;
                               End;
                               hWindow := WinCreate;
                               If hWindow=0 then begin
                                 MessageBox(0, 'Register Failed', NIL, mb_Ok);
                                 Exit;
                               End;
                               While GetMessage(AMessage, 0, 0, 0) do begin
                                 TranslateMessage(AMessage);
                                 DispatchMessage(AMessage);
                               End;
                               Halt(AMessage.WParam);
                             End.

                             There also exists a VCL replacement project named XCL linked from my "Delphi Tools" page which could
                             be of help here, too.
                             If your main goal is distributable size, you could also consider
                                  using EXE/DLL packers like Blinker, ASPack, NeoLite etc. for program compression
                                  or, even better: use alternative setup programs like our award-winning INF-Tool to create your
                                  distribution package. INF-Tool creates today's smallest setup packages available! Since users
                                  usually prefer to download smaller programs from the Internet (rather than to 'control' the installed
                                  program size after setup), you can focus on functionality and features instead of having to think
                                  about where to save a few code lines or if using a helpful VCL component "really pays".
                             (links to all mentioned programs can be found on my Delphi Tools page.)

  • Profile
    티모니 2002.06.10 21:12
    우선은 프로그램을 만드실때여.. 필요 없는건 uses 에서 빼주시구여...

    프로그램을 기능들을 dll로 따로 만들어서 관리 하시는 방법이 있구여

    그리고 마지막으로 upx같은걸루 실행파일을 압축하는 방법이 있습니당

    그럼 이만. 휘릭..

    코리아팀 퐈이링~~~~


    • 박송휘
    • 2002.06.10 18:46
    • 3 COMMENTS
    • /
    • 0 LIKES
    • 김수경
      2002.06.10 18:56
      OnClick Event와 연결된 Button1Click를 직접 불러 주시면 됩니다. 즐거운 하루 되세요!
    • 박송휘
      2002.06.11 05:23
      .......................
    • 최용일
      2002.06.12 12:36
      안녕하세요. 최용일입니다. 다른 프로그램도 가능합니다. 님이하신 코딩에서 Button13.Handle대신에 ...
    • 구현민
    • 2002.06.10 18:15
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 최석기
      2002.06.10 19:35
      퀵레포트 버그입니다.. 예전에 Usesnet 뒤지다가 그 버그 수정한 콤포넌트를 찾았었는데 이름이 기억이 ...
    • 김태훈
    • 2002.06.10 12:00
    • 7 COMMENTS
    • /
    • 0 LIKES
    • 김수경
      2002.06.10 19:02
      여러가지 방법이 있지만 제가 추천하는 방법은 Samples Tab에 있는 CSpinEdit1 Component를 사용하는 겁니...
    • 김태훈
      2002.06.11 11:12
      저는 이걸 함수로 만들려고 하거든요. 100이하만 입력할수 있고 아예 100이상은 사용자가 입력못하게요....
    • 성더기
      2002.06.11 19:49
      function MaxHund(Value : integer):boolean; begin   if (Value >= 1) and (Value <= 1...
    • 머슴
      2002.06.10 19:00
      먼저 에디트박스속성중에 MaxLength를 3으로 해주시고요.. KeyPress이벤트에서 숫자만 입력되도록 ...
    • 김태훈
      2002.06.11 11:08
      숫자만 입력되게는 했어요. 전 100이하의 숫자만 입력가능하게 하고 싶거든요. 100이상이면 메시지를 보...
    • 김도형
      2002.06.10 18:56
      숫자만 입력하게 했으믄 쉬운거 같은데염...   case strtoint(Edit2.text) of   ...
    • 김태훈
      2002.06.11 11:10
      100이상이면 메시지나 기타처리를 하는게 아니라 아예 100이상의 숫자를 사용자가 입력 못하게 하고 싶거...
    • 정경주
    • 2002.06.10 09:19
    • 1 COMMENTS
    • /
    • 0 LIKES
    • ☆영민★
      2002.06.10 10:19
      저도 아는게 별루 없지만.. 혹시.. chr(13) 으로 하면 되지 않을까요?? 엔터(Enter / Return)키 값이 1...
    • 머슴
      2002.06.10 23:20
      델파이 실행프로그램이 그리 크지가 않습니다..(제가 느끼기에는) 혹시 다른 원인이 있지 않을까 생...
    • 티모니
      2002.06.10 21:25
      Use CASE.. statments rather than IF..ELSE.. clauses.        &nb...
    • 티모니
      2002.06.10 21:12
      우선은 프로그램을 만드실때여.. 필요 없는건 uses 에서 빼주시구여... 프로그램을 기능들을 dll로 따로...
    • 장명선
      2002.06.10 01:53
      Write 를 쓰세요... 이것은 길이만큼 보내는 명령입니다. 프로퍼티를 참조하세요 예) ComPort.Wri...
    • 나그네
      2002.06.10 03:54
      고맙습니다. 답변해주셔서.. 근데요. ComPort.Write('ABCD', 4); 이거랑여 ComPort.WriteStr('ABCD'); ...
    • 장명선
      2002.06.10 05:35
      문자형 전송에서 Null값이 나오면 Null값에서 중단이 됩니다. 그래서 특정 길이만큼을 전송하라고 명령을 ...
    • 이동준
    • 2002.06.09 11:45
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 장명선
      2002.06.10 01:51
      BDE->Configuration->Drivers->Native DLL32 -> SQLORA8.DLL VENDOR INIT -> OCI.DLL ...
    • 장명선
    • 2002.06.09 09:25
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 신석기
      2002.07.23 10:04
      버젼과 관계가 있습니다. 설치된 ocx보다 버젼이 높다면 해당 경로에서 다운 받아 설치합니다. 옵션에서 ...
    • 김장훈
    • 2002.06.09 07:49
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 깨구락지
      2002.06.09 08:29
      myStr:=StringReplace(trim(tStr),' ','',[rfReplaceAll]) 공백은 무조건 제거합니다.
    • 김정용
      2008.07.31 00:51
      깨구락지 님 감사합니다.
    • 오현주
    • 2002.06.09 06:24
    • 2 COMMENTS
    • /
    • 0 LIKES
    • KDDG_zzang
      2002.06.09 08:12
      여기 가면 자세한 정보를 얻으실 수 있습니다. www.oracleclub.com 상단 메뉴에 보면 oracle > orac...
    • 오현주
      2002.06.09 23:54
      답변은 고맙습니다.. 그런데 저는 dataset의 query로 이용해서 데이터베이스에 접근을 해서 커서를 이동...
    • 이소진
    • 2002.06.09 04:17
    • 0 COMMENTS
    • /
    • 0 LIKES
    • 미소나눔
      2002.06.09 05:01
      직접 컴포넌트로 만드셔야 합니다. 아래처럼 새로운 Unit에 코딩하시구.. TNewEdit = class(TEdit) .... ...
    • 박종민
      2002.06.10 16:27
      델파이 잘 못하는 애들한테 왜 이런걸 내주는지 답변은 잘 봤는데 포기입니다... ㅡ.ㅡ
    • 깨구락지
      2002.06.11 20:30
      컴포넌트 만들기가 어려우시면 만드러진 컴포넌트를 사용하십시오. 자료실에 CurrencyEdit 컴포넌트를 이...
    • 이재식
      2002.06.09 04:20
      var    HexiDecimal : String ; -----------------------------------    &...
    • 이승근
    • 2002.06.09 01:24
    • 1 COMMENTS
    • /
    • 0 LIKES
    • KDDG_ZZOM
      2002.06.09 02:04
      정확한지는 모르지만... 파라독스에서 인라이뷰가 되는지 잘모르겠네요...
    • 권광일
      2002.06.15 02:01
      DirectX 의 기능중에 DES 기능이 있습니다. 그중에 TimeLine 이라는 것이 있는데, 그 조작을 XML 로도 ...
    • 이동현
    • 2002.06.09 00:23
    • 1 COMMENTS
    • /
    • 0 LIKES
    • KDDG_zzang
      2002.06.09 00:49
      1. DataSet.RecordCount 로 체크하시던가 2. SELECT COUNT(1) FROM 출석부 WHERE 이름 = '테스트' 여...
    • 송재진
    • 2002.06.09 00:17
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 이재식
      2002.06.09 04:26
      님께서 질문하신 내용은 그리 어렵지 않게 델파에서 주는 트리뷰 컴포넌트로 할수 있습니다. 특정 노드에...