Problem getting Type Library to regester 
Author Message
 Problem getting Type Library to regester

I have written a com project by hand (no atl, no wizard - help learn
what is going on under the hood).  The problem that I am running into
is that when I add the code to regester the type lib I get the
following error:

DllRegisterServer in parser.dll failed. Return code was: 0x80029c4a.

I have attached the .c file.

#include <olectl.h>  //registry functions
#include "spellcheck.h"

HINSTANCE g_hinstDll;  //global instance handle

//list of registry keys that we want to add
const char *g_RegTable[][2] = {
{"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}","Spellchecker
Object"},
{"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\InprocServer32",(const
char*)-1},
{"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\ProgID",
"Spellchecker.Object.1"},
{"Spellchecker.Object.1","Spellchecker Object"},
{"Spellchecker.Object.1\\CLSID","{7154966D-73F6-4142-9939-5D322DD43D11}"}

Quote:
};

STDAPI DllRegisterServer()
{
        HRESULT hr = S_OK;
        char    szFileName[MAX_PATH];
        HKEY    hkey;

        //determine the path of the dll server
        GetModuleFileName(g_hinstDll,szFileName,MAX_PATH);

        //determine the number or rows in the string array
        int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);

        //loop over all the rows in the arry of strings and extract the name
and value for each key from the character
        //array and calls RegSetValueExA to insert the key into the registry.
        for (int i=0; SUCCEEDED(hr) && i < nEntries; i++)
        {
                const char *pszKeyName = g_RegTable[i][0];
                const char *pszValue = g_RegTable[i][1];

                //if the value for the key is -1, substitue the path of the server
module
                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;
                }
        }

        //need to load and register the type lib
        ITypeLib* pTypeLib;
        wchar_t widePath[MAX_PATH];

        MultiByteToWideChar(CP_ACP, 0, szFileName, lstrlen(szFileName) + 1,
widePath, MAX_PATH);

        hr = LoadTypeLib(widePath,&pTypeLib);
        if (SUCCEEDED(hr))
        {
                hr = SELFREG_E_TYPELIB;
                //pTypeLib->Release();

                hr = RegisterTypeLib(pTypeLib,widePath,NULL);

                if (SUCCEEDED(hr))
                {
                        hr = SELFREG_E_TYPELIB;
                }
                else
                {
                        hr = TYPE_E_CANTLOADLIBRARY;
                }
        }
        else
        {
                hr = TYPE_E_CANTLOADLIBRARY;
        }

/*
    wchar_t widePath[MAX_PATH];
    GetPathName(widePath);
    RegisterServer(widePath, true);
    CComPtr<ITypeLib> pTypeLib;
    HRESULT hr(LoadTypeLib(widePath, &pTypeLib));
    if(hr) return SELFREG_E_TYPELIB;
    hr = RegisterTypeLib(pTypeLib, widePath, 0);
    if(hr) return SELFREG_E_TYPELIB;
    return S_OK;
*/

        return hr;

Quote:
}

STDAPI DllUnregisterServer()
{
        HRESULT hr=S_OK;

        int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);

        //walk the array backward and delete each key.  must delete subkeys
of a key before we delete
        //the key
        for (int i=nEntries-1; i >= 0; i--)
        {
                const char *pszKeyName=g_RegTable[i][0];
                long err=RegDeleteKeyA(HKEY_CLASSES_ROOT,pszKeyName);
                if(err != ERROR_SUCCESS)
                {
                        hr=S_FALSE;
                }
        }

        //unload typelib library and if successfull, unload the dll
        hr = UnRegisterTypeLib(LIBID_SpellcheckerLib,1,0,LOCALE_NEUTRAL,SYS_WIN32);

    if(SUCCEEDED(hr))
        {
                hr = SELFREG_E_TYPELIB;
        }

        return hr;

Quote:
}

BOOL APIENTRY DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID
lpvReserved)
{

        switch(fdwReason)
        {

                case DLL_PROCESS_ATTACH : g_hinstDll = hDLLInst;  //save off the
instance handle in our global var
        }

        return TRUE;

Quote:
}



Fri, 30 Jul 2004 20:07:59 GMT  
 Problem getting Type Library to regester
Well, just debug it. You can't seriously expect others to read through reams
of boilerplate code...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> I have written a com project by hand (no atl, no wizard - help learn
> what is going on under the hood).  The problem that I am running into
> is that when I add the code to regester the type lib I get the
> following error:

> DllRegisterServer in parser.dll failed. Return code was: 0x80029c4a.

> I have attached the .c file.

> #include <olectl.h>  //registry functions
> #include "spellcheck.h"

> HINSTANCE g_hinstDll;  //global instance handle

> //list of registry keys that we want to add
> const char *g_RegTable[][2] = {
> {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}","Spellchecker
> Object"},
> {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\InprocServer32",(const
> char*)-1},
> {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\ProgID",
> "Spellchecker.Object.1"},
> {"Spellchecker.Object.1","Spellchecker Object"},
> {"Spellchecker.Object.1\\CLSID","{7154966D-73F6-4142-9939-5D322DD43D11}"}
> };

> STDAPI DllRegisterServer()
> {
> HRESULT hr = S_OK;
> char    szFileName[MAX_PATH];
> HKEY    hkey;

> //determine the path of the dll server
> GetModuleFileName(g_hinstDll,szFileName,MAX_PATH);

> //determine the number or rows in the string array
> int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);

> //loop over all the rows in the arry of strings and extract the name
> and value for each key from the character
> //array and calls RegSetValueExA to insert the key into the registry.
> for (int i=0; SUCCEEDED(hr) && i < nEntries; i++)
> {
> const char *pszKeyName = g_RegTable[i][0];
> const char *pszValue = g_RegTable[i][1];

> //if the value for the key is -1, substitue the path of the server
> module
> 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;
> }
> }

> //need to load and register the type lib
> ITypeLib* pTypeLib;
> wchar_t widePath[MAX_PATH];

> MultiByteToWideChar(CP_ACP, 0, szFileName, lstrlen(szFileName) + 1,
> widePath, MAX_PATH);

> hr = LoadTypeLib(widePath,&pTypeLib);
> if (SUCCEEDED(hr))
> {
> hr = SELFREG_E_TYPELIB;
> //pTypeLib->Release();

> hr = RegisterTypeLib(pTypeLib,widePath,NULL);

> if (SUCCEEDED(hr))
> {
> hr = SELFREG_E_TYPELIB;
> }
> else
> {
> hr = TYPE_E_CANTLOADLIBRARY;
> }
> }
> else
> {
> hr = TYPE_E_CANTLOADLIBRARY;
> }

> /*
>     wchar_t widePath[MAX_PATH];
>     GetPathName(widePath);
>     RegisterServer(widePath, true);
>     CComPtr<ITypeLib> pTypeLib;
>     HRESULT hr(LoadTypeLib(widePath, &pTypeLib));
>     if(hr) return SELFREG_E_TYPELIB;
>     hr = RegisterTypeLib(pTypeLib, widePath, 0);
>     if(hr) return SELFREG_E_TYPELIB;
>     return S_OK;
> */

> return hr;
> }

> STDAPI DllUnregisterServer()
> {
> HRESULT hr=S_OK;

> int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);

> //walk the array backward and delete each key.  must delete subkeys
> of a key before we delete
> //the key
> for (int i=nEntries-1; i >= 0; i--)
> {
> const char *pszKeyName=g_RegTable[i][0];
> long err=RegDeleteKeyA(HKEY_CLASSES_ROOT,pszKeyName);
> if(err != ERROR_SUCCESS)
> {
> hr=S_FALSE;
> }
> }

> //unload typelib library and if successfull, unload the dll
> hr = UnRegisterTypeLib(LIBID_SpellcheckerLib,1,0,LOCALE_NEUTRAL,SYS_WIN32);

>     if(SUCCEEDED(hr))
> {
> hr = SELFREG_E_TYPELIB;
> }

> return hr;
> }

> BOOL APIENTRY DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID
> lpvReserved)
> {

> switch(fdwReason)
> {

> case DLL_PROCESS_ATTACH : g_hinstDll = hDLLInst;  //save off the
> instance handle in our global var
> }

> return TRUE;
> }



Sat, 31 Jul 2004 04:51:06 GMT  
 Problem getting Type Library to regester
if (SUCCEEDED(hr))
{
hr = SELFREG_E_TYPELIB;
Quote:
}

else
{
hr = TYPE_E_CANTLOADLIBRARY;
Quote:
}
}

else
{
hr = TYPE_E_CANTLOADLIBRARY;

Quote:
}

What is this code supposed to do? If you don't have an error, you invent
one.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken



