Solved

A few simple ATL DLL Questions

Posted on 2003-12-05
2
638 Views
Last Modified: 2013-12-14
Hi, a couple of questions relating to ATL (COM) DLL's.  I'm moving from MFC to ATL/WTL, so I'm having to get away from MFC Extension DLLs.  Basically, most of these relate to a replacement for my happy MFC Extension DLL way.

1) What is the (myproject)PS project?  What function does it serve, and when would I need to use it?

2) With an ATL COM DLL, is there a way to export a C++ Class (for example, a derivation of CWindowImpl) from the DLL?  If so, how; if not, is there an alternate way with a different type of dll?

3) With these COM objects and such, aren't all the methods to the interface exposed to anyone wanting to look at them? Is there a way to prevent this?


I'm very new to COM, but I fear it's something that will not go away.  Any tips would be *greatly* appreciated. :)  I'll split points if need be.

Thanks.
0
Comment
Question by:Shutterbug
2 Comments
 
LVL 49

Assisted Solution

by:DanRollins
DanRollins earned 50 total points
ID: 9887827
1) I don't know.  Where did you see it?  Provide a context.
2) Yes.  Use the ClassWizard to create and object publish its methods and properties via the IDL.  But it is probably easiest to just export normally, via a shared header (standad DLL exporting).
3) The direct interfaces... yes.  But let's say that the first parameter to a method is a long int.  Nobody knows that if that integer is set to 0x27856, the program performs some magic, undocumented operation.
-- Dan
0
 
LVL 9

Accepted Solution

by:
_ys_ earned 100 total points
ID: 9896083
1) This project allows you to compile a custom proxy/stub dll. If you don't know what these are, chances are you don't need them. Feel free to ignore this project.

2) As DanRollins pointed out, yes. But be careful. A COM dll can be unloaded by the COM runtime whenever it's not using it - this would result in some nasty dangling references to instances of your exported classes.

3) But this is one of the points to, and benefits of, COM - exposing objects via interfaces. If you do want to hide any interfaces, remove them from the IDL - thus excluding them from the type library. Of course, in this situation, you would have to declare those interfaces elsewhere.

struct IMyInterface
{
    __stdcall HRESULT myMethod1 ( ) = 0;
    __stdcall HRESULT myMethod2 (int) = 0;
};

// {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
const GUID IID_IMyInterface =
{ 0xXXXXXXXX, 0xXXXX, 0xXXXX, { 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX } };
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

777 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