SilverScreen Solid Modeler

Adding a SilverPlus entry point

Adding a SilverPlus entry point

Previous topic Next topic  

Adding a SilverPlus entry point

Previous topic Next topic JavaScript is required for the print function  

SilverPlusEllipse

 

Adding a SilverPlus entry point

 


A SilverPlus DLL is a normal MFC or Win32 DLL with an entry point called SilverCExec that must be exported. This topic describes the format of, and provides a framework skeleton for, the entry point.

 

 

Function table declaration

A SilverPlus DLL must contain a declaration for the SilverScreen API function table in order to access the SilverScreen API. This amounts to including ssrex.h, adding a global variable declaration, and initializing the variable in the SilverPlus entry point (SilverCExec). The following code shows all that is necessary to declare the function table pointer:

 

C / C++ Code

 

 #include "ssrex.h"

 

 . . .

 

 SSREX *sc;

 

 

Note: The include file SILVER2.H may be used instead of ssrex.h, since it includes SSREX.H

 

 

Entry point declaration

A SilverPlus DLL must also contain an exported function signature for SilverCExec, which is required by the SilverC DLL loading and unloading code. It is also used to pass the SilverScreen API function table pointer to the DLL (it contains function pointers corresponding to members of the SilverC library), so that SilverC functions may be used by the DLL. It is also used by a SilverC program to call into the DLL, thus serving as the gateway between SilverC and the DLL.

 

 

 

The function signature for SilverCExec must match the following:

C / C++ Code

 

 extern "C" __declspec(dllexport) int SilverCExec( int op, void *data );

 

 

 

That is:

 

r_point

C linkage

r_point

exported by __declspec(dllexport) (or other means)

r_point

__cdecl calling convention

 

Where:

 

op is a  user-defined operation code; with the exception of anything less than the value of REX_USER_BASE, which is reserved for SilverScreen library initialization

 

data is dependent on the operation code; in the case where op is equal to REX_FIRST_LOAD, this will be a pointer to an SSREX structure. The alignment for members of structures passed via data (including the SSREX) structure must be 4 bytes.

 

 

Win32 Skeleton

The following code show a Win32 DLL skeleton which implements SIlverCExec. The initialization of the SilverScreen API table is marked in red to signify its importance and to draw attention to the code.

 

C / C++ Code

 

 #include <windowsx.h> // Or, stdafx.h, etc.

 #include "silver2.h"

 

 SSREX *sc = NULL;  // The one-and-only global SSREX pointer

 

 

 //

 // Note: DllMain is required of Win32 DLLs, an MFC DLL handles

 //       the requirement through the CWinApp class.

 //

 

 extern "C" __declspec(dllexport) BOOL APIENTRY

    DllMain(HINSTANCE hInstance,

            DWORD     dwReason,

            LPVOID    lpReserved)

    {

    if (dwReason == DLL_PROCESS_ATTACH)

       {

       // DLL Initializing (i.e. InitInstance)

       }

    else

    if (dwReason == DLL_PROCESS_DETACH)

       {

       // DLL Terminating (i.e. ExitInstance)

       }

 

    return 1;   // ok

    }

 

 

 //

 // Note: SilverCExec is required of SilverPlus DLLs

 //

 

 extern "C" __declspec(dllexport) int SilverCExec(int op, void *data)

    {

    switch ( op )

       {

       case REX_FIRST_LOAD:

            sc = (SSREX *) data;

            break;

 

       case REX_LOADING:

            break;

 

       case REX_UNLOADING:

             break;

 

       case REX_REMOVED:

             break;

       }

 

    return 1;

    }

 

 

 

Example

For an example of an MFC DLL skeleton, see the SilverPlus sample MFDLL.