Read and alter registry settings in Axapta

Here is a sample code of increasing max. open cursors during run-time. But, please note that its purpose is only to show you how to read and write registry. If you encounter any open cursors problem, it is recommended to optimize the SQL statement rather than changing the setting for maximum open cursors. 
static void IncreaseMaxOpenCursors(Args _args)
    container   regRet;   
    int         readReg;
    int         writeReg;
    str         keyValue, keyPath, configName;
    int         maxOpenCursors;
    //Specify your Axapta configuration utility name here
    configName = "LocalMachine";
    //New maximum open cursor, default is 90
    maxOpenCursors = 120;
    keyPath = @"SOFTWARENavisionAxapta3.0" + configName;
    readReg  = WinAPI::regOpenKey( #HKEY_CURRENT_USER, keyPath, #KEY_READ);
    if (readReg)
        regRet = WinAPI::regGetValue(readReg, ‘opencursors’);
        keyValue = conpeek(regRet,1);
        if (str2int(keyValue) < maxOpenCursors)
            writeReg  = WinAPI::regOpenKey(#HKEY_CURRENT_USER, keyPath, #KEY_WRITE);
            if (writeReg)
                WinAPI::regSetValueEx(writeReg, ‘opencursors‘, #REG_SZ , maxOpenCursors);
            Info("Max open cursors: " + int2str(maxOpenCursors));
This entry was posted in Axapta Development. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s