Quote:
> I have written a com project by hand (no atl, no wizard - help learn
> what is going on under the hood).  The problem that I am running into
> is that when I add the code to regester the type lib I get the
> following error:

> DllRegisterServer in parser.dll failed. Return code was: 0x80029c4a.

> I have attached the .c file.

> #include <olectl.h>  //registry functions
> #include "spellcheck.h"

> HINSTANCE g_hinstDll;  //global instance handle

> //list of registry keys that we want to add
> const char *g_RegTable[][2] = {
> {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}","Spellchecker
> Object"},

{"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\InprocServer32",(const
Quote:
> char*)-1},
> {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\ProgID",
> "Spellchecker.Object.1"},
> {"Spellchecker.Object.1","Spellchecker Object"},

{"Spellchecker.Object.1\\CLSID","{7154966D-73F6-4142-9939-5D322DD43D11}"

- Show quoted text -

Quote:
}
> };

> STDAPI DllRegisterServer()
> {
> HRESULT hr = S_OK;
> char    szFileName[MAX_PATH];
> HKEY    hkey;

> //determine the path of the dll server
> GetModuleFileName(g_hinstDll,szFileName,MAX_PATH);

> //determine the number or rows in the string array
> int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);

> //loop over all the rows in the arry of strings and extract the name
> and value for each key from the character
> //array and calls RegSetValueExA to insert the key into the registry.
> for (int i=0; SUCCEEDED(hr) && i < nEntries; i++)
> {
> const char *pszKeyName = g_RegTable[i][0];
> const char *pszValue = g_RegTable[i][1];

> //if the value for the key is -1, substitue the path of the server
> module
> 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;
> }
> }

> //need to load and register the type lib
> ITypeLib* pTypeLib;
> wchar_t widePath[MAX_PATH];

> MultiByteToWideChar(CP_ACP, 0, szFileName, lstrlen(szFileName) + 1,
> widePath, MAX_PATH);

> hr = LoadTypeLib(widePath,&pTypeLib);
> if (SUCCEEDED(hr))
> {
> hr = SELFREG_E_TYPELIB;
> //pTypeLib->Release();

> hr = RegisterTypeLib(pTypeLib,widePath,NULL);

> if (SUCCEEDED(hr))
> {
> hr = SELFREG_E_TYPELIB;
> }
> else
> {
> hr = TYPE_E_CANTLOADLIBRARY;
> }
> }
> else
> {
> hr = TYPE_E_CANTLOADLIBRARY;
> }

> /*
>     wchar_t widePath[MAX_PATH];
>     GetPathName(widePath);
>     RegisterServer(widePath, true);
>     CComPtr<ITypeLib> pTypeLib;
>     HRESULT hr(LoadTypeLib(widePath, &pTypeLib));
>     if(hr) return SELFREG_E_TYPELIB;
>     hr = RegisterTypeLib(pTypeLib, widePath, 0);
>     if(hr) return SELFREG_E_TYPELIB;
>     return S_OK;
> */

> return hr;
> }

> STDAPI DllUnregisterServer()
> {
> HRESULT hr=S_OK;

> int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);

> //walk the array backward and delete each key.  must delete subkeys
> of a key before we delete
> //the key
> for (int i=nEntries-1; i >= 0; i--)
> {
> const char *pszKeyName=g_RegTable[i][0];
> long err=RegDeleteKeyA(HKEY_CLASSES_ROOT,pszKeyName);
> if(err != ERROR_SUCCESS)
> {
> hr=S_FALSE;
> }
> }

> //unload typelib library and if successfull, unload the dll
> hr =

UnRegisterTypeLib(LIBID_SpellcheckerLib,1,0,LOCALE_NEUTRAL,SYS_WIN32);

- Show quoted text -

Quote:

>     if(SUCCEEDED(hr))
> {
> hr = SELFREG_E_TYPELIB;
> }

> return hr;
> }

> BOOL APIENTRY DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID
> lpvReserved)
> {

> switch(fdwReason)
> {

> case DLL_PROCESS_ATTACH : g_hinstDll = hDLLInst;  //save off the
> instance handle in our global var
> }

> return TRUE;
> }



Sat, 31 Jul 2004 07:01:52 GMT  
 Problem getting Type Library to regester
I tried that and came up with nothing, that is why I ended up posting
a message here to determine if what I have is correct since I am new
to this world of COM.
Quote:

> Well, just debug it. You can't seriously expect others to read through
> reams
> of boilerplate code...

