CoCreateInstance fails returning class not registered

L

Lady_A

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[0];
const char* pszValue = g_RegTable[1];
if(pszValue==(const char*)-1)
pszValue=szFileName;
long err=RegCreateKey(HKEY_CLASSES_ROOT,pszKeyName,&hkey);
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!!!
 
M

mlimber

Lady_A said:
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
 
M

Mike Wahler

Lady_A said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top