Fix Windows include for MinGW

MinGW is case-sensitive
Fix Windows directory check

Please double-check to make sure I did the right thing.  This code looks like it was untested as the argument was an undeclared variable.
Swap MSVC-specific function for WINAPI equivalent