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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. COM
  4. create the com-object from the exe-server

create the com-object from the exe-server

Scheduled Pinned Locked Moved COM
questionc++comsysadmin
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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Maybe this question is same to the last .Could anyone explain it to me? ::CoInitialize(NULL); ISomeInterfacePtr ppv; ppv.CreateInstance("MYSERVER.SOMEINTERFACE.1"); ppv->SomeFunction(); The code can be successful if the com object is in a dll .But failed when the com object is in the exe-server . I used ATL to create the exe-server project . Do I need to add additional codes if it is created as an exe?

    L 1 Reply Last reply
    0
    • L Lost User

      Maybe this question is same to the last .Could anyone explain it to me? ::CoInitialize(NULL); ISomeInterfacePtr ppv; ppv.CreateInstance("MYSERVER.SOMEINTERFACE.1"); ppv->SomeFunction(); The code can be successful if the com object is in a dll .But failed when the com object is in the exe-server . I used ATL to create the exe-server project . Do I need to add additional codes if it is created as an exe?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      What is the error code when the object is in the exe-server? Did you register the proxy/stub for the exe server?

      L 1 Reply Last reply
      0
      • L Lost User

        What is the error code when the object is in the exe-server? Did you register the proxy/stub for the exe server?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Thanks a lot . As I have no materials at hand now, I don't know what the error code means,which is a negative number . But what do you mean that the proxy/stub need to be registered ? After I compile and link the source code , the VC has helped me to register the exe-server . I tried to create a dual interface in this Atl project ,and I found that I can use it in the client code . But if the interface was an custom interface which means it inherits from the IUnknown ,not IDispatch , I found the problem I posted last time . Why?

        L P 2 Replies Last reply
        0
        • L Lost User

          Thanks a lot . As I have no materials at hand now, I don't know what the error code means,which is a negative number . But what do you mean that the proxy/stub need to be registered ? After I compile and link the source code , the VC has helped me to register the exe-server . I tried to create a dual interface in this Atl project ,and I found that I can use it in the client code . But if the interface was an custom interface which means it inherits from the IUnknown ,not IDispatch , I found the problem I posted last time . Why?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          For dual interfaces COM can use Automation(aka Unversal) marshaller and there is no need for separate proxy/stub dll. If you have custom interfaces and expect to the marshalling to be envolved (call the object methods from another apartment, in case of out-of-proc object this is always true), than you need to build and register proxy/stub dll. IDL compiler generates all necessary files for that and ATL wizard creates .def & makefile to build it (ps.def and ps.mk. Edward

          1 Reply Last reply
          0
          • L Lost User

            Thanks a lot . As I have no materials at hand now, I don't know what the error code means,which is a negative number . But what do you mean that the proxy/stub need to be registered ? After I compile and link the source code , the VC has helped me to register the exe-server . I tried to create a dual interface in this Atl project ,and I found that I can use it in the client code . But if the interface was an custom interface which means it inherits from the IUnknown ,not IDispatch , I found the problem I posted last time . Why?

            P Offline
            P Offline
            Pros Chum
            wrote on last edited by
            #5

            If selected to create a custom interface, you'll need to register the proxy server marshalling dll for your EXE COM server. Look at the file with the WinMain(), Unlock(), and Monitor() functions that SCM uses to startup your COM server. At the top of the file you'll see some comments that look like this: // Note: Proxy/Stub Information // To build a separate proxy/stub DLL, // run nmake -f [Your EXE name here]ps.mk in the project directory. Just do what it says. (NOTE: You may need to run vcvars32.bat in your VC directory to setup the paths to nmake and stuff.) After doing that you should have a proxy/server marshalling DLL file. You'll also need to register the DLL: regsvr32 [The newly created proxy/server]ps.dll A way to automate this is to put it in your Project | Settings under the "Post-Build Step": nmake /f MyComponent.mk regsvr32 /c /s MyComponenetps.dll - Pros

            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