Skip to content
Raymond Chen edited this page Jan 23, 2020 · 15 revisions

WIL Win32 helpers assist with various functions and data types used by Win32.

Usage

The Win32 helpers can be used by including the correct header file:

#include <wil/win32_helpers.h>

String length constants

All string length constants are in the wil namespace and have type size_t.

Name Value Meaning
max_path_segment_length 254 Maximum length of a directory or file name. Does not include terminating null.
max_path_length 259 Maximum length of a MAX_PATH path. Does not include terminating null.
max_extended_path_length 32743 Maximum length of an extended path. Does not include terminating null.
guid_string_buffer_length 39 Size of buffer to hold a GUID string, including enclosing curly braces and terminating null.
guid_string_length 39 Length of a GUID string, including enclosing curly braces but not the terminating null.

The unusual value for max_extended_path_length comes from the system limit of 0x7FFF minus 24, where 24 is the length of the \Device\HardDiskVolume# prefix. If the path refers to the 10th through 99th hard disk volume, then the prefix grows to 25 characters, and the corresponding maximum length decreases by one.

File time constants

The file time constants are in the wil::filetime_duration namespace. They are all long long and represent the number of FILETIME units (100ns) contained in various well-known durations.

Name Value
one_millisecond 10000
one_second 10000000
one_minute 600000000
one_hour 36000000000
one_day 864000000000

File time helpers

The file time helpers are in the wil::filetime namespace.

  • unsigned long long to_int64(const FILETIME &ft)
    FILETIME from_int64(unsigned long long i64)

    • The conversion functions convert between a FILETIME structure (two 32-bit integers) and a 64-bit unsigned integer.
  • FILETIME add(_In_ FILETIME const &ft, long long delta)

    • Adjusts the value in an existing FILETIME structure by the specified number of ticks.
  • bool is_empty(const FILETIME &ft)

    • Returns true if the FILETIME is all zeros.
  • FILETIME get_system_time()

    • Returns the system time as a FILETIME.

Clone this wiki locally