How to build pywin32 using python 3 64-bit on Windows 10

Most recently I had to build pywin32 from source due to a known issue on DDE (That will come under a separate post). Follow the steps to get the pywin32 64-bit built using python 3 on a Windows 10 machine.

  1. Download and run Visual Studio Build Tools 2017
  2. Select and install Windows 8.1 SDK and Visual C++ 2015.3 v14
  3. Download MFCMAPI headers. I downloaded them from http://mfcmapi.codeplex.com/SourceControl/latest, and copied EdkGuid.h and EdkMdb.h in "C:Program Files (x86)Windows Kits8.0Includeum"
  4. Download the latest pywin source code (https://github.com/mhammond/pywin32)
  5. In setup.py line 155, modify
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows Kits\Installed Roots")

to

key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots")
  1. Run python3 setup.py install
  2. Once building is complete you will be informed that pywin32 extensions were successfully installed.
  3. The end.