FILE
is a type of the standard C library, used exclusively for file handling with the stdio.h functions. It cannot be used for anything else. The C standard lib has the advantage of being portable.
HANDLE
is a similar but wider concept used by the Windows API, used for everything where they want an abstraction layer on top of raw pointers. It is used for files, ports, threads, mutex, events, pipes and so on. Generally: any Windows resource that you can WaitForSingleObject
on - the WaitFor...
functions being Window's way of letting a thread effectively sleep without using up CPU resources. See What is a Windows Handle?. It only works for Windows API specific-functions like CreateFile
.
Both of these are "opaque types" that the application programmer doesn't know or care about how they are implemented internally.
In practice, the standard C library port for Windows is just an abstraction layer on top of the Windows API. So FILE* fp = fopen("", "w");
will very likely boil down to a CreateFile
call internally. So for all we know, FILE
could contain a HANDLE
internally.