> --
> =========================
> ============
> Alexander Nickolov
> Microsoft MVP [VC], MCSD

> MVP VC FAQ: http://www.mvps.org/vcfaq
> =========================
> ============



> > I have written a com project by hand (no atl, no wizard - help learn
> > what is going on under the hood).  The problem that I am running into
> > is that when I add the code to regester the type lib I get the
> > following error:

> > DllRegisterServer in parser.dll failed. Return code was: 0x80029c4a.

> > I have attached the .c file.

> > #include <olectl.h>  //registry functions
> > #include "spellcheck.h"

> > HINSTANCE g hinstDll;  //global instance handle

> > //list of registry keys that we want to add
> > const char *g RegTable[][2] = {
> > {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}","Spellchecker
> > Object"},

>  {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\InprocServer32",(const
> > char*)-1},
> > {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\ProgID",
> > "Spellchecker.Object.1"},
> > {"Spellchecker.Object.1","Spellchecker Object"},

> {"Spellchecker.Object.1\\CLSID","{7154966D-73F6-4142-9939-5D322DD43D11}"}

> > };

> > STDAPI DllRegisterServer()
> > {
> > HRESULT hr = S OK;
> > char    szFileName[MAX PATH];
> > HKEY    hkey;

> > //determine the path of the dll server
> > GetModuleFileName(g hinstDll,szFileName,MAX PATH);

> > //determine the number or rows in the string array
> > int nEntries = sizeof(g RegTable)/sizeof(*g RegTable);

> > //loop over all the rows in the arry of strings and extract the name
> > and value for each key from the character
> > //array and calls RegSetValueExA to insert the key into the registry.
> > for (int i=0; SUCCEEDED(hr) && i < nEntries; i++)
> > {
> > const char *pszKeyName = g RegTable[i][0];
> > const char *pszValue = g RegTable[i][1];

> > //if the value for the key is -1, substitue the path of the server
> > module
> > 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;
> > }
> > }

> > //need to load and register the type lib
> > ITypeLib* pTypeLib;
> > wchar t widePath[MAX PATH];

> > MultiByteToWideChar(CP ACP, 0, szFileName, lstrlen(szFileName) + 1,
> > widePath, MAX PATH);

> > hr = LoadTypeLib(widePath,&pTypeLib);
> > if (SUCCEEDED(hr))
> > {
> > hr = SELFREG E TYPELIB;
> > //pTypeLib->Release();

> > hr = RegisterTypeLib(pTypeLib,widePath,NULL);

> > if (SUCCEEDED(hr))
> > {
> > hr = SELFREG E TYPELIB;
> > }
> > else
> > {
> > hr = TYPE E CANTLOADLIBRARY;
> > }
> > }
> > else
> > {
> > hr = TYPE E CANTLOADLIBRARY;
> > }

> > /*
> >     wchar t widePath[MAX PATH];
> >     GetPathName(widePath);
> >     RegisterServer(widePath, true);
> >     CComPtr<ITypeLib> pTypeLib;
> >     HRESULT hr(LoadTypeLib(widePath, &pTypeLib));
> >     if(hr) return SELFREG E TYPELIB;
> >     hr = RegisterTypeLib(pTypeLib, widePath, 0);
> >     if(hr) return SELFREG E TYPELIB;
> >     return S OK;
> > */

> > return hr;
> > }

> > STDAPI DllUnregisterServer()
> > {
> > HRESULT hr=S OK;

> > int nEntries = sizeof(g RegTable)/sizeof(*g RegTable);

> > //walk the array backward and delete each key.  must delete subkeys
> > of a key before we delete
> > //the key
> > for (int i=nEntries-1; i >= 0; i--)
> > {
> > const char *pszKeyName=g RegTable[i][0];
> > long err=RegDeleteKeyA(HKEY CLASSES ROOT,pszKeyName);
> > if(err != ERROR SUCCESS)
> > {
> > hr=S FALSE;
> > }
> > }

> > //unload typelib library and if successfull, unload the dll
> > hr =
>  UnRegisterTypeLib(LIBID SpellcheckerLib,1,0,LOCALE NEUTRAL,SYS WIN32);

> >     if(SUCCEEDED(hr))
> > {
> > hr = SELFREG E TYPELIB;
> > }

> > return hr;
> > }

> > BOOL APIENTRY DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID
> > lpvReserved)
> > {

> > switch(fdwReason)
> > {

> > case DLL PROCESS ATTACH : g hinstDll = hDLLInst;  //save off the
> > instance handle in our global var
> > }

> > return TRUE;
> > }



Sat, 31 Jul 2004 11:24:40 GMT  
 Problem getting Type Library to regester
Don't understand your question.

I looked up the error code that is being sent back to me and it states
that it can not load up the tlb library.  The question is, am I
approching this issue correctly or not?
...

Quote:

> if (SUCCEEDED(hr))
> {
> hr = SELFREG_E_TYPELIB;
> }
> else
> {
> hr = TYPE_E_CANTLOADLIBRARY;
> }
> }
> else
> {
> hr = TYPE_E_CANTLOADLIBRARY;
> }

> What is this code supposed to do? If you don't have an error, you invent
> one.
> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



> > I have written a com project by hand (no atl, no wizard - help learn
> > what is going on under the hood).  The problem that I am running into
> > is that when I add the code to regester the type lib I get the
> > following error:

> > DllRegisterServer in parser.dll failed. Return code was: 0x80029c4a.

> > I have attached the .c file.

> > #include <olectl.h>  //registry functions
> > #include "spellcheck.h"

> > HINSTANCE g_hinstDll;  //global instance handle

> > //list of registry keys that we want to add
> > const char *g_RegTable[][2] = {
> > {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}","Spellchecker
> > Object"},

>  {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\InprocServer32",(const
> > char*)-1},
> > {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\ProgID",
> > "Spellchecker.Object.1"},
> > {"Spellchecker.Object.1","Spellchecker Object"},

>  {"Spellchecker.Object.1\\CLSID","{7154966D-73F6-4142-9939-5D322DD43D11}"
> }
> > };

> > STDAPI DllRegisterServer()
> > {
> > HRESULT hr = S_OK;
> > char    szFileName[MAX_PATH];
> > HKEY    hkey;

> > //determine the path of the dll server
> > GetModuleFileName(g_hinstDll,szFileName,MAX_PATH);

> > //determine the number or rows in the string array
> > int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);

> > //loop over all the rows in the arry of strings and extract the name
> > and value for each key from the character
> > //array and calls RegSetValueExA to insert the key into the registry.
> > for (int i=0; SUCCEEDED(hr) && i < nEntries; i++)
> > {
> > const char *pszKeyName = g_RegTable[i][0];
> > const char *pszValue = g_RegTable[i][1];

> > //if the value for the key is -1, substitue the path of the server
> > module
> > 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;
> > }
> > }

> > //need to load and register the type lib
> > ITypeLib* pTypeLib;
> > wchar_t widePath[MAX_PATH];

> > MultiByteToWideChar(CP_ACP, 0, szFileName, lstrlen(szFileName) + 1,
> > widePath, MAX_PATH);

> > hr = LoadTypeLib(widePath,&pTypeLib);
> > if (SUCCEEDED(hr))
> > {
> > hr = SELFREG_E_TYPELIB;
> > //pTypeLib->Release();

> > hr = RegisterTypeLib(pTypeLib,widePath,NULL);

> > if (SUCCEEDED(hr))
> > {
> > hr = SELFREG_E_TYPELIB;
> > }
> > else
> > {
> > hr = TYPE_E_CANTLOADLIBRARY;
> > }
> > }
> > else
> > {
> > hr = TYPE_E_CANTLOADLIBRARY;
> > }

> > /*
> >     wchar_t widePath[MAX_PATH];
> >     GetPathName(widePath);
> >     RegisterServer(widePath, true);
> >     CComPtr<ITypeLib> pTypeLib;
> >     HRESULT hr(LoadTypeLib(widePath, &pTypeLib));
> >     if(hr) return SELFREG_E_TYPELIB;
> >     hr = RegisterTypeLib(pTypeLib, widePath, 0);
> >     if(hr) return SELFREG_E_TYPELIB;
> >     return S_OK;
> > */

> > return hr;
> > }

> > STDAPI DllUnregisterServer()
> > {
> > HRESULT hr=S_OK;

> > int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);

> > //walk the array backward and delete each key.  must delete subkeys
> > of a key before we delete
> > //the key
> > for (int i=nEntries-1; i >= 0; i--)
> > {
> > const char *pszKeyName=g_RegTable[i][0];
> > long err=RegDeleteKeyA(HKEY_CLASSES_ROOT,pszKeyName);
> > if(err != ERROR_SUCCESS)
> > {
> > hr=S_FALSE;
> > }
> > }

