CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: API question :)

  1. #1
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    API question :)

    Hi, recently ive been trying to find out the differences between the windows api (the dll files) and the windows.h header file, i found that the windows.h file contains the declarations and the dll files contain the definitions.

    Could you explain to me why this is done in two different files, why not just have the definition and declaration in one file, wouldnt it be less hassle?

  2. #2
    Join Date
    Mar 2010
    Location
    Melbourne Australia
    Posts
    454

    Re: API question :)

    they could then Microsoft would have to reveal the source code , which they do not want to do think of it as driving a car , you interact with it , via steering , brakes , gears however common people have no idea what is going on inside , same with API , headers files allow you to use given set of libraries without knowing anything about them ,

    It helps developers in what the want to do rather than how they will do it. Perfect example is DirectX or OpenGL , developers want to devepol games they are not interested in how it interacts with underlying video cards.

  3. #3
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    Re: API question :)

    Thanks for the reply

    Ive also been trying to find out what actually is the Windows API, is it the windows.h file or the dll files, or a compilation of both which form it?

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: API question :)

    API

    Viggy

  5. #5
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    Re: API question :)

    Already seen that

  6. #6
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: API question :)

    You have to distinguish between (Windows) API and (Windows) SDK.

    By short:
    • Windows API (application programming interface) is the set of functions exposed by Windows system libraries (kernel32.dll, user32.dll, etc). API allows other applications to interact with the Windows system.
    • Windows SDK (software development kit) contains source header files, static libraries, tools, documentation. SDK helps developers to write applications which are using Windows API to interact with the Windows system.


    Windows.h is a source header file shipped with Windows SDK.
    Last edited by ovidiucucu; June 8th, 2011 at 03:58 AM.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  7. #7
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    Re: API question :)

    Ok, so the dll files form the windows api, and the windows.h file is a part of the windows sdk.

    Is the windows sdk automatically provided for us by the IDE when we choose to create a windows application?

  8. #8
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: API question :)

    Quote Originally Posted by TpOreilly View Post
    Is the windows sdk automatically provided for us by the IDE when we choose to create a windows application?
    It depends on the IDE.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  9. #9
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    Re: API question :)

    Ok, im guessing mine does, I use MS Visual Studio.

  10. #10
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    Re: API question :)

    Quote Originally Posted by aamir121a View Post
    they could then Microsoft would have to reveal the source code , which they do not want to do think of it as driving a car , you interact with it , via steering , brakes , gears however common people have no idea what is going on inside , same with API , headers files allow you to use given set of libraries without knowing anything about them ,

    It helps developers in what the want to do rather than how they will do it. Perfect example is DirectX or OpenGL , developers want to devepol games they are not interested in how it interacts with underlying video cards.
    Carrying on from this, couldnt they have both the declarations and the definitions in the dll files?

  11. #11
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: API question :)

    declarations and the definitions in the dll files.
    If declarations is in dll files how do you know the function names ?.
    dll files are just like compiled source file, the form is .dll instead of .cpp

    First you need to understand why dll files are being written and also find out the answer of function declaration and definition.
    ◄◄ hypheni ►►

  12. #12
    Join Date
    Feb 2002
    Posts
    4,640

    Re: API question :)

    Quote Originally Posted by hypheni View Post
    If declarations is in dll files how do you know the function names ?.
    dll files are just like compiled source file, the form is .dll instead of .cpp

    First you need to understand why dll files are being written and also find out the answer of function declaration and definition.
    I would compare a DLL with an EXE (or LIB), not a CPP file. A DLL is compiled code, all ready to run.

    Viggy

  13. #13
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: API question :)

    yes you are right Viggy. dll is compiled code ready to run by an exe.

    by calling the function names from exe a dll can execute its task, may be missed some term to explain OP exactly.
    ◄◄ hypheni ►►

  14. #14
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    Re: API question :)

    Ok so to summarise and closeee this thread:

    The windows.h file contains the declarations and the dll files contain the definitions of the functions within the windows API.

    They seperate the declarations from the definitions because they dont want people to know how the functions actually work.

    And the dll files are the windows api, and the windows.h file is a part of the windows sdk.

    Correct me if im wrong.

  15. #15
    Join Date
    Jun 2008
    Posts
    592

    Re: API question :)

    a dll is like an exe, but it is not a stand alone application and is meant to be loaded inside a process. It runs inside a thread attached to your process. It is to provide implementations dynamically vs statically. Instead of being compiled together, they link together during runtime. a dll is a format that the os uses to provide dynamic linking. I suggest you read http://en.wikipedia.org/wiki/Dynamic...on_and_binding.

    It is not to hide code. You don't need the c/c++ source, but only a compiled( assembly machine code ) version in a specific format that the os can use. This is why dlls are needed. It has to do with loading up dependencies at run-time or during exe loading.
    0100 0111 0110 1111 0110 0100 0010 0000 0110 1001 0111 0011 0010 0000 0110 0110 0110 1111 0111 0010
    0110 0101 0111 0110 0110 0101 0111 0010 0010 0001 0010 0001 0000 0000 0000 0000
    0000 0000 0000 0000

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured