D
D
DollyPapper2017-06-11 03:58:36
C++ / C#
DollyPapper, 2017-06-11 03:58:36

Literature or resources on WinAPI?

Friends. After reading K&R, I decided to immediately try to look at WinAPI. I downloaded the book System Programming in the Windows Environment from Hart. Judging by the versions of Windows that he calls, he does not even mention XP. That is, the book is apparently ancient. not a drop. Even the first code from that book does not 73eee454a06c486eb1378d53b37c42d9.pngcompile, outputting a crazy number of warnings and errors

spoiler
C:\Users\folle\Documents\wapi\vax\winapi.c:8:8: error: conflicting types for 'hIn'
  DWORD hIn, hOut;
        ^
C:\Users\folle\Documents\wapi\vax\winapi.c:7:9: note: previous declaration of 'hIn' was here
  HANDLE hIn, hOut;
         ^
C:\Users\folle\Documents\wapi\vax\winapi.c:8:13: error: conflicting types for 'hOut'
  DWORD hIn, hOut;
             ^
C:\Users\folle\Documents\wapi\vax\winapi.c:7:14: note: previous declaration of 'hOut' was here
  HANDLE hIn, hOut;
              ^
C:\Users\folle\Documents\wapi\vax\winapi.c:15:7: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
   hIn = CreateFile(argv [1], GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
       ^
C:\Users\folle\Documents\wapi\vax\winapi.c:16:12: warning: comparison between pointer and integer
    if (hIn == INVALID_HANDLE_VALUE)
            ^
C:\Users\folle\Documents\wapi\vax\winapi.c:22:8: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
   hOut = CreateFile(argv[2], GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
        ^
C:\Users\folle\Documents\wapi\vax\winapi.c:23:12: warning: comparison between pointer and integer
   if (hOut == INVALID_HANDLE_VALUE)
            ^
C:\Users\folle\Documents\wapi\vax\winapi.c:28:20: warning: passing argument 1 of 'ReadFile' makes pointer from integer without a cast [-Wint-conversion]
    while (ReadFile(hIn, Buffer, BUF_SIZE, &hIn, NULL) && hIn > 0)
                    ^
In file included from c:\mingw\include\windows.h:44:0,
                 from C:\Users\folle\Documents\wapi\vax\winapi.c:1:
c:\mingw\include\winbase.h:2013:24: note: expected 'HANDLE {aka void *}' but argument is of type 'DWORD {aka long unsigned int}'
 WINBASEAPI BOOL WINAPI ReadFile(HANDLE,PVOID,DWORD,PDWORD,LPOVERLAPPED);
                        ^
C:\Users\folle\Documents\wapi\vax\winapi.c:30:14: warning: passing argument 1 of 'WriteFile' makes pointer from integer without a cast [-Wint-conversion]
    WriteFile(hOut, Buffer, hIn, &hOut, NULL);
              ^
In file included from c:\mingw\include\windows.h:44:0,
                 from C:\Users\folle\Documents\wapi\vax\winapi.c:1:
c:\mingw\include\winbase.h:2207:24: note: expected 'HANDLE {aka void *}' but argument is of type 'DWORD {aka long unsigned int}'
 WINBASEAPI BOOL WINAPI WriteFile(HANDLE,PCVOID,DWORD,PDWORD,LPOVERLAPPED);
                        ^
C:\Users\folle\Documents\wapi\vax\winapi.c:38:15: warning: passing argument 1 of 'CloseHandle' makes pointer from integer without a cast [-Wint-conversion]
   CloseHandle(hIn);
               ^
In file included from c:\mingw\include\windows.h:44:0,
                 from C:\Users\folle\Documents\wapi\vax\winapi.c:1:
c:\mingw\include\winbase.h:1328:24: note: expected 'HANDLE {aka void *}' but argument is of type 'DWORD {aka long unsigned int}'
 WINBASEAPI BOOL WINAPI CloseHandle(HANDLE);
                        ^
C:\Users\folle\Documents\wapi\vax\winapi.c:39:15: warning: passing argument 1 of 'CloseHandle' makes pointer from integer without a cast [-Wint-conversion]
   CloseHandle(hOut);
               ^
In file included from c:\mingw\include\windows.h:44:0,
                 from C:\Users\folle\Documents\wapi\vax\winapi.c:1:
c:\mingw\include\winbase.h:1328:24: note: expected 'HANDLE {aka void *}' but argument is of type 'DWORD {aka long unsigned int}'
 WINBASEAPI BOOL WINAPI CloseHandle(HANDLE);
                        ^
etc.
Tell me, in fact, what to read to get into the topic of wapi programming, and in general, what else to read for a beginner. How, for example, to write DLLs in general, how to use them later, how do people know this, but K & R do not say anything about it. Another good lit-ry was not found by me. In general, help the lamer, put him on the right path.
UPD: Eclipse CDT development environment + MinGW compiler

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaroslav Pronin, 2017-06-15
@DollyPapper

From the literature - Richter, Petzold, from the reference book - MSDN. Again, the literature needs to be read only in order to understand the basics of WinAPI, much of the same Petzold is outdated, but work with the GUI is widely described there. Richter is already more advanced stuff API level kernel.

A
Axian Ltd., 2017-06-11
@AxianLTD

MSDN is the only and accurate source for information about Windows and other MS products

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question