Step by step. To find the vc version, look in windows explorer. If you installed in the to the default location, look at the folder C:\Program Files\Microsoft Visual Studio 2017\VC\Tools\MSVC. You should see one or more subfolders named 14.xx.xxxx. Use the name of the last folder for the vc version.
To find the SDK version, look at the folder where you installed the windows 10 sdk. The default location is C:\Program Files (x86)\Windows Kits\10. Look at either the include or lib subfolders. You should see one or more folders named 10.0.xxxxx.0. Use the name of that last folder for the sdk version.
In codeblocks, go to Settings->Compiler... In the dialog that pops up, select Microsoft Visual C++ 2010 and hit the "Copy" button.
Enter a name for the new compiler.
Select the custom variables tab, and create 4 variables WINSDKROOT, WINSDKVERSION, VCROOT, and VCVERSION.
For WINSDKVERSION and VCVERSION use the numbers found above. If you use the default installation location WINSDKROOT should be C:\Program Files (x86)\Windows Kits\10 and VCROOT should be C:\Program Files\Microsoft Visual Studio 2017\VC\Tools\MSVC. When you enter these variables, a popup will ask if you want to surround these in quotes. Hit the "Leave unquoted" button.
Move to the Toolchain executables tab. The only thing that needs to be changed is to enter $(VCROOT)\$(VCVERSION)\bin\Hostx64\x64 for the compiler's installation directory. All other items can be left with their default values.
Next hit Additional path's sub-tab. Enter $(WINSDKROOT)\bin\$(WinSDKVersion)\x64 and $(WINSDKROOT)\Debuggers\x64
Move to the Search directories tab and the Compiler sub-tab. Enter
$(VCRoot)\$(VCVersion)\include
$(WinSDKRoot)\include\$(WinSDKVersion)\shared
$(WinSDKRoot)\include\$(WinSDKVersion)\ucrt
$(WinSDKRoot)\include\$(WinSDKVersion)\um
You can also add
$(WinSDKRoot)\include\$(WinSDKVersion)\winrt
$(WinSDKRoot)\include\$(WinSDKVersion)\cppwinrt
but I have not needed those yet.
On the linker sub-tab add
$(VCRoot)\$(VCVersion)\lib\x64
$(WinSDKRoot)\lib\$(WinSDKVersion)\ucrt\x64
$(WinSDKRoot)\lib\$(WinSDKVersion)\um\x64
On the resource compiler sub-tab add
$(WinSDKRoot)\include\$(WinSDKVersion)\shared
$(WinSDKRoot)\include\$(WinSDKVersion)\um
The compiler is now ready for use with codeblocks. The only slight problem is that when codeblocks starts, you'll get a warning like the following:
Despite this warning, it does work.