How To Compile An Extension Using Microsoft Visual Studio Community 2017

This article describes how to compile a DDE Extension using the Microsoft Visual Studio C++ compiler.
Extensions have been deprecated (meaning that no new capabilities or bug fixes will be provided from that release onward) since the release of OpticStudio 15. We highly recommend that any users that wish to write their own applications to work with OpticStudio use ZOS-API, which is a much more powerful tool based the latest available programming technologies. For more information, see the section in the Help Files "About the ZOS-API" or visit the ZOS-API.NET: An Overview, or related Knowledge Base Articles.  
Thomas Pickering

Microsoft Visual Studio Community 2017

Start MS Visual Studio Community 2017, and then define a new C++ Win32 project

Enter a name for this project: in this case I used the name Hello World. Then press OK. In the next screen, "Application Settings", declare this to be an empty project, so no files are created.

Set the active solution configuration to Release and the active solution platform to whatever is appropriate for your system:

In the Solution Explorer, right-click on the Source Files folder and choose Add...Add Existing Item. Add the two files hello_world.c and zclient.c. The first file can be downloaded from the Sample Files section of this article. The other file can be found in the Extend folder, which typically is ..\Documents\Zemax\Extend

Then, in the Solutions Explorer, right-click on the project name itself, and then select properties. Under the general Configuration Properties, you need to select the Multi-Byte Character Set:

Under C/C++ and Command Line, enter /Y- into Additional Options. This turns off pre-compiled headers. Confirm with OK.

Then click on Build...Build Solution and the project should compile normally, without error:

That's it! To use your extension within OpticStudio, you just need to move it to the appropriate folder in your OpticStudio Installation folder. Typically, this is under Program Files\OpticStudio\Extend.