C U T B H P N

Lecture #6 - COM: Introduction to In-Process Components

Web Resources:

Linux Tutorials eclipse Code Project SysInternals Best SysInternals Tools Dr. Dobb's Journal Windows Forms COM at MSDN IDL Language base MIDL types IDL attributes MIDL Language Reference

Content:

In this lecture we begin discussing in-process COM components.
  1. Syllabus
    Describes topics to be covered, reading material for you to digest before coming to class, and due dates for the assigned projects.
  2. Projects:

  3. Microsoft Connect Conference 2018
  4. Microsoft Component Object Model (COM):

  5. Building COM Projects:

    Building COM projects is a little more complicated than building console or straight Windows applications. Here are some guidelines:
  6. Build Issues due to Microsoft updates
    • Old ATL projects will probably fail to build because the stdafx.h file has out-of-date Windows version Definitions. You should set these definitions:
      #define WINVER 0x0601
      #define _WIN32_WINNT 0x0601
      #define _WIN32_WINDOWS 0x0601
      #define _WIN32_IE 0x0601
      They set the Windows version to be at least 7. link to note about Winver
    • There is a build issue for .Net / COM interop on 64 bit machines

      You need to set the project build properties to Platform Target: x86.

      There is a build issue caused by Microsoft replacing the typelibrary registration tool

      Now you have to use the tool: C:\Windows\Microsoft.net\Framework64\v4.0.xxxxx\regtlibv12.exe. See Add External Tools.

      There is a build issue caused by a Microsoft Security update:

      The header atlcore.h participates in all project builds that use the ATL library. Microsoft removed a function from this header, apparently for a security update, but did nothing to patch the ATL library to work without it. This problem has been surfacing in the developer community for about a year. I haven't been able to find a Microsoft Patch or KB article about this. If you add this function to atlcore.h at the end, just before the end of the namespace you will find that builds work again. You should make a master version of the revised file as Microsoft may do the same thing again in a cumulative update. Here's the function:
      This function is missing after updating in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlcore.h file:
      //////////////////////////////////////////////////////////////////////////////
      // DLL Load Helper
      inline HMODULE AtlLoadSystemLibraryUsingFullPath(_In_z_ const WCHAR *pszLibrary)
      {
          WCHAR wszLoadPath[MAX_PATH+1];
          if (::GetSystemDirectoryW(wszLoadPath, _countof(wszLoadPath)) == 0)
          {
              return NULL;
          }
          if (wszLoadPath[wcslen(wszLoadPath)-1] != L'\\')
          {
              if (wcscat_s(wszLoadPath, _countof(wszLoadPath), L"\\") != 0)
              {
                  return NULL;
              }
          }
          if (wcscat_s(wszLoadPath, _countof(wszLoadPath), pszLibrary) != 0)
          {
              return NULL;
          }
          return(::LoadLibraryW(wszLoadPath));
      }
      //////////////////////////////////////////////////////////////////////////////
                    
  7. COM Tools:

  8. Details:

    Virtual Function Pointer Table
    You won't understand IUnknown::QueryInterface unless you understand this diagram. In-Proc Component code
    We will go over this code, line-by-line. IDL Presentation, ppt
    These slides discuss how to describe the structure of a COM interface. Interfac Project
    Shows how to pass most common types of data through COM interfaces, e.g., basic types, strings, pointers, and arrays. IDL Links
CST strip