Skip to content

Instantly share code, notes, and snippets.

@0xbadfca11
Last active September 4, 2025 14:05
Show Gist options
  • Save 0xbadfca11/4ababeff1e3eaa2bb7dcb95b0a89b8ee to your computer and use it in GitHub Desktop.
Save 0xbadfca11/4ababeff1e3eaa2bb7dcb95b0a89b8ee to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <cstdio>
#include <cstdlib>
#include <wil/filesystem.h>
#include <wil/resource.h>
int wmain(int, PWSTR argv[])
{
const auto [d, e] = wil::try_open_file(argv[1], FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_FLAG_BACKUP_SEMANTICS);
if (!d)
{
fprintf(stderr, "CreateFile %08lx\n", e);
return EXIT_FAILURE;
}
FILE_CASE_SENSITIVE_INFORMATION file_cs = { FILE_CS_FLAG_CASE_SENSITIVE_DIR };
if (!SetFileInformationByHandle(d.get(), FileCaseSensitiveInfo, &file_cs, sizeof file_cs))
{
fprintf(stderr, "SetFileInformationByHandle %08lx\n", GetLastError());
return EXIT_FAILURE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment