Solved

A few simple ATL DLL Questions

Posted on 2003-12-05
2
634 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
Comment Utility
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
Comment Utility
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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now