Coding the Custom Action DLL
Open the "StdAfx.h" file. Make the modification shown in bold below.
C++ Code
/*
stdafx.h : include file for standard system include files,
or project Each Project you create represents a single Speech
Driven Information System An Information System is a general
term used to describe the product you are designing with this
software. This could be any type of system in which you can give
information to your callers, such as a Virtual Customer Service
Center, a Virtual Technical Support Center, or a Virtual Help Desk..
So, if you want to create three separate Information Systems, you
will need to create three different Projects. specific include files
that are used frequently, but are changed infrequently
*/
#if!defined (AFX_STDAFX_H__9748C1DE_4F89_11D6_B4F5_0002B3494C5D__INCLUDED_)
#define AFX_STDAFX_H__9748C1DE_4F89_11D6_B4F5_0002B3494C5D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Insert your headers here
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <lvca.h>
// TODO: reference additional headers your program requires here
// {{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__9748C1DE_4F89_11D6_B4F5_0002B3494C5D__INCLUDED_)
Open the document which contains the DLLMain function. Make the modification shown in bold below:
C++ Code
// ca_test.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include "cadll.h"
BOOL APIENTRY DllMain( HANDLE 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;
}
// This is an example of an exported function.
CA_TEST_API BOOL WINAPI fnCallback( LONG message, HANDLE handle )
{
BOOL bReturn = FALSE ;
switch ( message )
{
case CAMSG_POLL:
bReturn = TRUE;
break;
default:
}
return bReturn ;
}
Open the CPP's header file. Make the modification shown below:
C++ Code
/*
The following ifdef block is the standard way of creating
macros which make exporting from a DLL simpler. All files
within this DLL are compiled with the CA_TEST_EXPORTS symbol
defined on the command line. this symbol should not be defined
on any project that uses this DLL. This way any other project
whose source files include this file see CA_TEST_API functions
as being imported from a DLL, whereas this DLL sees symbols
defined with this macro as being exported.
*/
#ifdef CA_TEST_EXPORTS
#define CA_TEST_API __declspec(dllexport)
#else
#define CA_TEST_API __declspec(dllimport)
#endif
CA_TEST_API BOOL WINAPI fnCallback( LONG message, HANDLE handle );
Press F7 to build the DLL.
Additional Information
A note regarding the CA_TEST_EXPORTS and CA_TEST_API macro: these are arbitrary names used for resolving
possible conflicts with exporting and importing functions and classes. You may use your own names so long
as you are consistent. We recommend brushing up on the topics covered in "DLL Tasks" and the
article "Mutual Imports" in the MSDN Library.
If you run Dependency Walker (depends.exe) and open up your Customj Action DLL, you will see an entry
on one of the right-hand views: ?fnCallback@YGHJPAX@Z. This is the "decorated" name of your
callback function and it is the name you will enter in the in the Designer if the designer does not
recognize it. You do not have to use this opaque naming convention. Create a .def file and type in the
following entries:
Save the file and rebuild your DLL. If you open up your Custom Action DLL again you will now see that
the entry is simply fnCallback which can be entered in the Designer.
Design Considerations:
The Engine is a multithreaded application, therefore, it is a good idea to make your DLL multithreaded
and your callback function re-entrant. State data is managed through the LVCA_SetUserData and LVCA_GetUserData
functions.