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. Can somebody please answer this?

Can somebody please answer this?

Scheduled Pinned Locked Moved COM
comquestionwindows-adminhelptutorial
6 Posts 3 Posters 1 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.
  • J Offline
    J Offline
    JohnnyG
    wrote on last edited by
    #1

    Ok. I'm trying to use a COM OCX object in a C program. I've done some research and found out how to call and instantiate a COM object from C. However, I do not know how to generate a header file for object type or interface declarations. SOPTEST replied with some useful info but all I can find out is info on how to develop a COM object using C and not how to use an existing one that is already in the registry that I didn't develop. I want to use MSCOMM32.OCX in a C program. How do I get the declaration for the IMSComm and other interfaces? I know how to get the IUknown interface, call QueryInterface, etc. And, I know that getting an interface pointer is really a void** so I could create a void pointer and call it anything I like and use it but that doesn't seem right or is it???? I've learned how to view the typelib, CLASSID, etc. from OLE/COM Object viewer so I don't think I'm an idiot, I just need some help. Is there someway of interpreting the type library and converting it into a header file that I am not aware of? Anybody??

    S S 2 Replies Last reply
    0
    • J JohnnyG

      Ok. I'm trying to use a COM OCX object in a C program. I've done some research and found out how to call and instantiate a COM object from C. However, I do not know how to generate a header file for object type or interface declarations. SOPTEST replied with some useful info but all I can find out is info on how to develop a COM object using C and not how to use an existing one that is already in the registry that I didn't develop. I want to use MSCOMM32.OCX in a C program. How do I get the declaration for the IMSComm and other interfaces? I know how to get the IUknown interface, call QueryInterface, etc. And, I know that getting an interface pointer is really a void** so I could create a void pointer and call it anything I like and use it but that doesn't seem right or is it???? I've learned how to view the typelib, CLASSID, etc. from OLE/COM Object viewer so I don't think I'm an idiot, I just need some help. Is there someway of interpreting the type library and converting it into a header file that I am not aware of? Anybody??

      S Offline
      S Offline
      soptest
      wrote on last edited by
      #2

      Use "oleview" to open type library. From "File" menu you can "Save as" *.IDL, *.H or *.C file. If you save it as *.IDL file then compile it with MIDL compiler to generate proxy/stub files. soptest

      J 2 Replies Last reply
      0
      • J JohnnyG

        Ok. I'm trying to use a COM OCX object in a C program. I've done some research and found out how to call and instantiate a COM object from C. However, I do not know how to generate a header file for object type or interface declarations. SOPTEST replied with some useful info but all I can find out is info on how to develop a COM object using C and not how to use an existing one that is already in the registry that I didn't develop. I want to use MSCOMM32.OCX in a C program. How do I get the declaration for the IMSComm and other interfaces? I know how to get the IUknown interface, call QueryInterface, etc. And, I know that getting an interface pointer is really a void** so I could create a void pointer and call it anything I like and use it but that doesn't seem right or is it???? I've learned how to view the typelib, CLASSID, etc. from OLE/COM Object viewer so I don't think I'm an idiot, I just need some help. Is there someway of interpreting the type library and converting it into a header file that I am not aware of? Anybody??

        S Offline
        S Offline
        Stuart Dootson
        wrote on last edited by
        #3

        If you're using MSVC++ (and what else would you be using :) !!), you can use '#import' to import COM objects. This will generate the required header files automatically when you compile the code. The one pain is that (with VC6, but not VC.NET, IIRC) you need to enter an absolute path to the DLL or OCX or whatever. (I've just looked it up - VC++NET lets you use a progid to say what class you want). MSDN (the one you get with VC++) should hopefully have enough info to get you started. Just one thing - by default, VC++ will generate wrappers for the COM class - this may not be what you want. Stuart Dootson 'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'

        S 1 Reply Last reply
        0
        • S Stuart Dootson

          If you're using MSVC++ (and what else would you be using :) !!), you can use '#import' to import COM objects. This will generate the required header files automatically when you compile the code. The one pain is that (with VC6, but not VC.NET, IIRC) you need to enter an absolute path to the DLL or OCX or whatever. (I've just looked it up - VC++NET lets you use a progid to say what class you want). MSDN (the one you get with VC++) should hopefully have enough info to get you started. Just one thing - by default, VC++ will generate wrappers for the COM class - this may not be what you want. Stuart Dootson 'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          Whoops - just read your message properly - you say you're using C, as opposed to C++, so this may have been of no use whatsoever :( Stuart Dootson 'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'

          1 Reply Last reply
          0
          • S soptest

            Use "oleview" to open type library. From "File" menu you can "Save as" *.IDL, *.H or *.C file. If you save it as *.IDL file then compile it with MIDL compiler to generate proxy/stub files. soptest

            J Offline
            J Offline
            JohnnyG
            wrote on last edited by
            #5

            I used "oleview". I did not know you could save .c or .h files from there but when I tried, it didn't work. Apparently, it uses a console window but the error happens so fast and the console window closes before I can see it. However, I was able to save the .idl file. But, going from using VC++ before with Add To Project | Components and Controls that generates all C++ wrapper classes and as you say proxy/stub files for out of process.

            1 Reply Last reply
            0
            • S soptest

              Use "oleview" to open type library. From "File" menu you can "Save as" *.IDL, *.H or *.C file. If you save it as *.IDL file then compile it with MIDL compiler to generate proxy/stub files. soptest

              J Offline
              J Offline
              JohnnyG
              wrote on last edited by
              #6

              I think I got it now. I was finally able to save a .c and .h files to the default directory (system32). I still got warnings or errors but I couldn't tell what they were. Looking at the contents it has the proper extern "C" declarations :laugh: Cool! Thanks again, SOPTEST

              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