?
Solved

c++ error

Posted on 2003-03-24
5
Medium Priority
?
235 Views
Last Modified: 2010-04-01
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
Comment
Question by:mateusz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Expert Comment

by:jmzorko
ID: 8200234

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
 
LVL 3

Accepted Solution

by:
cmaryus earned 150 total points
ID: 8200752
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
 
LVL 11

Expert Comment

by:cup
ID: 8201792
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
 
LVL 2

Expert Comment

by:Elias Saliba
ID: 8201909
/*++  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
 

Author Comment

by:mateusz
ID: 8206843
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question