Fixed potentially incorrect usage of Win API