Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How the ClassID of an OCX is determined?

Posted on 1999-07-20
9
Medium Priority
?
574 Views
Last Modified: 2013-12-03
Does someone know how the compiler decides what ClassId to give a certain OCX?
and how it guards that the number stays unique?
0
Comment
Question by:msiman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 6

Expert Comment

by:simonbennett
ID: 1403352
It uses a 128 bit 'random' generator that uses the system time, serial number, HD identifier and free bytes on the HD to produce the alphanumeric 'GUID' (globally unique identifier) - the same process can be seen for example in MS Access replication. The chanes of a duplicate are supposidly 10 to the power of 21 of a dupe occuring.

All Hail To Billy
0
 
LVL 2

Author Comment

by:msiman
ID: 1403353
So why everywhere i install my OCX, it keeps its
ClassID?

0
 
LVL 6

Expert Comment

by:simonbennett
ID: 1403354
Thats because it is created when it is compiled. Once created the GUID does not change. That process uses information from the development machine.
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 6

Expert Comment

by:simonbennett
ID: 1403355
..sorry, depending on your compatability settings - i.e No Compatability will keep the guid the same for example...
0
 
LVL 2

Author Comment

by:msiman
ID: 1403356
OK...
I will refine my question, so i raised a little the points.
I want to be able to change the CLassID of an OCX manually.
is it possible? if yes, then  how?

0
 
LVL 6

Expert Comment

by:simonbennett
ID: 1403357
Nope. And if you did it would be risky...
0
 
LVL 2

Author Comment

by:msiman
ID: 1403358
sorry, but it must be possible. the compiler does it,
what can't I?
the ClassID is stored somewhere, right? so
it can be changed with the appropriate editor....
and i want to do so...
0
 
LVL 6

Accepted Solution

by:
simonbennett earned 340 total points
ID: 1403359
Sorry msiman - I though you wanted to create a *new* GUID

If you need to change it you should use RegSetKeyValueEx etc API calls to look at the entry in the registry. If you look in..

HKEY_CLASSES_ROOT\YOURAPP.YOURCLASS\CLSID

...in the registry you will find the GUID for the class yourapp.yourclass, e.g. i have

HKEY_CLASSES_ROOT\ACCESS.APPLICATION\CLSID

which stores

{8CC49940-3146-11CF-97A1-00AA00424A9F}.

This is a string value so you can use...

Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long        

..to set it.

HTH


0
 
LVL 2

Author Comment

by:msiman
ID: 1403360
first' it doesn't work.
i created 2 OCXes, and wrote a program that calls one of them,
then i erased the first one, renmaed the second to be
the first, change its GUID to the GUID of the first one,
and i got an error. both had the same programming interface.
second, i am much more interested to know wheree the GUID is stored in the file...
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

670 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