BOOL
BOOL is a 32‑bit integer used in the Windows API to represent Boolean values.
Syntax
#include <windef.h>
typedef int BOOL;
Values
TRUE
(1) – Boolean trueFALSE
(0) – Boolean false
Remarks
Although BOOL
is an integer, it should only be used with the constants TRUE
and FALSE
. Functions that return BOOL
typically indicate success with TRUE
and failure with FALSE
. When a function fails, you can call GetLastError()
to obtain more error information.
Example
#include <windows.h>
#include <stdio.h>
int main(void)
{
BOOL result = SetConsoleTitleA("BOOL Example");
if (result)
{
printf("Title set successfully.\n");
}
else
{
printf("Failed to set title. Error: %lu\n", GetLastError());
}
return 0;
}