> > //unload typelib library and if successfull, unload the dll
> > hr =
>  UnRegisterTypeLib(LIBID_SpellcheckerLib,1,0,LOCALE_NEUTRAL,SYS_WIN32);

> >     if(SUCCEEDED(hr))
> > {
> > hr = SELFREG_E_TYPELIB;
> > }

> > return hr;
> > }

> > BOOL APIENTRY DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID
> > lpvReserved)
> > {

> > switch(fdwReason)
> > {

> > case DLL_PROCESS_ATTACH : g_hinstDll = hDLLInst;  //save off the
> > instance handle in our global var
> > }

> > return TRUE;
> > }



Sat, 31 Jul 2004 11:26:26 GMT  
 Problem getting Type Library to regester
You are returning an error code from your DllRegisterServer whether the
registration succeeds or not. Even if SUCCEEDED(hr) is true, you replace
success code with error code. Is that clear now?
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken



Quote:
> Don't understand your question.

> I looked up the error code that is being sent back to me and it states
> that it can not load up the tlb library.  The question is, am I
> approching this issue correctly or not?
> ...




Quote:
> > if (SUCCEEDED(hr))
> > {
> > hr = SELFREG_E_TYPELIB;
> > }
> > else
> > {
> > hr = TYPE_E_CANTLOADLIBRARY;
> > }
> > }
> > else
> > {
> > hr = TYPE_E_CANTLOADLIBRARY;
> > }

> > What is this code supposed to do? If you don't have an error, you
invent
> > one.
> > --
> > With best wishes,
> >     Igor Tandetnik

> > "For every complex problem, there is a solution that is simple,
neat,
> > and wrong." H.L. Mencken



> > > I have written a com project by hand (no atl, no wizard - help
learn
> > > what is going on under the hood).  The problem that I am running
into
> > > is that when I add the code to regester the type lib I get the
> > > following error:

> > > DllRegisterServer in parser.dll failed. Return code was:
0x80029c4a.

> > > I have attached the .c file.

> > > #include <olectl.h>  //registry functions
> > > #include "spellcheck.h"

> > > HINSTANCE g_hinstDll;  //global instance handle

> > > //list of registry keys that we want to add
> > > const char *g_RegTable[][2] = {
> > > {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}","Spellchecker
> > > Object"},

{"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\InprocServer32",(const
Quote:
> > > char*)-1},
> > > {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\ProgID",
> > > "Spellchecker.Object.1"},
> > > {"Spellchecker.Object.1","Spellchecker Object"},

{"Spellchecker.Object.1\\CLSID","{7154966D-73F6-4142-9939-5D322DD43D11}"

- Show quoted text -

Quote:
> > }
> > > };

> > > STDAPI DllRegisterServer()
> > > {
> > > HRESULT hr = S_OK;
> > > char    szFileName[MAX_PATH];
> > > HKEY    hkey;

> > > //determine the path of the dll server
> > > GetModuleFileName(g_hinstDll,szFileName,MAX_PATH);

> > > //determine the number or rows in the string array
> > > int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);

> > > //loop over all the rows in the arry of strings and extract the
name
> > > and value for each key from the character
> > > //array and calls RegSetValueExA to insert the key into the
registry.
> > > for (int i=0; SUCCEEDED(hr) && i < nEntries; i++)
> > > {
> > > const char *pszKeyName = g_RegTable[i][0];
> > > const char *pszValue = g_RegTable[i][1];

> > > //if the value for the key is -1, substitue the path of the server
> > > module
> > > 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;
> > > }
> > > }

> > > //need to load and register the type lib
> > > ITypeLib* pTypeLib;
> > > wchar_t widePath[MAX_PATH];

> > > MultiByteToWideChar(CP_ACP, 0, szFileName, lstrlen(szFileName) +
1,
> > > widePath, MAX_PATH);

> > > hr = LoadTypeLib(widePath,&pTypeLib);
> > > if (SUCCEEDED(hr))
> > > {
> > > hr = SELFREG_E_TYPELIB;
> > > //pTypeLib->Release();

> > > hr = RegisterTypeLib(pTypeLib,widePath,NULL);

> > > if (SUCCEEDED(hr))
> > > {
> > > hr = SELFREG_E_TYPELIB;
> > > }
> > > else
> > > {
> > > hr = TYPE_E_CANTLOADLIBRARY;
> > > }
> > > }
> > > else
> > > {
> > > hr = TYPE_E_CANTLOADLIBRARY;
> > > }

