Thread: Win API

  1. #1

    Win API

    Hy. I'm using Borland's C++ Builder 5. How can I acces the Windows API from this compiler? I would like to know a little more about API and their usage, so, can someone redirect me to a tutorial? Thanks.

  2. #2
    Join Date
    Jan 2002
    I don't know of any specific tutorials for doing win api stuff with bcb5 but I am familiar with simple stuff using the command line tools. I also played around with bcb4, which the following refers to (I originally posted it elsewhere):

    Builder is great for RAD of GUI apps but doesn't lend itself (IMO) very easily to win32 projects.

    It can be done, however, but I could not remove dependencies on the vcl (visual component library) as the borland IDE doesn't seem to permit hyperfine compiler & linker switch selection. I could be wrong of course as I often am.

    First off my advice would be to abandon the ide and use the cmd line tools via make as it will liberate you from the bloat imposed by the vcl.

    If you still want to use builder then:

    1. Create a new project. Remove the form and all units from it.
    2. Builder has a default project cpp file with the WinMain fn in it. Find this file and copy and paste some typical 'hello world' code in there.
    3. Amend the <#include windows.h> line to read <#include windows.hpp>. Alternatively you can replace that line with these two lines:
    #include <vcl.h>
    #pragma hdrstop
    which will accomplish more or less the same thing. In the latter case the build will take slightly longer and the exe will be larger.
    4. If you want a 'release' build then from the menu select project->options. A tabbed dialog box should appear. In the linker tab make sure that 'use dynamic rtl' is NOT checked, otherwise you will have to distribute borland run-time dll's with any apps you make. Also uncheck 'use debug libraries'. In the 'compiler' tab, click the 'release' button to set-up some std release compiler configuartions.
    5. Build the project.

    Note that there may be some differences in your bcb5 version, extra features etc that may help you improve on this. If not, it is almost definitely true that exes produced from wthin the IDE will be larger in size than any you create from the command line from makefiles.

    The information here is fairly general and may be adapted to most win32 examples you may find.

    Alternatively I think some of NeHe's tutorials have been adapted to use borland builder 4/5. A perusal of them may refine your techniques.

    Good luck with your experiments.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with this
    By tyrantil in forum C Programming
    Replies: 18
    Last Post: 01-30-2005, 04:53 PM
  2. win api literature
    By DMaxJ in forum Windows Programming
    Replies: 5
    Last Post: 04-30-2004, 03:25 PM
  3. Win API Links
    By GNick in forum Windows Programming
    Replies: 1
    Last Post: 04-05-2002, 08:12 AM
  4. Win API
    By Marky_Mark in forum Windows Programming
    Replies: 4
    Last Post: 10-23-2001, 12:57 PM
  5. Rich edit control example Win API
    By Echidna in forum Windows Programming
    Replies: 1
    Last Post: 09-17-2001, 02:12 AM