Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

c++ error

hi,

   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?

thanks,

matt

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;                  
                    Registry->Attach(HKEY_LOCAL_MACHINE);
                        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;

                    Registry->Close();
break;
0
mateusz
Asked:
mateusz
1 Solution
 
jmzorkoCommented:

Matt,

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?

Regards,

John

Falling You - exploring the beauty of voice and sound
http://www.mp3.com/fallingyou


0
 
cmaryusCommented:
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.
0
 
cupCommented:
Look for CRegKey::Close in atlbase.h
It should be something like

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


0
 
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
RegCreateKeyEx(.....);
RegCreateKey(.....);

see the examle above

hope it helps a little
trinety
0
 
mateuszAuthor Commented:
that's right, i'm using vc5. i'll change to 6 and see if it works.... thanks for the help guys!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now