Use of importlib 
Author Message
 Use of importlib

Hi,
Here is my problem:

I have two ATL DLLs: ApxComponent1.dll and ApxComponent2.dll.
The first one defines the simple COM object ApxObject1, and
an ApxEnum1 enum.
The second one defines the simple COM Object ApxObject2.

ApxObject2 has a method taking an IApxObject1*, and an
ApxEnum1 as parameters.

I did not manage to compile ApxComponent2.idl without
importing "ApxComponent2.idl" at the beginning of the file:
if I just use importlib in the "library" section I get
this error message:
 error MIDL2011 : unresolved type declaration : IApxObject1 ....

I would prefer to use importlib because when I use
import, I end up with ApxEnum1 defined in the two type
libraries.

How can I do ?

Thanks.
Chris.

Here are the IDL files:

import "oaidl.idl";
import "ocidl.idl";
 [
  object,
  uuid(15E6ABEF-7457-418D-BCC2-4B6D8F062E88),
  dual,
  helpstring("IApxObject1 Interface"),
  pointer_default(unique)
 ]
 interface IApxObject1 : IDispatch
 {
  [id(1), helpstring("method ShowEnum")] HRESULT ShowEnum(enum ApxEnum1
enumValue);
 };

[
 uuid(4AA9EB6C-7BBF-4B50-908B-4CD12A51F23D),
 version(1.0),
 helpstring("ApxComponent1 1.0 Type Library")
]
library APXCOMPONENT1Lib
{
 importlib("stdole32.tlb");
 importlib("stdole2.tlb");

 typedef [uuid(53D4C1A4-AE90-4e9e-809C-740CF74126C9),
    public,
    v1_enum,
    helpstring("ApxEnum1 constants")]
 enum ApxEnum1
 {
  [helpstring("e1One")] e1One  = 1,
  [helpstring("e1Two")] e1Two  = 2
 } ApxEnum1  ;

 [
  uuid(35E2F748-A31D-4980-9E3A-D11F309081BB),
  helpstring("ApxObject1 Class")
 ]
 coclass ApxObject1
 {
  [default] interface IApxObject1;
 };

Quote:
};

import "oaidl.idl";
import "ocidl.idl";

 interface IApxObject1 ;

 [
  object,
  uuid(2B3EA56F-E793-4D68-9D58-59D9C15DC5F3),
  dual,
  helpstring("IApxObject2 Interface"),
  pointer_default(unique)
 ]
 interface IApxObject2 : IDispatch
 {
  [id(1), helpstring("method SetEnum")] HRESULT SetEnum([in] IApxObject1*
pObj, [in] enum ApxEnum1 enumValue);
 };

[
 uuid(1AD2B362-2449-4CBC-B5EF-273F86401BAB),
 version(1.0),
 helpstring("ApxComponent2 1.0 Type Library")
]
library APXCOMPONENT2Lib
{
 importlib("stdole32.tlb");
 importlib("stdole2.tlb");
 importlib("..\ApxComponent1\ApxComponent1.tlb");

 [
  uuid(E733F587-4750-472F-888C-B0692A8F7112),
  helpstring("ApxObject2 Class")
 ]
 coclass ApxObject2
 {
  [default] interface IApxObject2;
 };

Quote:
};



Tue, 03 May 2005 23:28:15 GMT  
 Use of importlib
move the declaration of IApxObject2 inside the library
after "importlib("..\ApxComponent1\ApxComponent1.tlb");"

Quote:
>-----Original Message-----
>Hi,
>Here is my problem:

>I have two ATL DLLs: ApxComponent1.dll and
ApxComponent2.dll.
>The first one defines the simple COM object ApxObject1,
and
>an ApxEnum1 enum.
>The second one defines the simple COM Object ApxObject2.

>ApxObject2 has a method taking an IApxObject1*, and an
>ApxEnum1 as parameters.

>I did not manage to compile ApxComponent2.idl without
>importing "ApxComponent2.idl" at the beginning of the
file:
>if I just use importlib in the "library" section I get
>this error message:
> error MIDL2011 : unresolved type declaration :
IApxObject1 ....

>I would prefer to use importlib because when I use
>import, I end up with ApxEnum1 defined in the two type
>libraries.

>How can I do ?

>Thanks.
>Chris.

>Here are the IDL files:

>import "oaidl.idl";
>import "ocidl.idl";
> [
>  object,
>  uuid(15E6ABEF-7457-418D-BCC2-4B6D8F062E88),
>  dual,
>  helpstring("IApxObject1 Interface"),
>  pointer_default(unique)
> ]
> interface IApxObject1 : IDispatch
> {
>  [id(1), helpstring("method ShowEnum")] HRESULT ShowEnum
(enum ApxEnum1
>enumValue);
> };

