.ad 8
.bm 8
.fm 4
.bt $Copyright by   Software AG, 1993$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $NME$Project Distributed Database System$vos50c$
.tt 2 $$$
.tt 3 $R.Roedling$NT Registry$1997-06-02$
***********************************************************
.nf


    ========== licence begin LGPL
    Copyright (C) 2002 SAP AG

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    ========== licence end

.fo
.nf
.sp
Module  : NT_Registry
=========
.sp
Purpose :
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :

.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :

.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :

.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : R.Rdling
.sp
.cp 3
Created : 10.05.94
.sp
.cp 3
Version :
.sp
.cp 3
Release :  6.2 	 Date : 1997-06-02
.br
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:

.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:

.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:

.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
/*PRETTY*/

/*
 * INCLUDE FILES
 */


/*
 *  DEFINES
 */
#define MOD__  "VOS50C : "
#define MF__   MOD__"UNDEFINED"


/*
 *  MACROS
 */
#define BUILD_SERVICE_SUBKEY(_Key)     strcpy ( _Key, REG_SK_SERVICE );

#define BUILD_EVENTLOG_SUBKEY(_Key)    strcpy ( _Key, REG_SK_EVENT_LOG );

#define BUILD_APPLIC_SUBKEY(_Key)      strcpy ( _Key, REG_SK_BASE );          \
                                       strcat ( _Key, "\\" );                 \
                                       strcat ( _Key, REG_SK_APPLIC );

#define ADD_SUBKEY(_Key,_SubKey)       if (( _SubKey    != NULL ) &&          \
                                           ( _SubKey[0] != '\0' ))            \
                                         {                                    \
                                         strcat ( _Key, "\\" );               \
                                         strcat ( _Key, _SubKey );            \
                                         }




/*
 *  LOCAL TYPE AND STRUCT DEFINITIONS
 */


/*
 *  EXPORTED VARIABLES
 */


/*
 * LOCAL VARIABLES
 */



/*
 * LOCAL FUNCTION PROTOTYPES
 */

/*
 * ========================== GLOBAL FUNCTIONS ================================
 */

#if defined(_WIN32)

