c++ error


   i get this error when compiling [or actually linking] my code:

Example.obj : error LNK2001: unresolved external symbol "public: long __thiscall ATL::CRegKey::Close(void)" (?Close@CRegKey@ATL@@QAEJXZ)

Any idea how to fix it?



here is the system info:
program accesses registry (among other things)

VC++ 5.0
#include <atlbase.h>


case X:
                    CRegKey* Registry = new CRegKey();                
                    long err;                  
                        err = Registry->Create(HKEY_LOCAL_MACHINE, "Software\\MyApp\\");
                    if (err != ERROR_SUCCESS)
                           MessageBox(NULL, "coulnd;t open registry", "Caption box", MB_OK | MB_TASKMODAL);

                    char buffer[80];
                    unsigned long val_len = strlen(buffer);

                    err = Registry->QueryValue(buffer, "test", &val_len);
                    if (err != ERROR_SUCCESS)
                              MessageBox(NULL, "coulnd;t open registry", "Caption box", MB_OK | MB_TASKMODAL);

                    char *ret_str = buffer;

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.



I don't have a Windows box in front of me, but the linker is trying to say it doesn't know where the CRegKey implementation is.  Is this your own class?  If so, is it in your project?



Falling You - exploring the beauty of voice and sound

i compiled the code on vc 6.0 and it's ok
probably you have some problems with vc libraries. my opinion is that you should check the library and header file for the vc 5.0, it could be that the method don't exist in that vc version.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Look for CRegKey::Close in atlbase.h
It should be something like

inline LONG CRegKey::Close()
    if (m_hKey != NULL)
        lRes = RegCloseKey(m_hKey);
        m_hKey = NULL;
    return lRes;

Elias SalibaCommented:
/*++  Routine Description:      This function creates an event source in the registry.  The event     source is used by the event viewer to display the data in a     presentable manner.  Arguments:      None.  Return Value:      TRUE       - saved all data without error     FALSE      - errors occurred and did not save all data  --*/  {     HKEY   hk;     char   szBuf[1024];     DWORD  dwDisp;     char   szAppName[MAX_PATH];      GetAppName( szAppName, sizeof(szAppName) );     strcpy( szBuf, REGKEY_EVENTLOG );     strcat( szBuf, szAppName );     if (RegCreateKeyEx( HKEY_LOCAL_MACHINE,                         szBuf,                         0,                         NULL,                         REG_OPTION_NON_VOLATILE,                         KEY_QUERY_VALUE | KEY_SET_VALUE,                         NULL,                         &hk,                         &dwDisp                       )) {         return FALSE;     }      if (dwDisp == REG_OPENED_EXISTING_KEY) {         RegCloseKey(hk);         return TRUE;     }      strcpy( szBuf, REGKEY_SYSTEMROOT );     strcat( szBuf, DRWATSON_EXE_NAME );     RegSetEXPANDSZ( hk, REGKEY_MESSAGEFILE, szBuf );     RegSetDWORD( hk, REGKEY_TYPESSUPP, EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE );      RegCloseKey(hk);      return TRUE; }  HKEY RegGetAppKey( void )

for me i don't know that function    Registry->Close();    we just close the keys that we've opeened

// Close the keys that we opened    RegCloseKey(hKeyCurrentVersion);     RegCloseKey(hKeyControlWindows);
//create a key

see the examle above

hope it helps a little
mateuszAuthor Commented:
that's right, i'm using vc5. i'll change to 6 and see if it works.... thanks for the help guys!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.