I have this simple program:
#include <windows.h>
#include <iostream>
#include <stdint.h>
int main() {
WCHAR Filestring[MAX_PATH] = L"\0";
OPENFILENAMEW ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = Filestring;
ofn.nMaxFile = MAX_PATH;
if (GetOpenFileNameW(&ofn))
{
}
return 0;
}
This is my "simple reproducible example".
When I run this in my Visual Studio, it crashes at GetOpenFileNameW.
Why? I don't know. But when I run the application from the file path instead of debugging, it's fine and it opens the dialog like's it's supposed to.
I realized it's an issue with my situation rather than the code, so I completely reinstalled windows!
After, it worked fine when I tested it. But 5 hours later, I'm getting the same error.
Here is my error:
Anyone know what to do?
This code used to work, because I just grabbed it from an earlier project that just worked, until very recently for no reason.

I fixed it
I realized CMake was breaking it. I uninstalled it and it fixed it. WEIRD?