I tried to use these parts of Daniel's code and they did not create sparse files on Windows 10.
I found the following solution (See here) that might prove useful:
Use the DeviceIoControl function with the FSCTL_SET_SPARSE control
code to mark the file as sparse. If you don't mark the file as sparse,
the FSCTL_SET_ZERO_DATA control code will actually write zero bytes to
the file instead of marking the region as sparse zero area.
I tried to use these parts of Daniel's code and they did not create sparse files on Windows 10.
I found the following solution (See here) that might prove useful:
Use the DeviceIoControl function with the FSCTL_SET_SPARSE control
code to mark the file as sparse. If you don't mark the file as sparse,
the FSCTL_SET_ZERO_DATA control code will actually write zero bytes to
the file instead of marking the region as sparse zero area.