简体   繁体   中英

Question about Windows API

I have a code which is running on DOS Box in windows 7...However my question is whether my code is using the Windoows API or not? Below are the headers file which I am using...

#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<process.h>

Why don't you take a look at that code? If there are any Windows specific APIs being used, it won't be too hard to find them by looking at included header files.

DOSBox can run Windows 3.1 and associated programs, but if your program runs outside of Windows 3.1, then you can be pretty sure that no Windows APIs are being used.

These headers are not part of the Windows API, and in fact, it's unlikely that your code will compile at all using a compiler other than Borland Turbo C/C++.

It looks like you're using mostly proprietary Borland libraries. For example, graphics.h allows you to draw graphics in a text-based MS-DOS environment. It's not supported under Windows at all.

Even the header files like conio.h that you'll probably find in other compilers may not be compatible with the one you're using in your code. The library functions declared by conio.h vary somewhat from one compiler to another.

As a general rule, every program that uses the Windows API will include windows.h , and perhaps some additional child header files, depending on the specific functionality needed.

Most of the information you have received so far is too general. The headers that are included dont show you everything.

1) the compiler used will include headers behind-the-scenes

2) the librarys linked are only loosly coupled to the headers that you specified

Example:

  • if you use MinGW and include no headers explicitly it will link to stdlib.h behind the scenes and this will be linked to the Windows API without you ever knowing it.

  • if you then call malloc() it will be translated to HeapAlloc (Windows API) by the mingw-Headers and obviously linked to the Windows API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM