NO

Author Topic: ActiveX (DllGetClassObject and DllCanUnloadNow)  (Read 6655 times)

ivanhv

  • Guest
ActiveX (DllGetClassObject and DllCanUnloadNow)
« on: March 06, 2007, 11:25:52 PM »
Hi everyone.

Some time ago I was working on a driver for my mobile device (it should read IR from my old Palm Wireless Keyboard and send data to the working application).

I worked out all the IR thing and created a whole application for testing input from keyboard. But when faced to sending data to the current application, I had no clue about how to do it, because none of the usual functions you would be using on desktop existed for CE Platform (there are some posts about on Windows CE Forum)

Reluctantly, I fell on Input Method (I expected to avoid it, but was not possible). I developed the ActiveX and although it registered well, it didn't work.

I left the project parked (I've been giving a shot at Playstation development and I can now read input from this same keyboard on PSP  :D )

Now, I'm picking up the project again. I added lots of logs and I think I've found the problem. And, of course, it's a real silly problem.

It happens that the dll containing my activeX has to export those functions:

DllMain
DllRegisterServer
DllUnregisterServer
DllGetClassObject
DllCanUnloadNow

and it does, except for the last two.

If I declare DllCanUnloadNow as

STDAPI DllCanUnloadNow (void)

it compiles and links fine, but the function is not exported. If I declare:

__declspec( dllexport ) STDAPI DllCanUnloadNow (void)

it should export (as it does with DllRegisterServer, that is declared the same way), but fails to link with:

POLINK: error: Unresolved external symbol '_$DllGetClassObject'.

I think the problem is related to the declaration of both functions at objbase.h

Question (at last) is... how can I export those two functions from my dll?

By the way, I'm compiling with -Gz and -Ze flags, but not -Gn. If I compile with -Gn the symptoms are the same. I also have -D_WINCE and -DUNICODE put on.

ivanhv

  • Guest
ActiveX (DllGetClassObject and DllCanUnloadNow)
« Reply #1 on: March 06, 2007, 11:59:11 PM »
Ok! I've done it!

As I said, the problem is with lines 315 and 316 at objbase.h where it says:

STDAPI DllGetClassObject(REFCLSID,REFIID,LPVOID*);
STDAPI DllCanUnloadNow(void);

The linkage problem has to be with this two declarations. When removing the __declspec from my code, this two functions get defined, and the linker doesn't complain (but as they are not exported, ActiveX object can't ever be instantiated. If I write back __declspec, the functions are exported, but the two declarations at objbase are considered as having missing definition (and that's the error showed by the linker).

The solution then is to comment out those two lines at objbase.h

I don't know what the side effects of this action could be. I don't believe is a good idea to get out those two lines from the header file, but don't know any reason why they should exist there that way, except for appearing in the same form at Platform SDK. Hope Pelles can bring light to this.