> > > /*
> > >     wchar_t widePath[MAX_PATH];
> > >     GetPathName(widePath);
> > >     RegisterServer(widePath, true);
> > >     CComPtr<ITypeLib> pTypeLib;
> > >     HRESULT hr(LoadTypeLib(widePath, &pTypeLib));
> > >     if(hr) return SELFREG_E_TYPELIB;
> > >     hr = RegisterTypeLib(pTypeLib, widePath, 0);
> > >     if(hr) return SELFREG_E_TYPELIB;
> > >     return S_OK;
> > > */

> > > return hr;
> > > }

> > > STDAPI DllUnregisterServer()
> > > {
> > > HRESULT hr=S_OK;

> > > int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);

> > > //walk the array backward and delete each key.  must delete
subkeys
> > > of a key before we delete
> > > //the key
> > > for (int i=nEntries-1; i >= 0; i--)
> > > {
> > > const char *pszKeyName=g_RegTable[i][0];
> > > long err=RegDeleteKeyA(HKEY_CLASSES_ROOT,pszKeyName);
> > > if(err != ERROR_SUCCESS)
> > > {
> > > hr=S_FALSE;
> > > }
> > > }

> > > //unload typelib library and if successfull, unload the dll
> > > hr =

UnRegisterTypeLib(LIBID_SpellcheckerLib,1,0,LOCALE_NEUTRAL,SYS_WIN32);

- Show quoted text -

Quote:

> > >     if(SUCCEEDED(hr))
> > > {
> > > hr = SELFREG_E_TYPELIB;
> > > }

> > > return hr;
> > > }

> > > BOOL APIENTRY DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID
> > > lpvReserved)
> > > {

> > > switch(fdwReason)
> > > {

> > > case DLL_PROCESS_ATTACH : g_hinstDll = hDLLInst;  //save off the
> > > instance handle in our global var
> > > }

> > > return TRUE;
> > > }



Sat, 31 Jul 2004 22:48:27 GMT  
 Problem getting Type Library to regester
it is now.  thanks for taking a look at it.
...
Quote:

> You are returning an error code from your DllRegisterServer whether the
> registration succeeds or not. Even if SUCCEEDED(hr) is true, you replace
> success code with error code. Is that clear now?
> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



> > Don't understand your question.

> > I looked up the error code that is being sent back to me and it states
> > that it can not load up the tlb library.  The question is, am I
> > approching this issue correctly or not?
> > ...



> > > if (SUCCEEDED(hr))
> > > {
> > > hr = SELFREG_E_TYPELIB;
> > > }
> > > else
> > > {
> > > hr = TYPE_E_CANTLOADLIBRARY;
> > > }
> > > }
> > > else
> > > {
> > > hr = TYPE_E_CANTLOADLIBRARY;
> > > }

> > > What is this code supposed to do? If you don't have an error, you
>  invent
> > > one.
> > > --
> > > With best wishes,
> > >     Igor Tandetnik

> > > "For every complex problem, there is a solution that is simple,
>  neat,
> > > and wrong." H.L. Mencken



> > > > I have written a com project by hand (no atl, no wizard - help
>  learn
> > > > what is going on under the hood).  The problem that I am running
>  into
> > > > is that when I add the code to regester the type lib I get the
> > > > following error:

> > > > DllRegisterServer in parser.dll failed. Return code was:
>  0x80029c4a.

> > > > I have attached the .c file.

> > > > #include <olectl.h>  //registry functions
> > > > #include "spellcheck.h"

> > > > HINSTANCE g_hinstDll;  //global instance handle

> > > > //list of registry keys that we want to add
> > > > const char *g_RegTable[][2] = {
> > > > {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}","Spellchecker
> > > > Object"},

>  {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\InprocServer32",(const
> > > > char*)-1},
> > > > {"CLSID\\{7154966D-73F6-4142-9939-5D322DD43D11}\\ProgID",
> > > > "Spellchecker.Object.1"},
> > > > {"Spellchecker.Object.1","Spellchecker Object"},

>  {"Spellchecker.Object.1\\CLSID","{7154966D-73F6-4142-9939-5D322DD43D11}"
> > > }
> > > > };

