473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

CoCreateInstance fails returning class not registered

I have created a basic COM in-proc server and a client.
The registration of my server succeeds according to
regsvr32.
I can see it in the registry, having the ProgID and the
InProcServer32 entries.
I can't seem to find it in the OLE/COM Viewer unless I
specifically open the tlb file.
Opening the dll file by the same method displays an error
loading the type lib, although the dialog box specifies
that I can put in a dll file.
Calling CoCreateInstance from the client to instantiate
the server returns class not registered. But as I have
mentioned I can see it in the registry.
What have I done wrong ???

My registry entries :

HKEY_CLASSES_ROOT\CLSID\{57B7A8A0-E4D7-11d0-818D-444553540000}
The value is the name of my object

HKEY_CLASSES_ROOT\CLSID\{57B7A8A0-E4D7-11d0-818D-444553540000}\InprocServer32
The value is the right path to my DLL server

HKEY_CLASSES_ROOT\CLSID\{57B7A8A0-E4D7-11d0-818D-444553540000}\ProgID
The value is the name of my Dll Server.Object.1

HKEY_CLASSES_ROOT\Name.Object.1
The value is the name of my Dll Server

HKEY_CLASSES_ROOT\Name.Object.1\CLSID
The value is {57B7A8A0-E4D7-11d0-818D-444553540000}

This is the code for my DllRegisterServer :

HINSTANCE g_hinstDll;

const char* g_RegTable[][2]=
{
{"CLSID\\{57B7A8A0-E4D7-11d0-818D-444553540000}","SpellChecker
Object"},
{"CLSID\\{57B7A8A0-E4D7-11d0-818D-444553540000}\\InprocServer32",(const

char*)-1},
{"CLSID\\{57B7A8A0-E4D7-11d0-818D-444553540000}\\ProgID","SpellChecker.Object.1"},
{"SpellChecker.Object.1","SpellChecker Object"},
{"SpellChecker.Object.1\\CLSID","{57B7A8A0-E4D7-11d0-818D-444553540000}"}
};

STDAPI DllRegisterServer()
{
HRESULT hr=S_OK;
char szFileName[MAX_PATH];
HKEY hkey;
GetModuleFileName(g_hinstDll,szFileName,MAX_PATH);
int nEntries=sizeof(g_RegTable)/sizeof(*g_RegTable);
for(int i=0;SUCCEEDED(hr)&&i<nEntries;i++)
{
const char* pszKeyName = g_RegTable[i][0];
const char* pszValue = g_RegTable[i][1];
if(pszValue==(const char*)-1)
pszValue=szFileName;
long err=RegCreateKey(HKEY_CLASSES_ROOT,pszKeyName,&hke y);
if(err==ERROR_SUCCESS)
{
err=RegSetValueExA(hkey,0,0,REG_SZ,(const
BYTE*)pszValue,(strlen(pszValue)+1));
RegCloseKey(hkey);
}
if(err!=ERROR_SUCCESS)
{
DllUnregisterServer();
hr=SELFREG_E_CLASS;
}
}
return hr;
}

This is the idl file :

import "oaidl.idl";
import "ocidl.idl";
import "unknwn.idl";

[ object, uuid(00E73D3C-AA86-4d7e-9ED0-72948755C0D0) ]
interface ISpellChecker : IUnknown
{
HRESULT CheckSpelling([in,string] char *word, [out,retval] BOOL
*isCorrect);
HRESULT UseCustomDictionary([in,string]char *filename);
}

[ uuid(1E4CB38F-6EC4-4807-B459-FC54973A7FE5) ]
library SpellCheckerLib
{
[ uuid(57B7A8A0-E4D7-11d0-818D-444553540000) ]
coclass CSpellChecker
{
interface ISpellChecker;
}
};
What happens is exactly what I have meant to happen.

Why is not that enough ?
What more should be done ?

Thank you!!!

Sep 29 '05 #1
2 9495
Lady_A wrote:
I have created a basic COM in-proc server and a client.
The registration of my server succeeds according to
regsvr32.

[snip]

This newsgroup is for standard C++ language issues, but COM falls
outside of that scope. Please try in
comp.os.ms-windows.programmer.win32 or similar.

Cheers! --M

Sep 29 '05 #2

"Lady_A" <al***********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
I have created a basic COM in-proc server and a client.
The registration of my server succeeds according to
regsvr32.


None of this has anything to do with standard C++ language,
the only topic here.

Try asking about this in a Windows group, e.g.
comp.os.ms-windows.programmer.win32

-Mike
Sep 29 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Arthur | last post by:
A bit inspired by the decorator discussions, I'm trying to tackle something I had been avoiding. Essentially I am trying to create a non-destructive tranformation of an instance of a class - is...
2
by: David | last post by:
Can anyone tell me why the following code crashes? The pure base class StaticObjectRegistry stores pointers to derived classes upon construction. Later it uses these pointers to call the...
15
by: Brian Rogers | last post by:
Hello everyone, I apologize for the cross and re-post, but I am still searching for an answer. Why can C++ can create this object, but C# can't? I am trying to create an instance of the...
0
by: Tim Kiely | last post by:
I have a managed C++ class that exposes a COM object to ASP.NET. This COM object creates several other COM objects internally. A VS.NET 2002 build of the dll works fine on .NET 1.0 and 1.1. A...
0
by: Naveen | last post by:
Hi I have a component writtten in vc++ registered in MTS. I use MFC DLL which initializes and creates an instance and uninitialize of this MTS component. I use COInitialize ,COCreateInstance and...
0
by: alvin | last post by:
Dear friends, I am new to vc++ .net programing. Please anyone help me to solve my issue Following is my code:...
0
by: Kostya | last post by:
Hello. We need to use UserControl-derived components written in C# in our existing MFC application. The components need to be inserted into existing ActiveX controls (written using MFC and ATL...
1
by: steveo.uts | last post by:
I've created a web app in C # that creates a self-extracting installation file, and then attempts to digitally sign that file using MS signtool. I'm using the Process class to invoke signtool...
6
by: ranin02 | last post by:
Hi, I have a COM method that is called from VBA. This COM method in turn calls CoCreateInstance on a class that is a .NET class with a COM wrapper around it. This all works fine. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.