Why is WinAPI so different from “normal” C?

I wonder why WinAPI is very different from "normal" C programming?

I mean, at school, I learned that every C program has a main () function (WinAPI uses WinMain with some special parameters), some types of variables like int, long, char, etc. (WinAPI uses things like LPCSTR, BOOL, etc.), Why did Microsoft decide to go different with their OS API?

When I saw my first WinAPI program, I like the new language more for me ...;)

+5
source share
6 answers

The original Windows API was developed in 1984-85, over 25 years ago. Hungarian notation was a complete rage, so including a variable type in a declaration was a thing. For example, in pure C, there is no way to specify a "far" pointer, which indicates LP in LPCSTR, but in 1985 it was very important to distinguish between regular pointers and long pointers. (This value faded into the background when 32-bit windows occupied in the mid-90s, but the syntax is preserved ...)

In addition, C does not really distinguish between just a pointer to a char and a pointer to a static string. So the types are lpsz.

, , , C, 1984 . WinMain, , Windows . , , , main(), , WinMain (.. ).

+15

:

  • . C , , . LPCSTR, BOOL , Win32, typedefs structs, C.
  • . C , , . , , Windows ( ), , , .

API Win32, , , , .

+4

Microsoft Raymand Chen :

WinMain Platform SDK, . , WinMain Windows.

C , runtime, WinMain ( wWinMain, ).

+2

" -", .

WinMain() - , Windows. main().

(LPCSTR, BOOL ..), . , LPCSTR, const char *. BOOL typedef, C. , , , 16- 32- 64- .

. , , Win32/MFC.

+1

, - . Unix, , , , typedefs. , C Unix. , Windows LongFunctionNamesInMixedCase LOTSOFTYPEDEFS, *PTYPEDEFSFORPOINTERSTOO.

. , WinMain() , nCmdShow, ShowWindow(), , . , .

, , API- . Windows . CreateFile() , Unix, , , , .

+1

Windows API , C . , WinMain() , main() C.

While we are in this matter, C has few built-in types, and at that time there were several ways to specify them. Type windows (HWND, LPSTR, BOOL, etc.) Reflect the data types commonly used in window programming and try to tell the programmer what the data types will be.

Hungarian notation is a bit of a misuse of the source versions, as many variables have an unnecessary number of qualifiers.

0
source

All Articles