none
The procedure entry point RegGetValueA could not be located in ADVAPI32.dll

    Question

  • I'm pretty sure this is a mismatch between the version my application expects and the version I have, I'm just not sure why or what I can do about it. I did some research and discovered that the version of the DLL that comes with XP SP3 is 5.1.2600.5512. The version I have is 5.1.2600.5755. So my version is newer.

    I can only assume that this version shipped with VS2010 (.NET 4), but if that's the case, why am I having this problem? I'm linking with the correct library and I have no previous installations of Visual Studio on this system. Does anyone have any more information on this? I really don't want to revert to an earlier version unless I have to, in case of dependency issues.

    It should also be noted that I haven't actually implemented my registry class anywhere in the executed code of the application. The class exists, but that's it.

    #ifndef INCLUDED_REGISTRY_H
    #define INCLUDED_REGISTRY_H
    
    #include <windows.h>
    
    class CRegistry
    {
    	HKEY m_hKey;
    	DWORD m_dwDisposition;
    	DWORD m_dwType;
    	DWORD m_dwSize;
    	bool m_bExists;
    	DWORD m_dwLastError;
    
    	DWORD m_dwKeyValue;
    	LPCSTR m_lpszKeyValue;
    
    public:
    	CRegistry(LPCSTR lpszSubKey);
    	~CRegistry();
    
    	DWORD GetType();
    	DWORD GetSize();
    	void GetValue(LPCSTR lpszKeyName, LPCSTR lpszValue);
    
    	void SetType(DWORD dwType);
    	void SetSize(DWORD dwSize);
    	void SetValue(LPCSTR lpszValueName, DWORD dwType, LPVOID lpValue);
    
    	void DeleteValue(LPCSTR lpszValueName);
    
    	bool Exists();
    };
    
    #endif
    #include "Registry.h"
    
    CRegistry::CRegistry(LPCSTR lpszSubKey)
    {
    	this->m_hKey = NULL;
    	this->m_dwDisposition = NULL;
    
    	if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpszSubKey, NULL, KEY_ALL_ACCESS, &this->m_hKey) != ERROR_SUCCESS)
    	{
    		this->m_bExists = false;
    		this->m_dwLastError = GetLastError();
    	}
    	else
    	{
    		RegCreateKeyEx(HKEY_LOCAL_MACHINE, lpszSubKey, NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &this->m_hKey, &this->m_dwDisposition);
    
    		this->m_bExists = true;
    		this->m_dwLastError = NULL;
    	}
    
    	this->m_dwType = NULL;
    	this->m_dwSize = NULL;
    
    	this->m_dwKeyValue = NULL;
    	this->m_lpszKeyValue = new char[1024];
    }
    
    CRegistry::~CRegistry()
    {
    	delete[] this->m_lpszKeyValue;
    
    	RegFlushKey(this->m_hKey);
    	RegCloseKey(this->m_hKey);
    }
    
    DWORD CRegistry::GetType()
    {
    	return this->m_dwType;
    }
    
    DWORD CRegistry::GetSize()
    {
    	return this->m_dwSize;
    }
    
    void CRegistry::GetValue(LPCSTR lpszKeyName, LPCSTR lpszValue)
    {
    	if (this->m_hKey == NULL)
    		return;
    
    	RegGetValue(this->m_hKey, lpszKeyName, lpszValue, RRF_RT_ANY, &this->m_dwType, NULL, NULL);
    
    	if (this->m_dwType & (REG_DWORD | REG_DWORD_LITTLE_ENDIAN | REG_DWORD_BIG_ENDIAN))
    		RegGetValue(this->m_hKey, lpszKeyName, lpszValue, RRF_RT_ANY, NULL, (LPVOID)&this->m_dwKeyValue, &this->m_dwSize);
    
    	else if (this->m_dwType & (REG_EXPAND_SZ | REG_LINK | REG_MULTI_SZ | REG_SZ))
    		RegGetValue(this->m_hKey, lpszKeyName, lpszValue, RRF_RT_ANY, NULL, (LPVOID)this->m_lpszKeyValue, &this->m_dwSize);
    
    	else
    	{
    		this->m_dwType = NULL;
    		this->m_dwSize = NULL;
    	}
    }
    
    void CRegistry::SetType(DWORD dwType)
    {
    	this->m_dwType = dwType;
    }
    
    void CRegistry::SetSize(DWORD dwSize)
    {
    	this->m_dwSize = dwSize;
    }
    
    void CRegistry::SetValue(LPCSTR lpszValueName, DWORD dwType, LPVOID lpValue)
    {
    	if (this->m_hKey == NULL)
    		return;
    
    	DWORD dwQuotaAllowed = NULL;
    	DWORD dwQuotaUsed = NULL;
    
    	GetSystemRegistryQuota(&dwQuotaAllowed, &dwQuotaUsed);
    
    	if (dwQuotaUsed >= dwQuotaAllowed)
    		return;
    
    	RegSetValueEx(this->m_hKey, lpszValueName, NULL, dwType, (LPCBYTE)lpValue, sizeof(lpValue));
    }
    
    void CRegistry::DeleteValue(LPCSTR lpszValueName)
    {
    	if (this->m_hKey == NULL)
    		return;
    
    	RegDeleteValue(this->m_hKey, lpszValueName);
    }
    
    bool CRegistry::Exists()
    {
    	return this->m_bExists;
    }

    Saturday, April 17, 2010 5:57 AM

