Click here to Skip to main content
12,758,605 members (32,175 online)

WINXP-SP3 - The specified program requires a newer version of Windows.

Shakazzolo asked:

Open original thread
It seems like I'm the only one on the plant (Earth) who is having this problem...

I wrote a very simple method which dynamically loads and executes RegCreateKeyExA and I get the following error from "GetProcAddress(Avapi32,RegCreateKeyExA)"
Error 1150. The specified program requires a newer version of Windows.

The same code works fine on Windows 7, so I went back to WINXP and opened advapi32.dll with notepad, and sure enough, RegCreateKeyExA was there.... what am I missing here :confused:

Here is the method:
regDyFunc::DyRegCreateKeyEx(HKEY hMainKey,
			   LPCTSTR lpSubKey,
			   PHKEY phkResult,
                           LPDWORD lpdwDisposition )
 // The type of the wanted function
 typedef UINT (CALLBACK* REGFUNCCreateKeyEx)( 	//LONG WINAPI RegCreateKeyEx(
  HKEY,	  //  __in        HKEY hKey,
  LPCTSTR,//  __in        LPCTSTR lpSubKey,
  DWORD,  //  __reserved  DWORD Reserved,
  LPTSTR, //  __in_opt    LPTSTR lpClass,
  DWORD,  //  __in        DWORD dwOptions,
  REGSAM, //  __in        REGSAM samDesired,
  PHKEY,  //  __out       PHKEY phkResult,
  LPDWORD //  __out_opt   LPDWORD lpdwDisposition

 REGFUNCCreateKeyEx regFuncCreateKeyEx; // Stores the wanted function
 long lResult = ERROR_SUCCESS; // Used to check for failure and return value

 // Verify parameters
 if (lpSubKey == NULL)

 // Dynamically load the registry function
 if (lResult == ERROR_SUCCESS){
	regFuncCreateKeyEx =
                     (LPCSTR)"RegCreateKeyExA" );
	regDyFunc::csLastCall = "GetProcAddress(Avapi32,RegCreateKeyExA)";
	lResult = GetLastError();
 // Execute the function
 if (lResult == ERROR_SUCCESS)
	regDyFunc::csLastCall = "RegCreateKeyExA";
	lResult  = regFuncCreateKeyEx(

 return lResult;

And the function to load the library:
    bool bRet = true;
    regDyFunc::hAvapi32 = LoadLibrary("Advapi32");
    if (regDyFunc::hAvapi32 == NULL){
        _tprintf(_T("Unable to load Advapi32\n"));
        bRet = false;
    if (bRet){
        // Always try to load all modules
        regDyFunc::hKtmW32 = LoadLibrary("KtmW32");
        //Give an error only if its Vista or later
        if ((regDyFunc::hKtmW32 == NULL) && (regDyFunc::Is_Vista_or_Later())) {
            _tprintf(_T("Unable to load KtmW32\n"));
            bRet = false;
    return bRet;

Thanks in advance
Tags: C++


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100