Single / Multiple ATL COM object instances (using smartpointer)

Help! Please! Partial answer will get points too!
I am using the smartpointer recieved from the #import directive in the client.
My objects are ATL simple objects.

I would like to understand how to make multiple/single instances of objects:

1. If I wish to make only ONE instance called from several clients:
1.1 How do I do it without modifying the code of my object (if possible)?
1.2 What can I modify in the object so it's always one instance that comes up?
1.3 What happens if I use such a "singelton" in MTS?

2. If I want multiple instances of the same object in each client:
2.1 How do I do it without modifying the code of my object (if possible)?
2.2 What can I modify in the object so it's always one instance per client
(if possible at all)?
2.3 What happens if I use such a "forced multipleton" in MTS?
LVL 2
mflamAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mflamAuthor Commented:
Adjusted points to 100
0
mflamAuthor Commented:
Edited text of question.
0
mflamAuthor Commented:
Help! Please.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

mflamAuthor Commented:
Please! Urgent!
0
mflamAuthor Commented:
Adjusted points to 120
0
mflamAuthor Commented:
Edited text of question.
0
mflamAuthor Commented:
Edited text of question.
0
ajitmCommented:
You can use one smart pointer as a member in the client. Take only one instance of the object by calling 'new'.

e.g. IYourClassPtr pTempPtr;

pTempPtr = new IYourClassPtr(__uuidof(YourClass));

Then afterwords use only the smart pointer i.e. IYourClassPtr .

I think this will ensure single instance of the class per client.

Hope this will work.

Ajitm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mflamAuthor Commented:
I found out also that I can use the:

DECLARE_CLASSFACTORY_SINGLETON

for making the smartpointer singelton always. (in other words for making a single shared object).

Otherwise I get a new object for each call.

Thank you very much, Moshe
0
ajitmCommented:
Hi mflam,
You have accepted the answer but no points are added to me(120 pts.). Please do the needful.
Thanks.
Ajitm.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.