LONG sql50_reg_del_service_value ( PSZ    pszNodeName,
                                   PSZ    pszSubKey,
                                   PSZ    pszValueName )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_del_service_value"
  APIRET    rc  = NO_ERROR;
  PATHNAME  szKey;

  DBGIN;

  BUILD_SERVICE_SUBKEY(szKey);
  ADD_SUBKEY(szKey, pszSubKey);

  rc = sql50_reg_del_value ( pszNodeName,
                             HKEY_LOCAL_MACHINE,
                             szKey,
                             pszValueName );

  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG sql50_reg_del_service_key ( PSZ    pszNodeName,
                                 PSZ    pszSubKey )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_del_service_key"
  APIRET    rc  = NO_ERROR;
  PATHNAME  szKey;

  DBGIN;


  BUILD_SERVICE_SUBKEY(szKey);
  ADD_SUBKEY(szKey, pszSubKey);

  rc = sql50_reg_del_key ( pszNodeName, HKEY_LOCAL_MACHINE, szKey );

  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG sql50_reg_get_service_values ( PSZ             pszNodeName,
                                    PSZ             pszSubKey,
                                    ULONG           ulNumOfEntries,
                                    PREG_ENTRY_REC  pEntyArray )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_get_service_values"
  APIRET    rc  = NO_ERROR;
  PATHNAME  szKey;

  DBGIN;

  BUILD_SERVICE_SUBKEY(szKey);
  ADD_SUBKEY(szKey, pszSubKey);

  rc = sql50_reg_get_values ( pszNodeName, HKEY_LOCAL_MACHINE, szKey,
                              ulNumOfEntries, pEntyArray );

  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG sql50_reg_put_service_values ( PSZ             pszNodeName,
                                    PSZ             pszSubKey,
                                    ULONG           ulNumOfEntries,
                                    PREG_ENTRY_REC  pEntyArray )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_put_service_values"
  APIRET    rc  = NO_ERROR;
  PATHNAME  szKey;
  SECURITY_ATTRIBUTES   SA;
  ACCESS_RIGHTS_REC     Access;

  DBGIN;

  SA.nLength                = sizeof(SA);
  SA.bInheritHandle         = TRUE;
  SA.lpSecurityDescriptor   = NULL;

  memset ( &Access, 0, sizeof (Access) );  // - this must be done first!
  Access.fDescOwnerIsAdmin   = TRUE;
  Access.fAddDefaultDACL     = FALSE;
  Access.Creator.ulAccess    = KEY_ALL_ACCESS;
  Access.Creator.ulAceFlags  = CONTAINER_INHERIT_ACE;
  Access.Admin.ulAccess      = KEY_ALL_ACCESS;
  Access.Admin.ulAceFlags    = CONTAINER_INHERIT_ACE;
  Access.System.ulAccess     = KEY_ALL_ACCESS;
  Access.System.ulAceFlags   = CONTAINER_INHERIT_ACE;
  Access.AdabasOp.ulAccess   = KEY_ALL_ACCESS;
  Access.AdabasOp.ulAceFlags = CONTAINER_INHERIT_ACE;
  Access.World.ulAccess      = KEY_READ           |
                               KEY_CREATE_SUB_KEY |
                               KEY_ENUMERATE_SUB_KEYS;
  Access.World.ulAceFlags    = CONTAINER_INHERIT_ACE;

  rc = sql49c_alloc_and_init_SD( &Access, &SA.lpSecurityDescriptor );

  if ( rc == NO_ERROR )
    {
    BUILD_SERVICE_SUBKEY(szKey);
    ADD_SUBKEY(szKey, pszSubKey);

    rc = sql50_reg_put_values ( pszNodeName, HKEY_LOCAL_MACHINE, szKey,
                                ulNumOfEntries, pEntyArray, &SA );

    if ( SA.lpSecurityDescriptor )
      FREE_MEM ( SA.lpSecurityDescriptor );
    }

  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG  sql50_reg_applic_key_exists ( PSZ    pszNodeName,
                                    HKEY   hKey,
                                    PSZ    pszSubKey )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_applic_key_exists"
  PATHNAME  szKey;
  APIRET    rc  = NO_ERROR;

  DBGPAS;

  if (( hKey != HKEY_LOCAL_MACHINE ) && ( hKey != HKEY_CURRENT_USER ))
    return ( ERROR_INVALID_PARAMETER );

  BUILD_APPLIC_SUBKEY(szKey);
  ADD_SUBKEY(szKey, pszSubKey);

  rc = sql50_reg_key_exists ( pszNodeName, hKey, szKey );

  return ( rc );
  }

/*------------------------------*/

