Articles - Custom DLLs

Adding Custom Dynamic Link Libraries (dll)

 

A Brave New World

For those brave souls who desire to integrate custom software into OneWorld without using the JDE tool set this tutorial may come in handy. 

In this tutorial we'll create a Dialog based program compiled as a DLL.  The program will use all of JDEs database API for file I/O, thus inheriting all of the standard OCM and security settings.  Finally, when OneWorld initiates the program the Form will halt and wait for return values from the dialog.

 

The project I'm showing you will integrate a C++ MFC program into a OneWorld Form.   However, since this isn't really about MFC, I'm just going to show you the steps without delving into how MFC works.  The real purpose here is to show you that any DLL can be dynamically called within OneWorld and it can inherit all the proper handles so it inherits OCM and security restrictions.

 

 

The Tutorial:

This is where we're going.  The dialog box you see in this screen capture was written in MFVC and compiled as a DLL.  When the user presses the Test Dialog DLL button, the dialog displays.  When the OK button is pressed on the dialog it's information is passed back into OneWorld.  This tutorial will show you how to pass OneWorld's information into a DLL so you can have access to OneWorld's API.   Likewise, the DLL can pass information back into OneWorld.  The added benefit here is that you now have the ability to use more tools than just those supplied by JDE.

TheGoal.jpg (20302 bytes)

Create a new DLL with MFC

In C++, create a DLL project with the wizard:

   

Select MFC AppWizard(dll)

NewProject.jpg (40549 bytes)

Choose Regular DLL with MFC statically linked. 

Click 'Finish' and you're done.

AppWizStep1.jpg (43806 bytes)

 

Project Settings:

Now, in order to use this new program with OneWorld you have to alter some of the compiler settings.

Open the Settings dialog under the 'Project' drop down menu.

 

First is the "Struct Member Alignment" value.  Select the C/C++ tab and under Category select "Code Generation." Locate the Struct Member Alignment field.  By default this field is set to 8 bytes.  If you don't change this to 1 byte the data structure passed from OneWorld will not align properly.  When this happens you'll see your data structure being truncated, or values from the variables in the structure will migrate into adjacent fields in the structure.

ProjectSettings1.jpg (34443 bytes)

 

Select the 'Link' tab and locate the Object/library Modules field.  These are the commonly used Libraries that will be required for most things your write.  If you run into Linker Errors during a compile odds are you're missing a library in this list.  Locate the missing library using Windows Find tool and add it to this list. 

    It's hard to see just what's in there, so here is a listing.  You can copy and past this text right into that dialog->

            jdel.lib jdbodbc.lib jdekrnl.lib jdesetup.lib jdeuser.lib jdegbr.lib jdeoblib.lib jdedia.lib jdedia1.lib jdemail.lib envtool.lib browser.lib jdepkgbld.lib

ProjectSettings2.jpg (37378 bytes)

 

Options:

        Tools Menu->Options...

Now we need to tell the compiler exactly where these files, and others necessary for compilation, are located.  MS C++ needs to know where 'include' files, 'source' files, and 'libraries' exist on your computer.  Open the Options dialog under the Tools menu and pick the Directories tab.  Fill them in as indicated below.   Your directories may be named a bit differently.

Enter the locations of both your DEV and System Include Files

Enter the locations of both your DEV and System Include Files

Enter the location of your systems Library Files

Enter the location of your systems Library Files

Enter the location of your Source Files

Enter the location of your Source Files

 

 

example graphic