Solved

need to implement DllCanUnloadNow() function

Posted on 2013-12-12
3
513 Views
Last Modified: 2015-05-17
Hi,

I need to define the DllCanUnloadNow() function in one of my .ocx component(OLE based COM DLL).  
The COM DLLs which are having ATL support are also having CComModule global object, which can be used to get the lock count. For this particular case it's easy to implement the DllCanUnloadNow() function.

In my .ocx component, I do not have the ATL support. For this I am looking for some alternate of CComModule to implement the DllCanUnloadNow() function.

So, my question is to how to implement the DllCanUnloadNow() function if we do not have the CComModule object?

If we see the MSDN documentation for DllCanUnloadNlow(), it says-
"OLE does not provide this function. DLLs that support the OLE Component Object Model (COM) should implement and export DllCanUnloadNow."

Any ideas would be highly appreciable.
0
Comment
Question by:davinder101
3 Comments
 
LVL 24

Accepted Solution

by:
chaau earned 500 total points
ID: 39715820
Just create a exported function with this signature:
HRESULT __stdcall DllCanUnloadNow(void);

Open in new window

Then implement the function, returning S_OK or S_FALSE depending on whether the dll can be unloaded or not.
It just all depends on your project coding style. If you use __declspec syntax then the function should be exported like your other functions, like this:
#ifdef MY_OCX_EXPORTS
#define MY_OCX_API __declspec(dllexport)
#else
#define MY_OCX_API __declspec(dllimport)
#endif
MY_OCX_API HRESULT __stdcall DllCanUnloadNow(void);

Open in new window

If you use a def file, then just use in the 'h' file this syntax
HRESULT __stdcall DllCanUnloadNow(void);

Open in new window

and add DllCanUnloadNow to the EXPORTS section of the file:
EXPORTS
    ; Explicit exports can go here
    DllCanUnloadNow

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
I could not build boost code, 10 88
Problem with SqlConnection 4 170
Create a path if not exists 7 78
Where are the c++ header files to use in Eclipse? 4 12
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question