I study WinApi, I encountered it in one book with this description:

Instead, it (the Windows application) accesses GDI functions, GDI translates these calls to the software drivers of physical devices, ensuring hardware application independence.

And then I had a question:

When compiling C ++ code using WinApi, we get assembler .obj files that are assembled (so? I'm not sure what is right). Is it possible to broadcast? Those. does the graphics device interface (GDI) (as I suppose the set of structures and functions) act as an analog of a Java machine, due to which translation into intermediate bytecode is possible?

  • the word "broadcast" has a different meaning here :) - Sublihim
  • The horses, the people mixed up in a heap ... "GDI translates these calls to the software drivers" has nothing to do with the compilation at all. And ".obj in assembly language" does not happen. - PinkTux
  • @PinkTux, as I correctly understood the .obj files contain binary, right? - Semyon Shelukhin
  • one
    @ Semen Shelukhin read here ru.wikipedia.org/wiki/… - Sublihim
  • @ Semyon Shelukhin, binary code is not an assembler at all - Sublihim

2 answers 2

There is no intermediate bytecode.
This refers to the "layered" structure of the operating system software. An application calls operating system functions — GDI functions that are in their DLLs, for example, and that are already accessing specific hardware. Again, through another layer - drivers.

Ie, for example, we have a standard operator

 fstream << "Hello, world"; 

It is inside the standard library refers to the functions of Windows, most likely to WriteFile . The corresponding code of this function in Kernel32.dll will already refer to specific drivers - having figured out where and on which media this file is - to USB drivers, disk or something else. Which is already at the hardware level will perform the recording.

Those. Your program does not need to know how to work with a device - there are other layers of software for this. And the program will work regardless of whether it runs on a machine with an SDD, a regular screw, or works with a network file at the other end of the world. In the program, there is only a function call in Kernel32.dll , and which is not nearly in the source text.

So more or less clear?

  • Thank. What I wanted. :-) - Semyon Shelukhin

In this phrase

Instead, it (the Windows application) accesses GDI functions, GDI translates these calls to the software drivers of physical devices, ensuring hardware application independence

the word "translates" is not used in the sense of broadcasting programs. This means that it delegates specific work to fulfill the request to the drivers of physical devices. That is, an intermediate layer is introduced in the form of the Windows API, which is an intermediate interface between the application program and physical devices with their drivers. This allows the application to not know the details of what is happening on the physical level. These details are hidden in the Windows API, which provides a common interface for applications.