LONG sql50_reg_del_applic_value ( PSZ    pszNodeName,
                                  HKEY   hKey,
                                  PSZ    pszSubKey,
                                  PSZ    pszValueName )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_cu_reg_del_applic_value"
  APIRET    rc  = NO_ERROR;
  PATHNAME  szKey;

  DBGIN;

  if (( hKey != HKEY_LOCAL_MACHINE ) && ( hKey != HKEY_CURRENT_USER ))
    return ( ERROR_INVALID_PARAMETER );

  BUILD_APPLIC_SUBKEY(szKey);
  ADD_SUBKEY(szKey, pszSubKey);

  rc = sql50_reg_del_value ( pszNodeName, hKey, szKey, pszValueName );

  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG sql50_reg_del_applic_key ( PSZ    pszNodeName,
                                HKEY   hKey,
                                PSZ    pszSubKey )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_del_applic_key"
  APIRET    rc  = NO_ERROR;
  PATHNAME  szKey;

  DBGIN;

  if (( hKey != HKEY_LOCAL_MACHINE ) && ( hKey != HKEY_CURRENT_USER ))
    return ( ERROR_INVALID_PARAMETER );

  BUILD_APPLIC_SUBKEY(szKey);
  ADD_SUBKEY(szKey, pszSubKey);

  rc = sql50_reg_del_key ( pszNodeName, hKey, szKey );

  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG sql50_reg_get_applic_values ( PSZ             pszNodeName,
                                   HKEY            hKey,
                                   PSZ             pszSubKey,
                                   ULONG           ulNumOfEntries,
                                   PREG_ENTRY_REC  pEntyArray )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_get_applic_value"
  APIRET    rc  = NO_ERROR;
  PATHNAME  szKey;

  DBGIN;

  if (( hKey != HKEY_LOCAL_MACHINE ) && ( hKey != HKEY_CURRENT_USER ))
    return ( ERROR_INVALID_PARAMETER );

  BUILD_APPLIC_SUBKEY(szKey);
  ADD_SUBKEY(szKey, pszSubKey);

  rc = sql50_reg_get_values ( pszNodeName, hKey, szKey, ulNumOfEntries, pEntyArray );

  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG sql50_reg_put_applic_values ( PSZ             pszNodeName,
                                   HKEY            hKey,
                                   PSZ             pszSubKey,
                                   PSZ             pszPrivateSubKey,
                                   ULONG           ulNumOfEntries,
                                   PREG_ENTRY_REC  pEntyArray )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_put_applic_values"
  APIRET    rc  = NO_ERROR;
  PATHNAME  szKey;
  ACCESS_RIGHTS_REC     Access;
  SECURITY_ATTRIBUTES   PrivateSA;
  SECURITY_ATTRIBUTES   SA;
  PSECURITY_ATTRIBUTES  pSA = NULL;

  DBGIN;

  if (( hKey != HKEY_LOCAL_MACHINE ) && ( hKey != HKEY_CURRENT_USER ))
    return ( ERROR_INVALID_PARAMETER );

  SA.nLength                     = sizeof(SA);
  SA.bInheritHandle              = TRUE;
  SA.lpSecurityDescriptor        = NULL;

  PrivateSA.nLength              = sizeof(PrivateSA);
  PrivateSA.bInheritHandle       = TRUE;
  PrivateSA.lpSecurityDescriptor = NULL;


  if ( hKey == HKEY_LOCAL_MACHINE )
    {
    pSA = &SA;

    memset ( &Access, 0, sizeof (Access) );  // - this must be done first!
    Access.fDescOwnerIsAdmin   = TRUE;
    Access.fAddDefaultDACL     = FALSE;
    Access.Creator.ulAccess    = KEY_ALL_ACCESS;
    Access.Creator.ulAceFlags  = CONTAINER_INHERIT_ACE;
    Access.Admin.ulAccess      = KEY_ALL_ACCESS;
    Access.Admin.ulAceFlags    = CONTAINER_INHERIT_ACE;
    Access.System.ulAccess     = KEY_ALL_ACCESS;
    Access.System.ulAceFlags   = CONTAINER_INHERIT_ACE;
    Access.AdabasOp.ulAccess   = KEY_ALL_ACCESS;
    Access.AdabasOp.ulAceFlags = CONTAINER_INHERIT_ACE;
    Access.World.ulAccess      = KEY_READ           |
                                 KEY_CREATE_SUB_KEY |
                                 KEY_ENUMERATE_SUB_KEYS;
    Access.World.ulAceFlags    = CONTAINER_INHERIT_ACE;

    rc = sql49c_alloc_and_init_SD( &Access, &SA.lpSecurityDescriptor );

    if ( rc != NO_ERROR )
      {
      DBGOUT;
      return ( rc );
      }
    }

  BUILD_APPLIC_SUBKEY(szKey);
  ADD_SUBKEY(szKey, pszSubKey);

  rc = sql50_create_reg_key ( pszNodeName, hKey, szKey, pSA );

  if ( rc != NO_ERROR )
    {
    if ( SA.lpSecurityDescriptor != NULL )
      FREE_MEM ( SA.lpSecurityDescriptor );
    DBGOUT;
    return ( rc );
    }


  if (( pszPrivateSubKey != NULL ) && ( pszPrivateSubKey[0] != '\0'))
    {
    memset ( &Access, 0, sizeof (Access) );  // - this must be done first!
    Access.fDescOwnerIsAdmin  = FALSE;
    Access.fAddDefaultDACL    = FALSE;
    Access.User.ulAccess      = KEY_ALL_ACCESS;
    Access.User.ulAceFlags    = CONTAINER_INHERIT_ACE;
    Access.Admin.ulAccess     = KEY_ENUMERATE_SUB_KEYS |
                                DELETE                 |
                                READ_CONTROL           |
                                KEY_QUERY_VALUE        |
                                KEY_SET_VALUE;
    Access.Admin.ulAceFlags   = CONTAINER_INHERIT_ACE;
    Access.System.ulAccess    = KEY_ALL_ACCESS;
    Access.System.ulAceFlags  = CONTAINER_INHERIT_ACE;

    rc = sql49c_alloc_and_init_SD( &Access, &PrivateSA.lpSecurityDescriptor );

    if ( rc != NO_ERROR )
      {
      if ( SA.lpSecurityDescriptor != NULL )
        FREE_MEM ( SA.lpSecurityDescriptor );

      DBGOUT;
      return ( rc );
      }

    ADD_SUBKEY(szKey, pszPrivateSubKey);

    rc = sql50_reg_put_values  ( pszNodeName, hKey, szKey, ulNumOfEntries,
                                 pEntyArray, &PrivateSA );

    if ( PrivateSA.lpSecurityDescriptor != NULL )
       FREE_MEM ( PrivateSA.lpSecurityDescriptor );
    }
  else
    {
    rc = sql50_reg_put_values  ( pszNodeName, hKey, szKey, ulNumOfEntries,
                                 pEntyArray, pSA );
    }

  if ( SA.lpSecurityDescriptor != NULL )
    FREE_MEM ( SA.lpSecurityDescriptor );

  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG sql50_reg_key_exists ( PSZ      pszNodeName,
                            HKEY     hKey,
                            PSZ      pszSubKey )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_key_exists"
  APIRET    rc  = NO_ERROR;
  HKEY      hCreateKey;
  CHAR      szComputerName[2 + MX_NODEID + 1];

  DBGIN;

  if ( pszNodeName != NULL )
    {
    szComputerName[sizeof(szComputerName) - 1] = '\0';
    strcpy  ( szComputerName, "\\\\" );
    strncat ( szComputerName, pszNodeName, MX_NODEID );

    rc = RegConnectRegistry ( szComputerName, hKey, &hKey );

    if ( rc != ERROR_SUCCESS)
      {
      DBGOUT;
      return ( rc );
      }
    }

  rc = RegOpenKeyEx( hKey, pszSubKey, 0, KEY_READ, &hCreateKey );

  if ( rc == ERROR_SUCCESS)
    {
    RegCloseKey ( hCreateKey );

    DBGOUT;
    return ( NO_ERROR );
    }


  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG sql50_reg_del_value ( PSZ      pszNodeName,
                           HKEY     hKey,
                           PSZ      pszSubKey,
                           PSZ      pszValueName )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_del_value"
  APIRET    rc  = NO_ERROR;
  HKEY      hCreateKey;
  CHAR      szComputerName[2 + MX_NODEID + 1];

  DBGIN;

  if ( pszNodeName != NULL )
    {
    szComputerName[sizeof(szComputerName) - 1] = '\0';
    strcpy  ( szComputerName, "\\\\" );
    strncat ( szComputerName, pszNodeName, MX_NODEID );

    rc = RegConnectRegistry ( szComputerName, hKey, &hKey );

    if ( rc != ERROR_SUCCESS)
      {
      DBGOUT;
      return ( rc );
      }
    }

  rc = RegOpenKeyEx( hKey, pszSubKey, 0, KEY_SET_VALUE, &hCreateKey );

  if ( rc == ERROR_SUCCESS)
    {
    rc = RegDeleteValue ( hCreateKey, pszValueName );

    RegCloseKey ( hCreateKey );

    if ( rc == ERROR_SUCCESS )
      {
      DBGOUT;
      return ( NO_ERROR );
      }
    }

  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG sql50_reg_del_key ( PSZ      pszNodeName,
                         HKEY     hKey,
                         PSZ      pszSubKey )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_del_key"
  APIRET    rc  = NO_ERROR;
  HKEY      hCreateKey;
  PATHNAME  szKey;
  PSZ       pszDelKey;
  CHAR      szComputerName[2 + MX_NODEID + 1];

  DBGIN;

  pszDelKey = strrchr( pszSubKey, '\\');

  if ( pszDelKey != NULL )
    {
    *pszDelKey = '\0';
    strcpy ( szKey, pszSubKey );
    *pszDelKey = '\\';
    pszDelKey++;

    if ( strlen(szKey) == 0 )
      pszSubKey = "\\";
    else
      pszSubKey = szKey;
    }
  else
    {
    pszSubKey = "\\";
    pszDelKey = pszSubKey;
    }

  if ( pszNodeName != NULL )
    {
    szComputerName[sizeof(szComputerName) - 1] = '\0';
    strcpy  ( szComputerName, "\\\\" );
    strncat ( szComputerName, pszNodeName, MX_NODEID );

    rc = RegConnectRegistry ( szComputerName, hKey, &hKey );

    if ( rc != ERROR_SUCCESS)
      {
      DBGOUT;
      return ( rc );
      }
    }

  rc = RegOpenKeyEx( hKey, pszSubKey, 0, KEY_ALL_ACCESS, &hCreateKey );

  if ( rc == ERROR_SUCCESS)
    {
    rc = RegDeleteKey ( hCreateKey, pszDelKey );

    RegCloseKey ( hCreateKey );

    if ( rc == ERROR_SUCCESS )
      {
      DBGOUT;
      return ( NO_ERROR );
      }
    }

  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG sql50_reg_get_values ( PSZ                  pszNodeName,
                            HKEY                 hKey,
                            PSZ                  pszSubKey,
                            ULONG                ulNumOfEntries,
                            PREG_ENTRY_REC       pEntyArray )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_get_values"
  APIRET    rc  = NO_ERROR;
  ULONG     ulType;
  HKEY      hCreateKey;
  ULONG     ulEntry;
  CHAR      szComputerName[2 + MX_NODEID + 1];

  DBGIN;

  if ( pszNodeName != NULL )
    {
    szComputerName[sizeof(szComputerName) - 1] = '\0';
    strcpy  ( szComputerName, "\\\\" );
    strncat ( szComputerName, pszNodeName, MX_NODEID );

    rc = RegConnectRegistry ( szComputerName, hKey, &hKey );

    if ( rc != ERROR_SUCCESS)
      {
      for ( ulEntry = 0; ulEntry < ulNumOfEntries; ulEntry++ )
        pEntyArray[ulEntry].rc = rc;

      DBGOUT;
      return ( rc );
      }
    }

  rc = RegOpenKeyEx( hKey, pszSubKey, 0, KEY_READ, &hCreateKey );

  if ( rc == ERROR_SUCCESS)
    {
    for ( ulEntry = 0; ulEntry < ulNumOfEntries; ulEntry++ )
      {
      pEntyArray[ulEntry].rc = RegQueryValueEx( hCreateKey,
                                                pEntyArray[ulEntry].pszValueName,
                                                0,
                                                &ulType,
                                                pEntyArray[ulEntry].pValue,
                                                &pEntyArray[ulEntry].ulValueSize);

      if ( pEntyArray[ulEntry].rc != ERROR_SUCCESS )
        rc                     = pEntyArray[ulEntry].rc;
      else if (( ulType != pEntyArray[ulEntry].ulValueType ) &&
               ( ulType != 0 ))  // -- any type alllowed!
        {
        pEntyArray[ulEntry].rc = ERROR_BAD_FORMAT;
        rc                     = ERROR_BAD_FORMAT;
        }
      else
        pEntyArray[ulEntry].rc = NO_ERROR;
      }

    RegCloseKey ( hCreateKey );
    }
  else
    {
    for ( ulEntry = 0; ulEntry < ulNumOfEntries; ulEntry++ )
      pEntyArray[ulEntry].rc = rc;
    }

  if ( rc == ERROR_SUCCESS )
    rc = NO_ERROR;

  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG sql50_reg_put_values ( PSZ                  pszNodeName,
                            HKEY                 hKey,
                            PSZ                  pszSubKey,
                            ULONG                ulNumOfEntries,
                            PREG_ENTRY_REC       pEntyArray,
                            PSECURITY_ATTRIBUTES pSA )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_reg_put_values"
  APIRET    rc = NO_ERROR;
  HKEY      hCreateKey;
  ULONG     ulDisposition;
  ULONG     ulEntry;
  CHAR      szComputerName[2 + MX_NODEID + 1];

  DBGIN;

  if ( pszNodeName != NULL )
    {
    szComputerName[sizeof(szComputerName) - 1] = '\0';
    strcpy  ( szComputerName, "\\\\" );
    strncat ( szComputerName, pszNodeName, MX_NODEID );

    rc = RegConnectRegistry ( szComputerName, hKey, &hKey );

    if ( rc != ERROR_SUCCESS)
      {
      for ( ulEntry = 0; ulEntry < ulNumOfEntries; ulEntry++ )
        pEntyArray[ulEntry].rc = rc;

      DBGOUT;
      return ( rc );
      }
    }

  rc = RegCreateKeyEx( hKey, pszSubKey, 0, "ADABAS",
                       REG_OPTION_NON_VOLATILE,
                       KEY_ALL_ACCESS, pSA, &hCreateKey,
                       &ulDisposition );

  if ( rc == ERROR_SUCCESS )
    {
    for ( ulEntry = 0; ulEntry < ulNumOfEntries; ulEntry++ )
      {
      if ( pEntyArray[ulEntry].ulValueType == REG_SZ ||
           pEntyArray[ulEntry].ulValueType == REG_EXPAND_SZ )
        {
        pEntyArray[ulEntry].ulValueSize =
                   lstrlen (pEntyArray[ulEntry].pValue) + 1;
        }

      pEntyArray[ulEntry].rc = RegSetValueEx( hCreateKey,
                                              pEntyArray[ulEntry].pszValueName,
                                              0,
                                              pEntyArray[ulEntry].ulValueType,
                                              pEntyArray[ulEntry].pValue,
                                              pEntyArray[ulEntry].ulValueSize);

      if ( pEntyArray[ulEntry].rc != ERROR_SUCCESS )
        rc = pEntyArray[ulEntry].rc;
      else
        pEntyArray[ulEntry].rc = NO_ERROR;
      }

    RegCloseKey ( hCreateKey );

    if ( rc == ERROR_SUCCESS )
      {
      DBGOUT;
      return ( NO_ERROR );
      }
    }
  else
    {
    for ( ulEntry = 0; ulEntry < ulNumOfEntries; ulEntry++ )
      pEntyArray[ulEntry].rc = rc;
    }


  DBGOUT;
  return ( rc );
  }

