First start Microsoft Visual C++ version 6. The click File > New and select a Win32 Dynamic Link Library. Give the project a name, and choose a directory to hold the project files:

The new Project wizrad in Ms Visual C++ version 6

In this case, the project name is My_asphere, Click OK, and then choose to create an empty project:

Create an empty dll project

This means that the project is an empty container waiting for you to add files. In the Explorer tree on the left hand side, select "File View", and right-mouse-click on "Source Files", and select "Add Files from Folder":

Add Files

In the dialog that opens, navigate to {zemaxroot}/dll and select myarray.c. Remember, this is the copy of us_arrayeven.c that you made when you followed the instructions on the bottom of page 1 of this article.

Then, in the project pane above, right-mouse-click on "Header Files", choose "Add Files From Folder", and add the file usersurf.h, which is also in the {zemaxroot}/dll folder. The project pane should now look like this:

After inserting all files
The last thing we have to do before we can start editing our file is to set the code generation options in Microsoft Visual C++ 6. Click on Project>Settings:

Project Settings

Select the project itself in the tree on the left hand side, and in the C/C++ tab choose Category > Code Generation, and then choose Use Run-Time Library > Multithreaded. Then select Build > Set Active Configuration, and choose "Release":

Selecting Release Mode

That's all the configuration that is required! To test that the compiler works, we will make a simple modification. Double-click on my_array.c in the project explorer to open it:

Editing the source file

Find the line in Case 0 that says "strcpy(UD->string,"Even Array");" and change the name of the surface to "My Even Array". The line of text should now read:

strcpy(UD->string,"My Even Array");

and then choose Build > Rebuild All. The dll should compile without error:

It compiles!

Then copy the dll from your project's /release folder into the {zemaxroot}/dll folder.

Now start ZEMAX, and select a surface to be user-defined:

Selecting the surface

In the Lens Data Editor, the name we gave the surface is shown:

The surface is read in correctly
Congratulations! You have compiled a user-defined surface!