I have a problem with code that creates a DLL (or mayby the compiler settings).
I'm trying to create a DLL that works as an extension to a software package (ZEMAX) running under windows 64 - although the software it OLD (2005) - upgrading it would cost >$5000 and it works fine so it makes sense to try.
The software (ZEMAX) uses dll files to extend what it can do and expects these DLLs to have given functions which take give parameters and return given values. Example code is given, I can compile it to a DLL but the software just cannot find the functions.
Example code is given by ZEMAX to which I made minor modifications. I want to create four_angle.dll. Key lines in the example code (whic is all in C# and I'd rather not re-write it all) are:
int __declspec(dllexport) APIENTRY UserParamSourceDefinition(double *data);
int __declspec(dllexport) APIENTRY UserParamNames(char *data);
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}
and later on
int __declspec(dllexport) APIENTRY UserParamNames(char *data)
{
strcpy_s(data[1],16,'hello');
}
int __declspec(dllexport) APIENTRY UserSourceDefinition(double *data)
{
data[30] = (double)data[2] + 1.0;
}
Visual studio compiles with no errors. Is there any reason these functions cannot be called by the software which loads the DLL at runtime? I am new to making dlls so I have no idea on how those definition statements and options for DLLMain work.
PS - I notice that visual studio also created a DLLmain which I commented out as you cannot define something twice. Again I've only so much of an idea how it works and if I'm meant to fill in some of the case statements.
#include "stdafx.h"
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call,LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
PPS I've been following the instructions here - but with no luck: http://customers.zemax.com/os/resources/learn/knowledgebase/how-to-compile-a-user-defined-surface.aspx