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. Declare shared function in com (vc++)

Declare shared function in com (vc++)

Scheduled Pinned Locked Moved COM
c++comquestion
9 Posts 5 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.
  • P Offline
    P Offline
    Pop Cristian
    wrote on last edited by
    #1

    How should declare function in COM (vc++) in order to be seen as shared in vb (no instance object needed for function call)? thx

    J _ P G 4 Replies Last reply
    0
    • P Pop Cristian

      How should declare function in COM (vc++) in order to be seen as shared in vb (no instance object needed for function call)? thx

      J Offline
      J Offline
      Jonathan Davies
      wrote on last edited by
      #2

      As far as I know you can't. COM is all about creating object then calling functions those object provide (via interfaces). You could call a VB Shared method and within that method create a new COM object, call its function then delete it - all within the Shared VB. On the other hand perhaps using a Shared may not be the only way to do what you want.

      P 1 Reply Last reply
      0
      • J Jonathan Davies

        As far as I know you can't. COM is all about creating object then calling functions those object provide (via interfaces). You could call a VB Shared method and within that method create a new COM object, call its function then delete it - all within the Shared VB. On the other hand perhaps using a Shared may not be the only way to do what you want.

        P Offline
        P Offline
        Pop Cristian
        wrote on last edited by
        #3

        Shared vb function than creates an instance of my class, calls function (static one) then delete that object is a good solution, but not a perfect one. Was thinking perhaps there is a keyword that will expose function the way I want If you can tell me what's the other way arround please let me know thx

        J 1 Reply Last reply
        0
        • P Pop Cristian

          Shared vb function than creates an instance of my class, calls function (static one) then delete that object is a good solution, but not a perfect one. Was thinking perhaps there is a keyword that will expose function the way I want If you can tell me what's the other way arround please let me know thx

          J Offline
          J Offline
          Jonathan Davies
          wrote on last edited by
          #4

          Sorry, I haven't got another way exactly. What I meant was that when using VB you tend to get used to the things VB lets you do and use - such as using Shared. With COM you have to think more in terms of objects and interfaces and so you tend to design solutions around them.

          P 1 Reply Last reply
          0
          • J Jonathan Davies

            Sorry, I haven't got another way exactly. What I meant was that when using VB you tend to get used to the things VB lets you do and use - such as using Shared. With COM you have to think more in terms of objects and interfaces and so you tend to design solutions around them.

            P Offline
            P Offline
            Pop Cristian
            wrote on last edited by
            #5

            Static functions from c++ are equivalent to shared from VB; was thinking there is a way to just expose this static functions; if there isn't will just have to call code in vb common way, using object thx

            1 Reply Last reply
            0
            • P Pop Cristian

              How should declare function in COM (vc++) in order to be seen as shared in vb (no instance object needed for function call)? thx

              _ Offline
              _ Offline
              _Superman_
              wrote on last edited by
              #6

              COM exposes interfaces and not methods. According to your requirement, you want to expose a static method. That is not COM.

              «_Superman_»

              1 Reply Last reply
              0
              • P Pop Cristian

                How should declare function in COM (vc++) in order to be seen as shared in vb (no instance object needed for function call)? thx

                P Offline
                P Offline
                prasad_som
                wrote on last edited by
                #7

                Pop Cristian wrote:

                no instance object needed for function call

                I'm not sure about your requirement, but C++ dll,with exposed methods can be used in VB. As far as COM is concerned, it talks thorugh interfaces(so you need object) only.

                1 Reply Last reply
                0
                • P Pop Cristian

                  How should declare function in COM (vc++) in order to be seen as shared in vb (no instance object needed for function call)? thx

                  G Offline
                  G Offline
                  guestcat
                  wrote on last edited by
                  #8

                  Hi, I guess you need to be more clear with your requirements. else you drop in such situation. you could full fill your requirement by exposing c++ static methods. what makes to do this thru COM. COM is full if dynamic bindings. and VB shared stuff is full of static things that are decided at compilation.....

                  ^-^ @|@ - redCat

                  P 1 Reply Last reply
                  0
                  • G guestcat

                    Hi, I guess you need to be more clear with your requirements. else you drop in such situation. you could full fill your requirement by exposing c++ static methods. what makes to do this thru COM. COM is full if dynamic bindings. and VB shared stuff is full of static things that are decided at compilation.....

                    ^-^ @|@ - redCat

                    P Offline
                    P Offline
                    Pop Cristian
                    wrote on last edited by
                    #9

                    I have lots of structures/classes in my library, so I need to be COM; there is no specific requirement, all I needed was just a fancy way of exposing / calling a static vc function; I have now in c code, CMyClass::DoThis(param1, param2), so no need to create new object in c for this; I'll just create a new object in vb, call my function and discard object afterwards Was thinking in vb I could've have CMyClass.DoThis(param1, param2) instead of dim c as new CMyClass c.DoThis(param1, paramt) thx

                    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