Solved

A few simple ATL DLL Questions

Posted on 2003-12-05
2
650 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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 clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

623 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