>[
> uuid(4AA9EB6C-7BBF-4B50-908B-4CD12A51F23D),
> version(1.0),
> helpstring("ApxComponent1 1.0 Type Library")
>]
>library APXCOMPONENT1Lib
>{
> importlib("stdole32.tlb");
> importlib("stdole2.tlb");

> typedef [uuid(53D4C1A4-AE90-4e9e-809C-740CF74126C9),
>    public,
>    v1_enum,
>    helpstring("ApxEnum1 constants")]
> enum ApxEnum1
> {
>  [helpstring("e1One")] e1One  = 1,
>  [helpstring("e1Two")] e1Two  = 2
> } ApxEnum1  ;

> [
>  uuid(35E2F748-A31D-4980-9E3A-D11F309081BB),
>  helpstring("ApxObject1 Class")
> ]
> coclass ApxObject1
> {
>  [default] interface IApxObject1;
> };
>};

>import "oaidl.idl";
>import "ocidl.idl";

> interface IApxObject1 ;

> [
>  object,
>  uuid(2B3EA56F-E793-4D68-9D58-59D9C15DC5F3),
>  dual,
>  helpstring("IApxObject2 Interface"),
>  pointer_default(unique)
> ]
> interface IApxObject2 : IDispatch
> {
>  [id(1), helpstring("method SetEnum")] HRESULT SetEnum
([in] IApxObject1*
>pObj, [in] enum ApxEnum1 enumValue);
> };

>[
> uuid(1AD2B362-2449-4CBC-B5EF-273F86401BAB),
> version(1.0),
> helpstring("ApxComponent2 1.0 Type Library")
>]
>library APXCOMPONENT2Lib
>{
> importlib("stdole32.tlb");
> importlib("stdole2.tlb");
> importlib("..\ApxComponent1\ApxComponent1.tlb");

> [
>  uuid(E733F587-4750-472F-888C-B0692A8F7112),
>  helpstring("ApxObject2 Class")
> ]
> coclass ApxObject2
> {
>  [default] interface IApxObject2;
> };
>};

>.



Tue, 03 May 2005 23:48:44 GMT  
 Use of importlib

Quote:
> move the declaration of IApxObject2 inside the library
> after "importlib("..\ApxComponent1\ApxComponent1.tlb");"

OK. The idl file compiles now, but I now get an error when it compiles
ApxComponent2.cpp:
    error C2061: syntax error : identifier 'IApxObject1'

(the code on which it is complaining is:
    MIDL_INTERFACE("2B3EA56F-E793-4D68-9D58-59D9C15DC5F3")
    IApxObject2 : public IDispatch
    {
    public:
        virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE
Enum(
            /* [in] */ /* external definition not present */ IApxObject1 __RPC_FAR *pObj,
            /* [in] */ enum /* external definition not present */ ApxEnum1 enumValue) = 0;

    };
)



Wed, 04 May 2005 00:18:12 GMT  
 Use of importlib
try
#import "libid:IApxObject1LIBraryLIBID" no_namespace

Quote:
>-----Original Message-----

>> move the declaration of IApxObject2 inside the library
>> after "importlib("..\ApxComponent1\ApxComponent1.tlb");"

>OK. The idl file compiles now, but I now get an error
when it compiles
>ApxComponent2.cpp:
>    error C2061: syntax error : identifier 'IApxObject1'

>(the code on which it is complaining is:
>    MIDL_INTERFACE("2B3EA56F-E793-4D68-9D58-59D9C15DC5F3")
>    IApxObject2 : public IDispatch
>    {
>    public:
>        virtual /* [helpstring][id] */ HRESULT
STDMETHODCALLTYPE
>Enum(
>            /* [in] */ /* external definition not present

*/ IApxObject1 __RPC_FAR *pObj,
Quote:
>            /* [in] */ enum /* external definition not

present */ ApxEnum1 enumValue) = 0;

- Show quoted text -

Quote:

>    };
>)

>.



Wed, 04 May 2005 05:24:37 GMT  
 Use of importlib

Quote:
> try
> #import "libid:IApxObject1LIBraryLIBID" no_namespace

All I get is :

fatal error C1083: Cannot open type library file:
'libid:IApxObject1LIBraryLIBID': No such file or directory

Where would you insert this line and what is the meaning of
libid:IApxObject1LIBraryLIBID ?

Chris.



Fri, 06 May 2005 17:36:50 GMT  
 Use of importlib
 >I would prefer to use importlib because when I use

Quote:
>import, I end up with ApxEnum1 defined in the two type
>libraries.

You can use #import with exclude  option to prevent inclusion of a type in
the tlh file.

Hope this helps.

Thank you,
Bobby Mattappally
Microsoft VC++/C# Team

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Quote:

>Subject: Use of importlib
>Date: Fri, 15 Nov 2002 16:28:15 +0100
>Lines: 117
>X-Priority: 3
>Hi,
>Here is my problem:

>I have two ATL DLLs: ApxComponent1.dll and ApxComponent2.dll.
>The first one defines the simple COM object ApxObject1, and
>an ApxEnum1 enum.
>The second one defines the simple COM Object ApxObject2.

>ApxObject2 has a method taking an IApxObject1*, and an
>ApxEnum1 as parameters.

>I did not manage to compile ApxComponent2.idl without
>importing "ApxComponent2.idl" at the beginning of the file:
>if I just use importlib in the "library" section I get
>this error message:
> error MIDL2011 : unresolved type declaration : IApxObject1 ....

