用 VC2012+Update 3,已經在專案設定把 Platform Toolset 切換到 「Visual Studio 2012 - Windows XP (v110_xp)」了,看網上的文章這樣都能解決 2012 編譯出來的 exe 原本在 XP 上無法執行的問題,但我這樣做產生的 exe 在 XP 跑還是跳「...不是正確的 Win32 程式」。其實就是 optional header 相關欄位竟然沒修正
原本編譯出來的 MajorOperatingSystemVersion, MinorOperatingSystemVersion, MajorSubsystemVersion, MinorSubsystemVersion 是 6, 0, 6, 0,當然不能在 XP 跑
換 toolset 之後應該會變 5, 1, 5, 1,問題在是我換之後重編的執行檔該欄位還是沒變,後來試著手動修改那四個欄位之後就能在 XP 跑了...