Solved

Change GUID in VStudio C++ OCX

Posted on 2004-10-05
2
1,255 Views
Last Modified: 2013-11-20
Hi

A seeming simple thing, but I can't find a reference on how to do this.

I wrote and ActiveX control in Visual Studio 6.  I want to break off from the current interface and create a newly referenced control...new name, new GUID.

The ODL file has lines as follows:

[ uuid(11518DD5-DD1F-11D4-9B28-000000000000), version(1.1),
.
.
.
library RICHTEXTBOXLib
{
      importlib(STDOLE_TLB);
      importlib(STDTYPE_TLB);

      //  Primary dispatch interface for CRichTextBoxCtrl

      [ uuid(11518DD6-DD1F-11D4-9B28-000000000000),
.
.
.
      //  Event dispatch interface for CRichTextBoxCtrl

      [ uuid(11518DD7-DD1F-11D4-9B28-000000000000),
        helpstring("Event interface for RichTextBox Control") ]
.
.
.
      //  Class information for CRichTextBoxCtrl

      [ uuid(11518DD8-DD1F-11D4-9B28-000000000000),

Can I just generate a new set of GUIDs and replace these?  Are the sequential aspects of these existing GUIDS important?

Thanks
0
Comment
Question by:rmichels
2 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 12235000
You can generate new GUIDs and replace existing. Sequence doesn't matter - GUIDs are not compared in COM.
For example, Visual Basic generates new GUIDs for COM Library in every build if "No compatibility" option is selected. The result is completely new COM component (even if it has the same name).
0
 
LVL 6

Accepted Solution

by:
nabehs earned 125 total points
ID: 12235201
you will need more than just replacing the guids in odl file:

1. First of all, yes, you need to replace all guids in odl file

2. Change the version of the control in guid file, for example version(1.0) to version(2.0)

3. In Ctl file (i.e. RichTextBoxCtl.cpp) change the following:

(A) IMPLEMENT_OLECREATE_EX macro to the new guid of the control in odl file. the guid you will need here from the odl file is the last guid in the odl file which is the control guid. You need also to change the control name from RICHTEXTBOX.1.0 for example to RICHTEXTBOX.2.0 in the same macro

(B) change the following guid definitions in the ctl file
const IID BASED_CODE IID_DRichTextbox =
            { the guid of the properties interface in the odl file (2nd guid) };
const IID BASED_CODE IID_DRichTextboxEvents =
            { the guid of the events interface in the odl file (3rd guid)};
Note you need to reformat the guid here, for example: a guid of
1AB2BB44-F870-4AC2-A912-094AA5666BE1 becomes:
{ 0x1ab2bb44, 0xf870, 0x4ac2, { 0xa9, 0x12, 0x9, 0x4a, 0xa5, 0x66, 0x6b, 0xe1 } }

3. In the app file (i.e. RichTextbox.cpp), you need to change the type library guid:
const GUID CDECL BASED_CODE _tlid =
            { the guid of the type library in the odl file (1st guid) };
const WORD _wVerMajor = 1; // change the version to the new version
const WORD _wVerMinor = 0;

4. change the guid for the default property page (i.e. RichTextboxPPg.cpp) to the new guid (you will need to create a new guid for the property page)
check IMPLEMENT_OLECREATE_EX macro

This should do it and create a fresh control.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

709 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now