Multiple copies of same alt-object 
Author Message
 Multiple copies of same alt-object

I would like to be able to open multiple copies of same
alt-COM object at same time. Each has its own unique data,
for example:
 CoCreateInstance(
                CLSID_A,
                NULL,
                CLSCTX_INPROC_SERVER,
                IID_IA,
                (void**) &p1);
    p1->init();
    p1->init();

 CoCreateInstance(
                CLSID_A,
                NULL,
                CLSCTX_INPROC_SERVER,
                IID_IA,
                (void**) &p2);
    p2->init();
    p2->init();

// Inside
x=0;
 init()
{
  ++x;

Quote:
}

I want x to be 0 when I call it using p2, but what I am
finding is that it is two(because I called it twice using
p1. I want each p1,p2 to be unrelated.
So, if anybody knows solution I will appreciated it!
Thank You.
Imad,


Sun, 22 Feb 2004 01:38:47 GMT  
 Multiple copies of same alt-object
Make x a member of the class. This way every instance has its own copy. You
declare x as a global variable.
--
With best wishes,
    Igor Tandetnik


Quote:
> I would like to be able to open multiple copies of same
> alt-COM object at same time. Each has its own unique data,
> for example:
>  CoCreateInstance(
> CLSID_A,
> NULL,
> CLSCTX_INPROC_SERVER,
> IID_IA,
> (void**) &p1);
>     p1->init();
>     p1->init();

>  CoCreateInstance(
> CLSID_A,
> NULL,
> CLSCTX_INPROC_SERVER,
> IID_IA,
> (void**) &p2);
>     p2->init();
>     p2->init();

> // Inside
> x=0;
>  init()
> {
>   ++x;
> }
> I want x to be 0 when I call it using p2, but what I am
> finding is that it is two(because I called it twice using
> p1. I want each p1,p2 to be unrelated.
> So, if anybody knows solution I will appreciated it!
> Thank You.
> Imad,



Sun, 22 Feb 2004 02:06:43 GMT  
 Multiple copies of same alt-object
Don't use static variables - use only member variables.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> I would like to be able to open multiple copies of same
> alt-COM object at same time. Each has its own unique data,
> for example:
>  CoCreateInstance(
> CLSID_A,
> NULL,
> CLSCTX_INPROC_SERVER,
> IID_IA,
> (void**) &p1);
>     p1->init();
>     p1->init();

>  CoCreateInstance(
> CLSID_A,
> NULL,
> CLSCTX_INPROC_SERVER,
> IID_IA,
> (void**) &p2);
>     p2->init();
>     p2->init();

> // Inside
> x=0;
>  init()
> {
>   ++x;
> }
> I want x to be 0 when I call it using p2, but what I am
> finding is that it is two(because I called it twice using
> p1. I want each p1,p2 to be unrelated.
> So, if anybody knows solution I will appreciated it!
> Thank You.
> Imad,



Sun, 22 Feb 2004 02:28:28 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Printing - how to detect which copy on multiple copies

2. Unable to print multiple copies without multiple iterations in print loop

3. Proposal: alt.binaries.examples.vb4 , alt.binaries.examples.vcpp , alt.binaries.examples.java

4. question about copying 16-or-256 GDI bitmap object to monochrome bitmap object by bitblt

5. Object with Multiple Type Objects

6. Serializing objects with multiple pointers to the same object

7. ALT Simple Object structure

8. why com object with alt 7.0 can't run on win2000 without visual.net

9. ALT/MTS COM used as ASP application level object

10. Alt-Tab/Alt-Esc Event

11. simulate a Ctrl+Alt+Del or Alt-Tab

12. Block Alt+Tab, Alt+Esc key combination

 

 
Powered by phpBB® Forum Software