Loading DLL

I am loading my own dll I wrote but keep getting an error that my function cannot be found. Its something simple right now but I am not sure if I have it set right to expose the function or not. Any c++ experts among us that may be able to point me in the right direction?

My h file looks like:

[code]#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif

// This class is exported from the MYDLL.dll
class MYDLL_API CMYDLL {
public:
CMYDLL(void);
// TODO: add your methods here.

};

extern MYDLL_API int nMYDLL;

MYDLL_API int __stdcall fnMYDLL(void);

[/code]

I would assume using a soft declare like Soft Declare Function fnMYDLL Lib “MYDLL.dll” As Integer would work right?

Thanks.

I would expect it to as long as its located in the right place for a built app

It is in the correct place but keeps throwing the function not found error. Was unsure if my code was correct for making the functions available to an outside app like xojo.

Thanks.

Not being a Windows guy I’m not certain
You have the DLL Main and all the other normal bits
One thing that’s quite likely not going to work is trying to load a C++ class as the API to the DLL
But there’s only a small snippet of your code so its hard to know why the function isn’t being found

Is this line a typo?

extern MYDLL_API int nMYDLL;

Shouldn’t it be

extern MYDLL_API int fnMYDLL;

Also, the Function Not Found is a false error sometimes, it can mean that the DLL just didn’t load for some reason.

Nope, not a typo, thats what vs2008 generated when the project was created.

Yes I thought that too but this is everytime so something is amiss.

Thanks for any help.

I did just realize I am getting the typical mangling that c++ does to a function. Once I have that resolved then I think it should load correctly then.

Right, use a .def file looking like this:

LIBRARY “MYDLL.dll”

EXPORTS
fnMYDLL @ 1

Yep, did that and that resolved it. Thanks.