Code Monkey home page Code Monkey logo

outofprocesscomserver's Introduction

OutOfProcessCOMServer

An ATL C++ Out-Of-Process COM server and clients (C++, .NET, VBscript) sample.

The OutOfProcessCOMServer project is the COM server executable. It has been created using Visual Studio's ATL wizard and an "ATL Simple Object" item has been added (renamed as "Mouse").

Key points:

  • The IMouse dual (IUnknown-derived + IDispatch) interface methods were added manually.
  • The IKeyboard IUnknown-derived interface was added manually in OutOfProcessCOMServer.idl and was also added to the list of interfaces the CMouse class implements (in Mouse.h). For demonstration purposes, IKeyboard uses a non-OLE-automation type (the Windows LPCWSTR type), which needs proper marshaling.
  • Both IMouse and IKeyboard have been simply implemented (in Mouse.h).
  • Building (MIDL) create (among other files) a OutOfProcessCOMServer.tlb (Type Library) file needed for the .NET client.
  • Self-registration was removed from config so Visual Studio doesn't need to run as admin.
  • The server starts and shutdowns automatically (ATL does that).
  • It must be registered (with admin rights) with OutOfProcessCOMServer.exe /regserver.
  • It can be unregistered (with admin rights) with OutOfProcessCOMServer.exe /unregserver.

The OutOfProcessCOMServerPS project is the Proxy/Stub dll for the OutOfProcessCOMServer COM server. It's only needed for the IKeyboard interface which is an IUnknown-derived interface (not IDispatch, not dual) which needs to be proxied and marshaled since it's not dual nor OLE-Automation and not using OLE-Automation compatible types. When using only interfaces like IMouse, this project is not needed at all.

Key points:

  • It has not been created by Visual Studio automatically, the project was created from an empty DLL project.

  • it references ATL-generated files xdlldata.c, xdlldata.h, OutOfProcessCOMServer_i.c, OutOfProcessCOMServer_p.c from the OutOfProcessCOMServer project.

  • the OutOfProcessCOMServerPS.def file has been added manually to export standard COM functions so the DLL can be registered/unregistered.

  • It must be registered (with admin rights) with regsvr32 OutOfProcessCOMServerPS.dll

  • It can be unregistered (with admin rights) with regsvr32 /u OutOfProcessCOMServerPS.dll

The Client project is a C++ client (using ATL). It includes OutOfProcessCOMServer project's MIDL-generated files for IIDs and CLSIDs definitions.

The NetCoreClient project is a .NET 7.0 client project. It references the .TLB (by it's LIBID so it must exist before this project can compile) generated by OutOfProcessCOMServer project's MIDL pass. It can access IMouse and IKeyboard.

The VBScriptClient.vbs is a VBScript file. It can only access IMouse since VBScript only supports OLE-Automation interfaces.

outofprocesscomserver's People

Contributors

smourier avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.