>I would prefer to use importlib because when I use
>import, I end up with ApxEnum1 defined in the two type
>libraries.

>How can I do ?

>Thanks.
>Chris.

>Here are the IDL files:

>import "oaidl.idl";
>import "ocidl.idl";
> [
>  object,
>  uuid(15E6ABEF-7457-418D-BCC2-4B6D8F062E88),
>  dual,
>  helpstring("IApxObject1 Interface"),
>  pointer_default(unique)
> ]
> interface IApxObject1 : IDispatch
> {
>  [id(1), helpstring("method ShowEnum")] HRESULT ShowEnum(enum ApxEnum1
>enumValue);
> };

>[
> uuid(4AA9EB6C-7BBF-4B50-908B-4CD12A51F23D),
> version(1.0),
> helpstring("ApxComponent1 1.0 Type Library")
>]
>library APXCOMPONENT1Lib
>{
> importlib("stdole32.tlb");
> importlib("stdole2.tlb");

> typedef [uuid(53D4C1A4-AE90-4e9e-809C-740CF74126C9),
>    public,
>    v1_enum,
>    helpstring("ApxEnum1 constants")]
> enum ApxEnum1
> {
>  [helpstring("e1One")] e1One  = 1,
>  [helpstring("e1Two")] e1Two  = 2
> } ApxEnum1  ;

> [
>  uuid(35E2F748-A31D-4980-9E3A-D11F309081BB),
>  helpstring("ApxObject1 Class")
> ]
> coclass ApxObject1
> {
>  [default] interface IApxObject1;
> };
>};

>import "oaidl.idl";
>import "ocidl.idl";

> interface IApxObject1 ;

> [
>  object,
>  uuid(2B3EA56F-E793-4D68-9D58-59D9C15DC5F3),
>  dual,
>  helpstring("IApxObject2 Interface"),
>  pointer_default(unique)
> ]
> interface IApxObject2 : IDispatch
> {
>  [id(1), helpstring("method SetEnum")] HRESULT SetEnum([in] IApxObject1*
>pObj, [in] enum ApxEnum1 enumValue);
> };

>[
> uuid(1AD2B362-2449-4CBC-B5EF-273F86401BAB),
> version(1.0),
> helpstring("ApxComponent2 1.0 Type Library")
>]
>library APXCOMPONENT2Lib
>{
> importlib("stdole32.tlb");
> importlib("stdole2.tlb");
> importlib("..\ApxComponent1\ApxComponent1.tlb");

> [
>  uuid(E733F587-4750-472F-888C-B0692A8F7112),
>  helpstring("ApxObject2 Class")
> ]
> coclass ApxObject2
> {
>  [default] interface IApxObject2;
> };
>};



Sat, 07 May 2005 03:25:55 GMT  
 Use of importlib


Fri, 19 Jun 1992 00:00:00 GMT  
 Use of importlib
Alex,

That is so cool - does this work in VC6?

I read on MSDN that all formats understood by LoadTypeLib can be #import:ed.
Does that include custom monikers, which I assume is the case here?

Thanks,

--
Kim Gr?sman
Microsoft MVP - Visual C++
http://www.winwonk.com


Quote:
> try
> #import "libid:IApxObject1LIBraryLIBID" no_namespace



Sat, 07 May 2005 04:54:41 GMT  
 Use of importlib


Fri, 19 Jun 1992 00:00:00 GMT  
 Use of importlib
Try the real libid value instead of the name  IApxObject1LIBraryLIBID:

#import "libid:12341234-1234-1234-1234-123412341234"

#import is a C++ compiler pre-processor directive, so you have to put it in
a cpp file.

Please see below for more info:
The #import Directive
http://msdn.microsoft.com/library/en-us/vclang/html/_predir_The_.23.i...
irective.asp

Hope this helps.

Thank you,
Bobby Mattappally
Microsoft VC++/C# Team

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------



Quote:
>Subject: Re: Use of importlib
>Date: Mon, 18 Nov 2002 10:36:50 +0100

>> try
>> #import "libid:IApxObject1LIBraryLIBID" no_namespace

>All I get is :

>fatal error C1083: Cannot open type library file:
>'libid:IApxObject1LIBraryLIBID': No such file or directory

>Where would you insert this line and what is the meaning of
>libid:IApxObject1LIBraryLIBID ?

>Chris.



Sun, 08 May 2005 08:24:52 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. HELP Using Enums through importlib???

2. i can't use types from another tlb using importlib

3. MIDL namespace problems using importlib

4. Using importlib in an IDL file?

5. VC++ 7 / ATL / importlib / msxml4

6. Difference in #import, #importlib, #include

7. importlib problem with Visual C++ 6

8. ATL, importlib attribute, library attribute, ADO

9. VC++ 7 / ATL / importlib / msxml4

10. importlib does not import enum type

11. How to importlib msvbvm60.dll\3

12. importlib "stdole32.tlb":???

 

 
Powered by phpBB® Forum Software