A: If you have a DLL written in C++ like this:
#define STRICT
#include <windows.h>
#define DEFINE_EXPORT
#define _EXP _export
//******Your code goes here*****************************************
int _EXP MyFunc (int i)
{
return (i+10);
}
//*****************************************************************
#pragma argsused
int FAR PASCAL LibMain( HINSTANCE hInstance,
WORD wDataSegment,
WORD wHeapSize,
LPSTR lpszCmdLine )
{
if ( wHeapSize != 0 )
UnlockData( 0 );
return 1; // Indicate that the DLL was
initialized successfully.
}
#pragma argsused
int FAR PASCAL WEP ( int bSystemExit )
{
return 1;
}
This won't work. There are two ways to fix it. One is to declare the function in question as EXTERN. e.g.
extern "C" {
int _EXP MyFunc (int i)
{
return (i+10);
}
}
In this case you need to use cdelc when you prototype the function. Something like this:
function MyFunc(i: integer): integer; cdecl; far; external 'MYDLL' index 12;
OR
you can declare the functions with FAR PASCAL and then call the function in the normal way
If there are problems, make sure that you declare the DLL functions
with "_loadds". Remember that, normally, a DLL function runs on the
caller's DS, unless you specifically load the correct one.