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()?

  1. A.

    CloseHandle("filename.txt");

  2. B.

    CloseHandle(lpFileName);

  3. C.

    CloseHandle(NULL);

  4. 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.

Explore the full course: Niacl Ao It Specialist