title: How can I give an old ActiveX control new GUIDs?
body: <p>I am trying to modify an ActiveX control developed in Visual Studio 2008 to use it for a purpose for which it was not originally designed.  I will be reusing at least 90% of its code.  Therefore, I would like to begin by creating an identical control that uses different GUIDs.  I tried to follow instructions I found <a href="https://www.experts-exchange.com/questions/21157465/Change-GUID-in-VStudio-C-OCX.html" rel="nofollow noreferrer">here</a> (a very old link, written in 2004), but when I tried to build my project, I got an assertion failure in ctlreg.cpp line 113.  Then, I restored all my changed files back to their original states, and for each GUID is the .odl file, I searched for the GUID in my .cpp and .h files and changed it wherever I found it.  I also made sure to change my major version number.  I still get the assertion failure.  What else should I be doing?  </p>
  
  <p>Here's the code from ctlreg.cpp from the start of the method containing the assertion to the assertion itself:</p>
  
  <pre><code>BOOL AFXAPI AfxOleRegisterTypeLib(HINSTANCE hInstance, REFGUID tlid,
      LPCTSTR pszFileName, LPCTSTR pszHelpDir)
  {   
      BOOL bSuccess = FALSE;
      CStringW strPathNameW;
      wchar_t *szPathNameW = strPathNameW.GetBuffer(_MAX_PATH);
      ::GetModuleFileNameW(hInstance, szPathNameW, _MAX_PATH);
      strPathNameW.ReleaseBuffer();
      LPTYPELIB ptlib = NULL;
      // If a filename was specified, replace final component of path with it.
      if (pszFileName != NULL)
      {
          int iBackslash = strPathNameW.ReverseFind('\\');
          if (iBackslash != -1)
              strPathNameW = strPathNameW.Left(iBackslash+1);
          strPathNameW += pszFileName;
      }
      if (SUCCEEDED(LoadTypeLib(strPathNameW.GetString(), &amp;ptlib)))
      {
          ASSERT_POINTER(ptlib, ITypeLib);
  
          LPTLIBATTR pAttr;
          GUID tlidActual = GUID_NULL;
  
          if (SUCCEEDED(ptlib-&gt;GetLibAttr(&amp;pAttr)))
          {
              ASSERT_POINTER(pAttr, TLIBATTR);
              tlidActual = pAttr-&gt;guid;
              ptlib-&gt;ReleaseTLibAttr(pAttr);
          }
  
          // Check that the guid of the loaded type library matches
          // the tlid parameter.
          ASSERT(IsEqualGUID(tlid, tlidActual));
  </code></pre>