Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Exporting enum types to a COM DLL

Exporting enum types to a COM DLL

Scheduled Pinned Locked Moved COM
csharpc++visual-studiocomhardware
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Robert Ernst
    wrote on last edited by
    #1

    Hi I'm very new to the Windows/COM development environment (coming from embedded/Unix). I'd like to create a COM/DLL (using C++) that contains and exports an enum type. I want the enum type to show up in the Visual Studio Object browser after I add the DLL to the "References" folder in the client application. I've used "[export]" before the enum in the header file. I've also tried including the header file in the serverdll.idl file. So far the enum hasn't showed up in the Object Browser. Any help or suggestions would be appriciated. Thanks Robert Ernst codeproject@theernsts.org

    L 1 Reply Last reply
    0
    • R Robert Ernst

      Hi I'm very new to the Windows/COM development environment (coming from embedded/Unix). I'd like to create a COM/DLL (using C++) that contains and exports an enum type. I want the enum type to show up in the Visual Studio Object browser after I add the DLL to the "References" folder in the client application. I've used "[export]" before the enum in the header file. I've also tried including the header file in the serverdll.idl file. So far the enum hasn't showed up in the Object Browser. Any help or suggestions would be appriciated. Thanks Robert Ernst codeproject@theernsts.org

      L Offline
      L Offline
      Laxman Auti
      wrote on last edited by
      #2

      open the .idl file of the interface put the definition of the enum inside the Library after the definition of the coclass as follows typedef enum tagEchoType { EchoTypeHelloWorld = 0, EchoTypeGoodbyeWorld = 1 } EchoType; thats enough Knock out 't' from can't, You can if you think you can :cool: -- modified at 1:54 Friday 19th May, 2006

      R 1 Reply Last reply
      0
      • L Laxman Auti

        open the .idl file of the interface put the definition of the enum inside the Library after the definition of the coclass as follows typedef enum tagEchoType { EchoTypeHelloWorld = 0, EchoTypeGoodbyeWorld = 1 } EchoType; thats enough Knock out 't' from can't, You can if you think you can :cool: -- modified at 1:54 Friday 19th May, 2006

        R Offline
        R Offline
        Robert Ernst
        wrote on last edited by
        #3

        I've tried placing the enum in the .idl file, but the type still doesn't show up in the DLL, based on browsing with the Object Viewer I've inserted the enum in the .idl file both manually, and using attributes: So I have: File: employee.cpp #include [ module(dll, name = "TestEmployee", helpstring = "TestEmployee 1.0 Type Library") ]; [ emitidl ]; [dual] __interface IEmployee : IDispatch { [id(1)] HRESULT DoWork(BSTR bstrTask); }; [export] enum Status {EMPLOYEED, UNEMPLOYEED} Status_t; File:employee.idl ... [ uuid(38884C05-8FF2-3A53-83D3-837E34D61785), dual ] #line 27 "c:\\samples\\com\\employee.cpp" interface IEmployee : IDispatch { #line 29 "c:\\samples\\com\\employee.cpp" [id(1)] HRESULT DoWork([in]BSTR bstrTask); }; #line 33 "c:\\samples\\com\\employee.cpp" enum Status { EMPLOYEED = 0, UNEMPLOYEED = 1, }; The linker command is: cl employee.cpp /LD /link /IDLOUT:employee.idl Am I missing something in the Linker command? Thanks Robert Ernst

        L 1 Reply Last reply
        0
        • R Robert Ernst

          I've tried placing the enum in the .idl file, but the type still doesn't show up in the DLL, based on browsing with the Object Viewer I've inserted the enum in the .idl file both manually, and using attributes: So I have: File: employee.cpp #include [ module(dll, name = "TestEmployee", helpstring = "TestEmployee 1.0 Type Library") ]; [ emitidl ]; [dual] __interface IEmployee : IDispatch { [id(1)] HRESULT DoWork(BSTR bstrTask); }; [export] enum Status {EMPLOYEED, UNEMPLOYEED} Status_t; File:employee.idl ... [ uuid(38884C05-8FF2-3A53-83D3-837E34D61785), dual ] #line 27 "c:\\samples\\com\\employee.cpp" interface IEmployee : IDispatch { #line 29 "c:\\samples\\com\\employee.cpp" [id(1)] HRESULT DoWork([in]BSTR bstrTask); }; #line 33 "c:\\samples\\com\\employee.cpp" enum Status { EMPLOYEED = 0, UNEMPLOYEED = 1, }; The linker command is: cl employee.cpp /LD /link /IDLOUT:employee.idl Am I missing something in the Linker command? Thanks Robert Ernst

          L Offline
          L Offline
          Laxman Auti
          wrote on last edited by
          #4

          Robert Ernst wrote:

          I've tried placing the enum in the .idl file, but the type still doesn't show up in the DLL, based on browsing with the Object Viewer

          The following code is generated by the Application wizard of the ATL COM Componenet. I am simply added the enum inside the code is works fine. I have tested under VB6.0 and VC++6.0 Object Browser

          import "oaidl.idl";
          import "ocidl.idl";
          [
          object,
          uuid(7CB363A8-69EB-48BE-9E20-BD1B5CC87F76),
          dual,
          helpstring("Itest Interface"),
          pointer_default(unique)
          ]
          interface Itest : IDispatch
          {
          };

          [
          uuid(8D40959D-E348-4220-971A-61CA27F53C45),
          version(1.0),
          helpstring("test11 1.0 Type Library")
          ]
          library TEST11Lib
          {
          importlib("stdole32.tlb");
          importlib("stdole2.tlb");

          \[
          	uuid(8F71F9BF-8982-4804-A22C-FA3A7E7C225C),
          	helpstring("test Class")
          \]
          coclass test
          {
          	\[default\] interface Itest;
          };
          typedef enum tagTestEnum
          {
          	Bad=0,
          	Good=1
          }TestEnum;
          

          };

          Hope this code helps you Knock out 't' from can't, You can if you think you can :cool:

          R 1 Reply Last reply
          0
          • L Laxman Auti

            Robert Ernst wrote:

            I've tried placing the enum in the .idl file, but the type still doesn't show up in the DLL, based on browsing with the Object Viewer

            The following code is generated by the Application wizard of the ATL COM Componenet. I am simply added the enum inside the code is works fine. I have tested under VB6.0 and VC++6.0 Object Browser

            import "oaidl.idl";
            import "ocidl.idl";
            [
            object,
            uuid(7CB363A8-69EB-48BE-9E20-BD1B5CC87F76),
            dual,
            helpstring("Itest Interface"),
            pointer_default(unique)
            ]
            interface Itest : IDispatch
            {
            };

            [
            uuid(8D40959D-E348-4220-971A-61CA27F53C45),
            version(1.0),
            helpstring("test11 1.0 Type Library")
            ]
            library TEST11Lib
            {
            importlib("stdole32.tlb");
            importlib("stdole2.tlb");

            \[
            	uuid(8F71F9BF-8982-4804-A22C-FA3A7E7C225C),
            	helpstring("test Class")
            \]
            coclass test
            {
            	\[default\] interface Itest;
            };
            typedef enum tagTestEnum
            {
            	Bad=0,
            	Good=1
            }TestEnum;
            

            };

            Hope this code helps you Knock out 't' from can't, You can if you think you can :cool:

            R Offline
            R Offline
            Robert Ernst
            wrote on last edited by
            #5

            BINGO!! That was it. My enum definition wasn't inside the library TEST11Lib {} declaration. Once I placed it inside the library {} block it worked. Thanks so much for your help! Robert Ernst codeproject@theernsts.org

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups