Another alternative is to place the declaration of the Enum within a Type Library.
The pre-requisites of this approach are that you will need a utility like MKTYPLIB.EXE or MIDL.EXE that will be used to compile the TLB file from an ODL file. You will also need to generate a GUID, like GUIDGEN.EXE.
Then create an ASCII text file that contains the ODL syntax.
Example:
Code:
//The UUID is the GUID. The one below is just an example.
//The HELPSTRING is the description that shows up in the References dialog box in VB
//The LCID specifies the Local ID
// NOTE: 0x00000000 indicates that the type library is not locale specific.
//The VERSION is the version of the type library.
[
uuid(00000000-0000-0000-0000-000000000000),
helpstring("This Is My Type Library"),
lcid(0x00000000),
version(1.0)
]
library MyTypLib {
// My enumerator
// Each HELPSTRING below will show up in the Object Browser
typedef
[ helpstring("This enumerator is for the purpose of _.") ]
enum {
[ helpstring("This element of the enum is for the purpose of _.") ]
Element1 = 0,
[ helpstring("This element of the enum is for the purpose of _.") ]
Element2 = 1,
[ helpstring("This element of the enum is for the purpose of _.") ]
Element3 = 2
} MyEnum;
}
Save the file as SOMETHING.ODL and then compile it using one of the utilities mentioned above.
Example (from command prompt).
Code:
C:\Path\To\MkTypLib\mktyplib.exe /nocpp /nologo /o MakeLib.log /tlb C:\WINDOWS\SYSTEM32\MYTYPLIB.tlb SOMETHING.ODL
// /nocpp indicates that the C Pre-Processor will not be used.
// /nologo indicates that MKTYPLIB will not display is name and version in the command prompt when ran.
// /o indicates the Log file that will be used to record either success or an error message.
// /tlb specifies the path and filename of the TLB to be generated.
You can then add a reference to the type library to any project. The first time you add a reference to it, you will need to "browse" to select the library. After that, it should just appear as a selectable entry in you list of references.