How to declare enum using attribute in VC++ .Net?

W

Woon Kiat Wong

Hi,

Using IDL, I can declare my enumeration like following,

library MyAppLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");

typedef enum MyColor
{
ORANGE = 1,
RED = 2
} MyColor;

}

COM compatible client like VB can use the enum from their application
when import this library. How can I achieve the same thing in Visual
C++ .Net using attribute? I have tried [export] and [v1_enum], but the
enum is only exported to IDL like following

typedef enum MyColor
{
ORANGE = 1,
RED = 2

} MyColor;

library MyAppLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");

........

}

I need the enum to be in the library section. Anyone knows how to solve
this?

regards,
Woon Kiat
 
R

Rodrigo Corral [MVP]

Here you have an example. This code is working for me in and ATL Attributed
project.
Tell us if it works or not.

[
export,
uuid("CCA6D17A-17F9-47d2-86AD-DB64B273B5C1"),
helpstring("MsgType"),
library_block
]
enum eMsgType
{
mtA = 1,
mtB = 2,
mtC = 3,
mtD = 4
}


--
Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top