Which of the following is a correct usage of CloseHandle() after using…
2025
Which of the following is a correct usage of CloseHandle() after using CreateFile()?
- A.
CloseHandle("filename.txt");
- B.
CloseHandle(lpFileName);
- C.
CloseHandle(NULL);
- D.
CloseHandle(fileHandle);
Attempted by 9 students.
Show answer & explanation
Correct answer: D
In the Windows API (Win32), the operating system manages system resources like files, threads, and processes using internal objects. Applications cannot access these objects directly; instead, they use an abstract token called a HANDLE.
When you call CreateFile(), the operating system allocates system resources for file access and hands you back a handle if successful.