/*------------------------------*/

LONG sql50_create_reg_key ( PSZ                  pszNodeName,
                            HKEY                 hKey,
                            PSZ                  pszSubKey,
                            PSECURITY_ATTRIBUTES pSA )
  {
  #undef  MF__
  #define MF__ MOD__"sql50_create_reg_key"
  APIRET    rc  = NO_ERROR;
  HKEY      hCreateKey;
  ULONG     ulDisposition;
  CHAR      szComputerName[2 + MX_NODEID + 1];

  DBGIN;

  if ( pszNodeName != NULL )
    {
    szComputerName[sizeof(szComputerName) - 1] = '\0';
    strcpy  ( szComputerName, "\\\\" );
    strncat ( szComputerName, pszNodeName, MX_NODEID );

    rc = RegConnectRegistry ( szComputerName, hKey, &hKey );

    if ( rc != ERROR_SUCCESS)
      {
      DBGOUT;
      return ( rc );
      }
    }

  rc = RegCreateKeyEx( hKey, pszSubKey, 0, "Application Data",
                       REG_OPTION_NON_VOLATILE,
                       KEY_CREATE_SUB_KEY, pSA, &hCreateKey,
                       &ulDisposition );

  if ( rc == ERROR_SUCCESS )
    {
    RegCloseKey ( hCreateKey );
    }


  DBGOUT;
  return ( rc );
  }

#endif


/*
 * ========================== LOCAL FUNCTIONS =================================
 */

.CM *-END-* code ----------------------------------------
.SP 2
***********************************************************
.PA