Answers

  • According to documentation -- http://msdn.microsoft.com/en-us/library/ms724868(VS.85).aspx -- it seems that in Windows XP this function is only available in 64-bit version. Consider RegQueryValueEx instead, which requires explicit null-termination of read strings.

    Saturday, April 17, 2010 8:44 AM
  • "I'm pretty sure this is a mismatch between the version my application expects and the version I have, I'm just not sure why or what I can do about it. I did some research and discovered that the version of the DLL that comes with XP SP3 is 5.1.2600.5512. The version I have is 5.1.2600.5755. So my version is newer.

    I can only assume that this version shipped with VS2010 (.NET 4), but if that's the case, why am I having this problem? I'm linking with the correct library and I have no previous installations of Visual Studio on this system. Does anyone have any more information on this? I really don't want to revert to an earlier version unless I have to, in case of dependency issues."

    Just to add some information to do with DLLs. Advapi would never come with Visual Studio. The version you have is due to security updates. With function availability in Windows there is always a section at the bottom which tells you the client version that it was introduced in. If you check the link  Viorel gave and scroll down to the bottom look at Minimum Client Version. This is Windows XP x64, so the version of Advapi that it has is 5.2.3790 (the same version as Windows Server 2003 because XP x64 was based on that).


    Visit my (not very good) blog at http://c2kblog.blogspot.com/
    Saturday, April 17, 2010 11:04 AM

All replies

  • According to documentation -- http://msdn.microsoft.com/en-us/library/ms724868(VS.85).aspx -- it seems that in Windows XP this function is only available in 64-bit version. Consider RegQueryValueEx instead, which requires explicit null-termination of read strings.

    Saturday, April 17, 2010 8:44 AM
  • "I'm pretty sure this is a mismatch between the version my application expects and the version I have, I'm just not sure why or what I can do about it. I did some research and discovered that the version of the DLL that comes with XP SP3 is 5.1.2600.5512. The version I have is 5.1.2600.5755. So my version is newer.

    I can only assume that this version shipped with VS2010 (.NET 4), but if that's the case, why am I having this problem? I'm linking with the correct library and I have no previous installations of Visual Studio on this system. Does anyone have any more information on this? I really don't want to revert to an earlier version unless I have to, in case of dependency issues."

    Just to add some information to do with DLLs. Advapi would never come with Visual Studio. The version you have is due to security updates. With function availability in Windows there is always a section at the bottom which tells you the client version that it was introduced in. If you check the link  Viorel gave and scroll down to the bottom look at Minimum Client Version. This is Windows XP x64, so the version of Advapi that it has is 5.2.3790 (the same version as Windows Server 2003 because XP x64 was based on that).


    Visit my (not very good) blog at http://c2kblog.blogspot.com/
    Saturday, April 17, 2010 11:04 AM
  • Ah! Thanks very much, I should pay attention to that from now on. :)
    Saturday, April 17, 2010 11:05 AM