|
Transports and Interfaces: Siebel Enterprise Application Integration > EAI DLL and EAI File Transports > About the EAI DLL Transport >
Creating a DLL to Call a Function in an External DLL
The following procedure illustrates how to create a DLL to use the EAI DLL Transport business service to call a function in an external DLL. It is not necessary for the DLL to release the memory either on Microsoft Windows or UNIX. The DLL transport business service will release the memory. If the DLL does a memory deallocation, then the deallocation will most likely fail. The DLL must do the memory allocation with a C-style malloc only. Any other type of allocation will not be handled properly and can lead to failure. To create a DLL
- Open a VC++ project by choosing the Open menu, then New.
- Select a Win32 Dynamic Link Library and give the name of the project.
- In the next dialog box, select the option Simple dll project.
Following files are created by default:
- Project.cpp
- StdAfx.h
- StdAfx.cpp
- Make the following changes in the StdAfx.h and Main.cpp files and check the results in the process simulator:
StdAfx.h struct XMLDataBuf {
int nLength; void* pData;
};
extern "C" int __declspec(dllexport) TestEAI(const XMLDataBuf* Value, XMLDataBuf* pReply); Main.cpp #include "stdafx.h" #include <string.h> #include <stdio.h> #include <io.h>
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
return TRUE;
}
extern "C" int __declspec(dllexport) TestEAI(const XMLDataBuf* Value, XMLDataBuf* pReply) {
FILE *p; p = fopen("c:\\test.txt","w"); fprintf(p,"before test"); fprintf(p,"%s After Test",Value->pData); //strcpy(s,"Hello World"); fclose(p); return 0;
}
|