What is an API? What is the windows API, and how will learning how to use the windows API help me write better programs?
API is short for "Application Programming Interface" - it's essentially a set of libraries that are designed to be the building blocks for your applications. They give your program (likely written in C) access to various system resources such as the file system, memory, etc. Specifically, the Win32 API exposes access to some core functionality in the Windows Operating System above and beyond what is included in the standard C libraries. Learning the Windows API would allow you to write programs that take advantage of those additional features.
so if I #include <windows.h>, I will be able to do fancy things with the default Windows GUI?
Perhaps. I think there are actually several different headers for different parts of the OS. I've never done much with Win32 so you'll need to find a reference online. (Probably on MSDN.)
This is what my windows.h looks like:\[/* windows.h - main header file for the Win32 API Written by Anders Norlander <anorland@hem2.passagen.se> This file is part of a free library for the Win32 API. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef _WINDOWS_H #define _WINDOWS_H #if __GNUC__ >=3 #pragma GCC system_header #endif /* translate GCC target defines to MS equivalents. Keep this synchronized with winnt.h. */ #if defined(__i686__) && !defined(_M_IX86) #define _M_IX86 600 #elif defined(__i586__) && !defined(_M_IX86) #define _M_IX86 500 #elif defined(__i486__) && !defined(_M_IX86) #define _M_IX86 400 #elif defined(__i386__) && !defined(_M_IX86) #define _M_IX86 300 #endif #if defined(_M_IX86) && !defined(_X86_) #define _X86_ #elif defined(_M_ALPHA) && !defined(_ALPHA_) #define _ALPHA_ #elif defined(_M_PPC) && !defined(_PPC_) #define _PPC_ #elif defined(_M_MRX000) && !defined(_MIPS_) #define _MIPS_ #elif defined(_M_M68K) && !defined(_68K_) #define _68K_ #endif #ifdef RC_INVOKED /* winresrc.h includes the necessary headers */ #include <winresrc.h> #else #include <stdarg.h> #include <windef.h> #include <wincon.h> #include <winbase.h> #if !(defined NOGDI || defined _WINGDI_H) #include <wingdi.h> #endif #ifndef _WINUSER_H #include <winuser.h> #endif #ifndef _WINNLS_H #include <winnls.h> #endif #ifndef _WINVER_H #include <winver.h> #endif #ifndef _WINNETWK_H #include <winnetwk.h> #endif #ifndef _WINREG_H #include <winreg.h> #endif #ifndef _WINSVC_H #include <winsvc.h> #endif #ifndef WIN32_LEAN_AND_MEAN #include <cderr.h> #include <dde.h> #include <ddeml.h> #include <dlgs.h> #include <imm.h> #include <lzexpand.h> #include <mmsystem.h> #include <nb30.h> #include <rpc.h> #include <shellapi.h> #include <winperf.h> #ifndef NOGDI #include <commdlg.h> #include <winspool.h> #endif #if defined(Win32_Winsock) #warning "The Win32_Winsock macro name is deprecated.\ Please use __USE_W32_SOCKETS instead" #ifndef __USE_W32_SOCKETS #define __USE_W32_SOCKETS #endif #endif #if defined(__USE_W32_SOCKETS) || !(defined(__CYGWIN__) || defined(__MSYS__) || defined(_UWIN)) #if (_WIN32_WINNT >= 0x0400) #include <winsock2.h> /* * MS likes to include mswsock.h here as well, * but that can cause undefined symbols if * winsock2.h is included before windows.h */ #else #include <winsock.h> #endif /* (_WIN32_WINNT >= 0x0400) */ #endif #ifndef NOGDI /* In older versions we disallowed COM declarations in __OBJC__ because of conflicts with @interface directive. Define _OBJC_NO_COM to keep this behaviour. */ #if !defined (_OBJC_NO_COM) #if (__GNUC__ >= 3) || defined (__WATCOMC__) #include <ole2.h> #endif #endif /* _OBJC_NO_COM */ #endif #endif /* WIN32_LEAN_AND_MEAN */ #endif /* RC_INVOKED */ #ifdef __OBJC__ /* FIXME: Not undefining BOOL here causes all BOOLs to be WINBOOL (int), but undefining it causes trouble as well if a file is included after windows.h */ #undef BOOL #endif #endif \] It's all just preprocessor directives :( how am I supposed to build powerful windows apps like that :( no documentation
Yeah, well, there's a reason I didn't last long as a Windows programmer. Linux had better documentation. And that's saying a lot, because on the whole, Linux documentation is pretty abysmal much of the time.
http://msdn.microsoft.com/en-us/library/ms123401.aspx which one should I go to?
http://msdn.microsoft.com/en-us/library/ee663300.aspx there we go; Windows client.
So if I want to create games and GUI applications on the Windows platform, I use the Windows API, whereas if I want to be able to also port it to other platforms like the Mac OSX or the Linux family, I could use something like Qt or wxWidgets (or Swing on Java)?
:( GUI programming seems a little more complicated than writing simple console applications; all those NULL arguments and weird names like lParam, wParam, lpszClassName, etc.
An application programming interface (API) is a source code based specification intended to be used as an interface by software components to communicate with each other. An API may include specifications for routines, data structures, object classes, and variables. An API specification can take many forms, including an International Standard such as Posix or vendor documentation such as the Microsoft Windows API, or the libraries of a programming language, e.g. Standard Template Library in C++ or Java API. An API differs from an ABI (Application Binary Interface) in that the former is source code based while the latter is a binary interface. For instance POSIX is an API, while the Linux Standard Base is an ABI).[1]
java libraries are called API too
Join our real-time social learning platform and learn together with your friends!