> > > > STDAPI DllRegisterServer()
> > > > {
> > > > HRESULT hr = S_OK;
> > > > char    szFileName[MAX_PATH];
> > > > HKEY    hkey;

> > > > //determine the path of the dll server
> > > > GetModuleFileName(g_hinstDll,szFileName,MAX_PATH);

> > > > //determine the number or rows in the string array
> > > > int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);

> > > > //loop over all the rows in the arry of strings and extract the
>  name
> > > > and value for each key from the character
> > > > //array and calls RegSetValueExA to insert the key into the
>  registry.
> > > > for (int i=0; SUCCEEDED(hr) && i < nEntries; i++)
> > > > {
> > > > const char *pszKeyName = g_RegTable[i][0];
> > > > const char *pszValue = g_RegTable[i][1];

> > > > //if the value for the key is -1, substitue the path of the server
> > > > module
> > > > 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;
> > > > }
> > > > }

> > > > //need to load and register the type lib
> > > > ITypeLib* pTypeLib;
> > > > wchar_t widePath[MAX_PATH];

> > > > MultiByteToWideChar(CP_ACP, 0, szFileName, lstrlen(szFileName) +
>  1,
> > > > widePath, MAX_PATH);

> > > > hr = LoadTypeLib(widePath,&pTypeLib);
> > > > if (SUCCEEDED(hr))
> > > > {
> > > > hr = SELFREG_E_TYPELIB;
> > > > //pTypeLib->Release();

> > > > hr = RegisterTypeLib(pTypeLib,widePath,NULL);

> > > > if (SUCCEEDED(hr))
> > > > {
> > > > hr = SELFREG_E_TYPELIB;
> > > > }
> > > > else
> > > > {
> > > > hr = TYPE_E_CANTLOADLIBRARY;
> > > > }
> > > > }
> > > > else
> > > > {
> > > > hr = TYPE_E_CANTLOADLIBRARY;
> > > > }

> > > > /*
> > > >     wchar_t widePath[MAX_PATH];
> > > >     GetPathName(widePath);
> > > >     RegisterServer(widePath, true);
> > > >     CComPtr<ITypeLib> pTypeLib;
> > > >     HRESULT hr(LoadTypeLib(widePath, &pTypeLib));
> > > >     if(hr) return SELFREG_E_TYPELIB;
> > > >     hr = RegisterTypeLib(pTypeLib, widePath, 0);
> > > >     if(hr) return SELFREG_E_TYPELIB;
> > > >     return S_OK;
> > > > */

> > > > return hr;
> > > > }

> > > > STDAPI DllUnregisterServer()
> > > > {
> > > > HRESULT hr=S_OK;

> > > > int nEntries = sizeof(g_RegTable)/sizeof(*g_RegTable);

> > > > //walk the array backward and delete each key.  must delete
>  subkeys
> > > > of a key before we delete
> > > > //the key
> > > > for (int i=nEntries-1; i >= 0; i--)
> > > > {
> > > > const char *pszKeyName=g_RegTable[i][0];
> > > > long err=RegDeleteKeyA(HKEY_CLASSES_ROOT,pszKeyName);
> > > > if(err != ERROR_SUCCESS)
> > > > {
> > > > hr=S_FALSE;
> > > > }
> > > > }

> > > > //unload typelib library and if successfull, unload the dll
> > > > hr =

>  UnRegisterTypeLib(LIBID_SpellcheckerLib,1,0,LOCALE_NEUTRAL,SYS_WIN32);

> > > >     if(SUCCEEDED(hr))
> > > > {
> > > > hr = SELFREG_E_TYPELIB;
> > > > }

> > > > return hr;
> > > > }

> > > > BOOL APIENTRY DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID
> > > > lpvReserved)
> > > > {

> > > > switch(fdwReason)
> > > > {

> > > > case DLL_PROCESS_ATTACH : g_hinstDll = hDLLInst;  //save off the
> > > > instance handle in our global var
> > > > }

> > > > return TRUE;
> > > > }



Sun, 01 Aug 2004 02:50:23 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. MessengerAPI type library - IDispatch enum type problem

2. Type Library problem

3. Type Library Registration Problem

4. HELP: #import problem w/ COM type library

5. #import type library problems

6. Problems with ClassWizard and VB OLE Type Libraries?

7. #import/type library problem

8. HELP: #import problem w/ COM type library

9. HRESULT return type turns into void when adding class from type library

10. type problems with .net types *arrgh*

11. Exposing interfaces in a type library that are infact defined in another type library.

12. Getting a Type from a Class

 

 
Powered by phpBB® Forum Software