Regdeletekey error codes

regdeletekey error codes

stackoverflow.com › questions › regdeletekey-returning-file-not-found. Hi All, I am implementing a recursive registry delete using RegOpenKeyEx, RegDeleteKey and RegEnumKey. The regDeleteKey function removes a key and all associated values from the registry on the local system or a remote system. regdeletekey error codes

Something: Regdeletekey error codes

ERROR LNK2001 UNRESOLVED EXTERNAL SYMBOL _MAINCRTSTARTUP
Dkms virtualbox error
Regdeletekey error codes
End blob steam error

Regdeletekey error codes - idea

FOF_NOERRORUI

RegDeleteKeyExA function (winreg.h)

  • Article
  • 2 minutes to read

Deletes a subkey and its values from the specified platform-specific view of the registry. Note that key names are not case sensitive.

To delete a subkey as a transacted operation, call the RegDeleteKeyTransacted function.

Syntax

Parameters

A handle to an open registry key. The access rights of this key do not affect the delete operation. For more information about access rights, see Registry Key Security and Access Rights.

This handle is returned by the RegCreateKeyEx or RegOpenKeyEx function, or it can be one of the following predefined keys:

HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS

The name of the key to be deleted. This key must be a subkey of the key specified by the value of the hKey parameter.

The function opens the subkey with the DELETE access right.

Key names are not case sensitive.

The value of this parameter cannot be NULL.

An access mask the specifies the platform-specific view of the registry.

ValueMeaning
KEY_WOW64_32KEY
0x0200
Delete the key from the 32-bit registry view.
KEY_WOW64_64KEY
0x0100
Delete the key from the 64-bit registry view.

This parameter is reserved and must be zero.

Return value

If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

A deleted key is not removed until the last handle to it is closed.

On WOW64, 32-bit applications view a registry tree that is separate from the registry tree that 64-bit applications view. This function enables an application to delete an entry in the alternate registry view.

The subkey to be deleted must not have subkeys. To delete a key and all its subkeys, you need to enumerate the subkeys and delete them individually. To delete keys recursively, use the RegDeleteTree or SHDeleteKey function.

If the function succeeds, RegDeleteKeyEx removes the specified key from the registry. The entire key, including all of its values, is removed.

Note

On legacy versions of Windows, this API is also exposed by kernel32.dll.

Note

The winreg.h header defines RegDeleteKeyEx as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Minimum supported clientWindows Vista, Windows XP Professional x64 Edition [desktop apps only]
Minimum supported serverWindows Server 2008, Windows Server 2003 with SP1 [desktop apps only]
Target PlatformWindows
Headerwinreg.h (include Windows.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll

See also

RegCreateKeyEx

RegDeleteKeyTransacted

RegOpenKeyEx

Registry Functions

Registry Redirector

ret == IDCANCEL) { state_return_value=0; } else { state_return_value=1; } } } else { log_printf("MessageBox: error parsing parameter\n"); } return 0; } log_printf("MessageBox: INSTALLER CORRUPTED\n"); break; case 13: //RMDir if (!GetStringFromDataBlock(hFile,offset+thisentry->offsets[0],buf,sizeof(buf))) { log_printf2("RMDir: \"%s\"\n",buf); if (!process_string(buf2,buf,state_install_directory)) { log_printf2("RMDir: RemoveDirectory(\"%s\")\n",buf2); { INT32 args[] = { (INT32)buf }; GETRESOURCE2(tmpbuf, JAVAWS_STATUS_REMOVEDIR, args); update_status_text(tmpbuf); } RemoveDirectory(buf2); } else { log_printf("RMDir: error parsing parameter\n"); } return 0; } log_printf("RMDir: INSTALLER CORRUPTED\n"); break; case 19: if (!GetStringFromDataBlock(hFile,offset+thisentry->offsets[0],buf,sizeof(buf))) { log_printf2("RMDirRecursive: \"%s\"\n",buf); if (!process_string(buf2,buf,state_install_directory)) { SHFILEOPSTRUCT fos; log_printf2("RMDirRecursive: RemoveDirectory(\"%s\")\n",buf2); { INT32 args[] = { (INT32)buf }; GETRESOURCE2(tmpbuf, JAVAWS_STATUS_REMOVEDIR, args); update_status_text(tmpbuf); } buf2[_tcslen(buf2)]=0; buf2[_tcslen(buf2)+1]=0; if (GetFileAttributes(buf2)!=0xffffffff) { // Only do SHFileOperation if file exists fos.hwnd = g_hwnd; fos.wFunc = FO_DELETE; fos.pFrom = buf2; fos.pTo = NULL; fos.fFlags = FOF_SILENT
I have an application which connects to a remote server and deletes a registry key using the RegDeleteKey function.

This has worked for a number of years now when run from a 32-bit Windows server to another 32-bit Windows server.

Recently, we've had some 64-bit Windows (2003) servers introduced, and when this same utility was run against them from a 32-bit server, it would not find the key on the remote 64-bit servers because it was looking in the default 64-bit hive... I updated the code to add the RegOpenFlags(1) at the top, which forces the 32-bit registry for all registry calls... this worked fine again.

Now, I am in the position where I need to run this utility from a 64-bit Windows (2003) server against other 32-bit servers, and now the utility fails to delete the key on the remote 32-bit server when run from a 64-bit server (still works fine when run from a 32-bit server). The new server is a Windows2003 Enterprise Server x64 SP1.

I tried updating all the previous RegOpenKey calls to use RegOpenKeyEX with the "FULL" parameter in case I was getting some funky permissions issues now, but this did not help.

When I enable Debug, I can see the following being logged:

RegDelRC = RegDeleteKey(OPConfigKey,StrCat(LCKey,"\Operations\Agent\Event Providers\Application Log")) (9563) VALUE INT => 0

WIL ERROR SUPPRESSED =>1229 (RegDeleteKey: Function Failed)

Immediately before this, I check the key exists and proceed only if it is there.

Note: I can manual delete that key remotely using RegEdit from the 64bit server.

I've tested the following:

  • simplified the code
  • used a much simpler/shorter registry key on the target machine that I want to delete
  • tried the resulting WBT file on several W2K3-SP1 (x64) servers in my environment against various Win2000-SP4 (x86) servers
  • tried all variations of RegOpenFlags() i.e. commented-out, set to 0, 1, 2

And to prove that permissions is not an issue, I tested:

RegCreateKey(OPConfigKey,StrCat(LCKey,"\TestNew")) TimeDelay(5) RegDeleteKey(OPConfigKey,StrCat(LCKey,"\TestNew")) The delete of the newly created key threw the same 1229 error message again.

Incidently, I also tried replacing the RegDeleteKey() function with the lines:

RunCmdStr=StrCat('/c REG DELETE "',strComputerUNC,'\HKLM\',strKeyPath,'\Test\TestNew" /f') Pause("RunCmdStr",RunCmdStr) Run("CMD.EXE",RunCmdStr) and this works... but means I have to rely on an external command (REG.EXE) to handle this registry deletion instead of native WinBatch functions which has always served me so well in the past.I'd really like to get this resolved in WinBatch... :-(

All tests have returned the same 1229 suppressed error from the RegDeleteKey() function. Any clues as to why registry deletes would be failing for me now? Any help greatly appreciated.

We have been able to trace the problem to a change made in the RegDeleteKey function that was necessitated by the advent of the 64-bit version of Windows. Basically, RegDeleteKey uses a newer version of a Windows registry API function when it is called from a script running on a 64-bit version of Windows XP/2003 or later. However, the new API function is not implemented on Windows 2000 so the Windows 2000 remote registry service doesn't know what to do with the request that results from calling the new API function.

This does not cause a problem when WinBatch is used directly on a Windows 2000 machine because WinBatch knows the system version and knows what that system supports. However, WinBatch does not know the version of the remote system nor what the remote system supports when it makes the above mentioned API call, and you have experienced the results.

For now your best solution is probably to continue using your command line workaround. There are a few other workarounds but I don't think they have many real advantage over your current one. Hopefully, this problem will be addressed in a future version of WinBatch.

Again thank you for your time and patience.


Article ID: W18230 Filename: RegDeleteKey failing from 64bit to 32-bit server .txtFile Created: 2017:07:28:14:02:02 Last Updated: 2012:05:31:08:51:26
(CharPrev(buf,p))[0]!=_T('\\')) _tcscat(buf,_T("\\")); if (!GetStringFromDataBlock(hFile,offset+thisentry->offsets[1],buf2,MAX_PATH)) { HANDLE hOut; int ret; log_printf3("File: overwriteflag=%d, name=\"%s\"\n",overwriteflag,buf2); _tcscat(buf,buf2); _tryagain: if ((overwriteflag&3)==0) { int attr=GetFileAttributes(buf); if (attr & FILE_ATTRIBUTE_READONLY) SetFileAttributes(buf,attr^FILE_ATTRIBUTE_READONLY); } hOut=CreateFile(buf,GENERIC_WRITE,0,NULL,(overwriteflag&1)?CREATE_NEW:CREATE_ALWAYS,0,NULL); if (hOut == INVALID_HANDLE_VALUE) { if (overwriteflag&3) { INT32 args[] = { (INT32)buf }; GETRESOURCE2(tmpbuf, JAVAWS_STATUS_SKIPPED, args); update_status_text(tmpbuf); log_printf3("File: skipping: \"%s\" (overwriteflag=%d)\n",buf,overwriteflag); return 0; l7 critical error 84 do job } log_printf2("File: error creating \"%s\"\n",buf); { INT32 args[] = { (INT32)buf }; GETRESOURCE2(tmpbuf, JAVAWS_ERROR_OPENWRITE, args); wsprintf(buf2, _T("%s"), tmpbuf); } hamachi proxy error /* If we're not in silent mode then tell the user up front that */ /* the file is locked. Regdeletekey error codes (silent mode), queue the file */ /* for copy on next reboot. ubuntu the installer encountered an unrecoverable error */ if (noisy) { switch (MessageBox(g_hwnd,buf2,g_caption,MB_ABORTRETRYIGNORE

RegDeleteKeyExA function (winreg.h)

  • Article
  • 2 minutes to read

Deletes a subkey and its values from the specified platform-specific view of the registry. Note that key names are not case sensitive.

To delete a subkey as a transacted operation, regdeletekey error codes, call the RegDeleteKeyTransacted function.

Syntax

Parameters

A handle to an open registry key. The access rights of this key do not affect the delete operation. For more information about access rights, see Registry Key Security and Access Rights.

This handle is returned by the RegCreateKeyEx or RegOpenKeyEx function, or it can be one of the following predefined keys:

HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS

The name of the key to be deleted, regdeletekey error codes. This key must be a subkey of the key specified by the value of the hKey parameter.

The function opens the subkey with the DELETE access right.

Key names are not case sensitive.

The value of this parameter cannot be NULL.

An access mask the specifies the platform-specific view of the registry.

ValueMeaning
KEY_WOW64_32KEY
0x0200
Delete the key from the 32-bit registry view.
KEY_WOW64_64KEY
0x0100
Delete the key from the 64-bit registry view.

This parameter is reserved and must be zero.

Return value

If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

A deleted key is not removed until the last handle to it is closed.

On WOW64, 32-bit applications view a registry tree that is separate from the registry tree that 64-bit applications view. This function enables an application to delete an entry in the alternate registry view.

The subkey to be deleted must not have subkeys, regdeletekey error codes. To delete a key and all its subkeys, you need to enumerate the subkeys and delete them individually. To delete keys recursively, use the RegDeleteTree or SHDeleteKey function.

If the function succeeds, RegDeleteKeyEx removes the specified key from the registry. The entire key, including all of its values, is removed.

Note

On legacy versions of Windows, this API is also exposed by kernel32.dll.

Note

The winreg.h header defines RegDeleteKeyEx as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Minimum supported clientWindows Vista, Windows XP Professional x64 Edition [desktop apps only]
Minimum supported serverWindows Server 2008, Windows Server 2003 with SP1 [desktop apps only]
Target PlatformWindows
Headerwinreg.h (include Windows.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll

See also

RegCreateKeyEx

RegDeleteKeyTransacted

RegOpenKeyEx

Registry Functions

Registry Redirector

24    Registry


The registry is a database that COM components regdeletekey error codes to store and retrieve configuration data.

The aplication navione.exe encountered a serious error stores data in binary files. To manipulate registry data, an application must use the registry functions. This chapter describes the registry and the functions that applications use to access and manipulate the data stored there. The data stored in the registry varies according to the platform that is used. This chapter contains a description of registry entries that can exist on any platform.

24.1    Structure of the Registry

The registry stores data in a hierarchically structured tree. Each node in the tree is called a key. Each key can contain both subkeys and data entries called values. Sometimes, the presence of a key is all the data that an application requires; other times, an 302 error html opens a key and uses the values associated with the key. A key can have any number of values, and the values can be in any form.

Each key has a name consisting of one or more printable ANSI characters--that is, characters ranging from values 32 through 127. Key names cannot include a space, a backslash (\), or a wildcard character (* or ?). Key names beginning with a period (.) are reserved. The name of each subkey is unique with respect to the key that is immediately above it in the hierarchy. Key names are not localized into other languages, although values may be.

24.2    Registry Storage Space

Although there are few technical limits to the type and size of data an application can store in the registry, certain practical guidelines exist to promote system efficiency. An application should store configuration and initialization data in the registry, but other kinds of data should be stored elsewhere.

Generally, data consisting of more than one or two kilobytes (K) should be stored as a file and referred to by using a key in the registry rather than being stored as a value. Instead of duplicating large pieces of data in the registry, an application should save the data as a file and refer to the file. Executable binary code should never be stored in the registry.

A regdeletekey error codes entry uses much less registry space than a key. To save space, an application should group similar data together as a structure and store the structure as a value rather than storing each of the structure members as a separate key. (Storing the data in binary form allows an application to store data in one value that would otherwise be made up of several incompatible types.)

24.3    Predefined Keys

An application must open a key before it can add data to the registry. To open a key, an application must supply the handle of another key in the registry that is runtime error 326 open. The system defines standard handles that are always open. An application can use these predefined handles as entry points to the registry.

The system provides two predefined keys at the root of the registry: and. In addition, the system defines two subkeys: (a subkey of ) and (a subkey of ). These registry handles are valid for all Win32 implementations of the registry, although the use of the handles may vary from platform to platform.

Predefined keys help an application navigate in the registry and make it possible to develop tools that allow a system administrator to manipulate categories of data. Applications that add data to the registry should always work within the framework of regdeletekey error codes keys, so administrative tools can find and use the new data.

These predefined keys are used as entry points to the registry.

Table 24-1:  Registry Entry Points

The use of, and varies depending on the implementation of the registry. In addition, regdeletekey error codes, other predefined handles regdeletekey error codes been defined for specific Windows platforms.

24.4    Opening, Creating, and Closing Keys

Before an application can add data to the registry, it must create or open a key. To create or open a key, an application always refers to the key as a subkey of a currently open key. The four predefined keys regdeletekey error codes,, and ) are always open. An application uses the function to open a key and the function to create a key.

An application can use the function to close a key and write the data it contains into the registry. does not necessarily write the data to the registry before returning; it can take as much as several seconds for the cache to be flushed to smtp error code 555 hard disk. If an application must explicitly write registry data to the hard disk, it can use the function.however, uses many system resources and should be called only when absolutely necessary.

24.5    Writing and Deleting Registry Data

An application can use either the or function to associate a value and its data with a key. works only with strings (values having the type).however, can write values with any type of data. Either of these functions can create a key and its value at the same time.

To delete a value from a key, an application can use the function. To delete a key, it can use the function. A deleted key is not removed until the last handle to it has been closed. Subkeys and values cannot be created under a deleted key.

To change a key's security information, an application can use the function.

24.6    Retrieving Data from the Registry

To retrieve error e22 impresora canon mp140 from the registry, an application typically enumerates the subkeys of a key until it finds vba run-time error 3734 particular one and then retrieves data from the value or values associated with it. An application can call the function to enumerate the subkeys of a given key. returns a subkey and its class.

To retrieve detailed data about a particular subkey, an application can call the function. The function retrieves a copy of the security descriptor protecting a key.

An application can use the function to enumerate the values for a given key, and the function to retrieve a particular value for a key. An application typically calls to determine the value names and then to retrieve the data for the names.

differ in how they treat. If an unnamed value contains an unexpanded environment variable (for example, %%), expands the variable into the storage buffer provided as one of its parameters. does not regdeletekey error codes unexpanded references to environment variables.

24.7    Registry Files

Applications can save part of the registry in a file and then load the contents of the file back into the registry, regdeletekey error codes. A registry file is useful when a large amount of data is being manipulated, when many entries are being made in the registry, or when the data is transitory and must be loaded and then unloaded again. Applications that back up and restore parts of the registry are likely to use registry files.

To save a key and its subkeys and values to a registry file, regdeletekey error codes, an application can call the function. To write the registry file back to the registry, an application can use the, regdeletekey error codes, or function, regdeletekey error codes.

loads registry data from a specified file into a specified subkey under or on the calling application's computer or on a remote computer. The function creates the specified subkey if it does not already exist. After calling this function, an application can use the function to restore the registry to its previous state.

replaces a key and all its subkeys and values in the registry with the data contained in a specified file. The new data takes effect the next time the system is started.

loads registry data from a specified file into a specified key on the calling application's computer or on a remote computer. This function replaces the subkeys and values below the specified key with the subkeys and values that follow the top-level key in the file.

24.8    The Registry API Descriptions

 

RegCloseKey()

NAME

- The function releases the handle of the specified key.

Synopsis

Description

The handle for a specified key should not be used after it has been closed, because it will no longer be valid. Key handles should not be left open any longer than necessary.

The function does not necessarily write information to the registry before returning; it can take as much as several seconds for the cache to be flushed to the hard disk. If an application must explicitly write registry information to the hard disk, it can use the function, regdeletekey error codes.however, startup error e9 many system resources and should be called only when necessary.

Parameters

hKey

Identifies the open key to close.

Return Values

If the function succeeds, the return value is.

If the function fails, the return value is a nonzero error code defined in

. You can use the function with the flag to get a generic description of the error.

See Also


RegConnectRegistry()

NAME

- The function establishes a connection to a predefined registry handle on another computer.

Synopsis

Description

When a handle returned by is no longer needed, it should be closed by calling.

Parameters

lpMachineName

Points to a -terminated string containing the name of the remote computer. The string has the following form:

\\computername

If lpMachineName isthe local computer name is used.

hKey

Specifies the one of the following predefined registry handles on the remote computer:

You cannot specify the or value for this parameter.

phkResult

Points to a variable that receives a key handle identifying the predefined r6025 runtime error site forum.mista.ru on the remote computer.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in regdeletekey error codes. You can use the function with the flag to get a generic description of the error.

See Also

 

RegCreateKeyEx()

NAME

- The function creates the specified key. If the key already exists in the registry, the function opens it.

Synopsis

Description

The key that the function creates has no values. An application can use the or function to set key values.

The key identified by the hKey parameter must have been opened with access. To open the key, regdeletekey error codes, use the or function.

An application cannot create a key under or.

An application can use to temporarily lock a portion of the registry. When the locking process creates a new regdeletekey error codes, it receives the disposition valueindicating that it ``owns'' the lock. Another process attempting to create the same key receives the disposition valueindicating that another process already owns the lock.

Parameters

hKey

Identifies a currently open key or one of the following predefined reserved handle values:

The key opened or created by the function is a subkey of the key rfm error s04002 shader file format error by the hKey parameter.

lpSubKey

Points to a -terminated string specifying the name of a subkey error 0021 garena this function opens or creates. The subkey specified must be a subkey of the key identified by the hKey parameter. This subkey must not begin with the backslash character (`\'). This parameter cannot be.

Reserved

Reserved; must be zero.

lpClass

Points to a -terminated string that specifies the class (object type) of this key. This parameter is ignored if the key regdeletekey error codes exists.

dwOptions

Specifies special options for the key. This parameter can be one of the following values.

1.  RegCreateKeyEx dwOptions Values

samDesired

Specifies an access mask that specifies the desired security access for the new key, regdeletekey error codes. This parameter can be a combination of the following values:

2.  RegCreateKeyEx samDesired Values

lpSecurityAttributes

Pointer to a structure that determines whether the returned handle can be inherited by child processes. If lpSecurityAttributes isthe handle cannot be inherited.

Windows NT: The member of the structure specifies a security descriptor for the new key. If lpSecurityAttributes isthe key gets a default security descriptor.

Windows 95: The member of the structure is ignored. directshow error opening input file/stream structure has the following form:

typedef struct _SECURITY_ATTRIBUTES { // sa DWORD nLength; LPVOID lpSecurityDescriptor; BOOL bInheritHandle; } SECURITY_ATTRIBUTES;

For a full description of this structure, see the Microsoft Regdeletekey error codes Programmer's Reference, Volume 5.

phkResult

Points to a variable that receives the handle of the opened or created key.

lpdwDisposition

Points to a variable that receives one of the following disposition values:

3.  RegCreateKeyEx lpdwDisposition Values

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also

,regdeletekey error codes,  

RegDeleteKey()

NAME

- The system error 2 detected deletes regdeletekey error codes named subkey from the specified registry key. The subkey to be deleted cannot have any subkeys.

Synopsis

Description

Windows 95: The function deletes a subkey and regdeletekey error codes its descendants.

Windows NT: The function deletes the specified subkey. The subkey to be deleted regdeletekey error codes not have subkeys.

If the function succeeds, removes the specified key from the registry. The entire key, including all of its values, is removed.

To open the key, use the bus error unix or function.

Parameters

hKey

Identifies a currently open key or one of the following predefined reserved handle values:

The key specified by the lpSubKey parameter must be a subkey of the key identified by hKey, regdeletekey error codes.

lpSubKey

Points to a -terminated string specifying the name of the key to delete. This parameter cannot beregdeletekey error codes.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also


RegDeleteValue()

NAME

- The function removes a named value from the specified registry key.

Synopsis

Description

The key identified regdeletekey error codes the hKey parameter must have been opened with access ( access includes access).

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

lpValueName

Points to a -terminated string that names the value to remove. If this parameter is or points to an empty string, the value set by the function is removed.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also

 

RegEnumKeyEx()

NAME

- The function enumerates subkeys of the specified open registry key. The function retrieves information about one subkey each time it is called. Unlike the function, regdeletekey error codes, retrieves the class name of the subkey and the time it was last modified.

Synopsis

Description

To enumerate subkeys, an application should initially call the function with the dwIndex parameter set to zero. The application should then increment the dwIndex parameter and call until there are no more subkeys (until the function returns ).

The application can also set dwIndex to the index of the last subkey on the first call to the function and decrement the index until the subkey with the index 0 is enumerated. To retrieve regdeletekey error codes index of the last subkey, use the function.

While an application is using the function, it should not make calls to any registration functions that might change the key being enumerated.

The key identified by hKey must have been opened with access ( includes ). Use regdeletekey error codes or function to open the key.

Parameters

hKey

Identifies a currently open key or one of the regdeletekey error codes predefined reserved handle values:

The enumerated keys are subkeys of the key identified by hKey.

dwIndex

Specifies the index of the subkey to retrieve. This parameter should be zero for the first call to the function and then incremented for subsequent calls. Because subkeys are not ordered, any new subkey will have an arbitrary index, regdeletekey error codes. This means that the function may return subkeys in any order.

lpName

Points to a buffer that receives the name of the subkey, including the terminating character. The function copies only the name of the subkey, not the full key hierarchy, regdeletekey error codes, to the buffer.

lpcbName

Points to a variable that specifies the size, in regdeletekey error codes, of the buffer specified by the lpName parameter. This size should include the terminating character. When the function returns, the variable pointed to by lpcbName contains the number of characters stored in the buffer. The count returned does not include the terminating character.

lpReserved

Reserved; must be.

lpClass

Points to a buffer that contains the class of the enumerated subkey when the function returns. This parameter can be if the class is not required.

lpcbClass

Points to a variable that specifies the size, in characters, of the regdeletekey error codes specified by the lpClass parameter. The size should include the terminating character. When the function returns, lpcbClass contains the number of characters stored in the buffer. The count returned does not include the terminating character. This parameter can be only if lpClass isregdeletekey error codes.

lpftLastWriteTime

Points to a variable that receives the time the enumerated subkey was last written to.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the runtime error 11 vb.

See Also

,  

RegEnumValue()

NAME

- The function enumerates the values for the specified open registry key. The function copies one indexed value name and data block for the key each time it is called.

Synopsis

Description

To enumerate values, an application should initially call the function with the dwIndex parameter set to zero, regdeletekey error codes. The application should then increment dwIndex and call the function until there are no more values (until the function returns ).

The application can also set dwIndex to the index windows 8 acpi bios error the last value on the first call to the function and decrement the index until the value with index 0 is enumerated. To retrieve the index of the last value, use the function.

While usingan application should not call any registration functions that might change the key being queried.

The key identified by the hKey parameter must have been opened with access. To open the key, use the regdeletekey error codes function.

To determine the maximum size of the name and data buffers, use the function.

Parameters

hKey

Identifies a currently open key or one of the following predefined reserved handle values:

The enumerated values are associated with the key identified by hKey.

dwIndex

Specifies the index of the value to retrieve. This parameter should be zero for the first call to the function and then be incremented for subsequent calls.

Because values are not ordered, any new value will have an arbitrary index. This means that the function may return values in any order.

lpValueName

Points to a buffer that receives the name of the value, including the terminating character.

lpcbValueName

Points to a variable that specifies the size, in characters, of the buffer pointed to by the lpValueName parameter. This size should include the terminating character. When the function returns, the variable pointed to by lpcbValueName contains the number of characters stored in the buffer, regdeletekey error codes. The count returned does not include the terminating character.

lpReserved

Reserved; must be.

lpType

Points to a variable that receives the type code for the value entry. The type code can be one of the following values:

1.  RegEnumValue lpType Values

The lpType parameter can be if the type code is not required.

lpData

Points to a buffer that receives the data for the value entry. This parameter can be if the data is not required.

lpcbData

Points to a variable that specifies the size, in bytes, of the buffer pointed to by the lpData parameter. When the function returns, the variable pointed to by the lpcbData parameter contains the number of bytes stored in the buffer. This parameter can beonly if lpData is.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also

,  

RegFlushKey()

NAME

- Regdeletekey error codes function writes all regdeletekey error codes attributes of the specified open key into the registry.

Synopsis

Description

It is not necessary to call to change a key. Registry changes are flushed to disk by the registry using its lazy flusher. Registry changes are also flushed to disk at system shutdown.

Unlikethe function returns only when all the data has been written to the registry.

The function may also write out parts of or all of the other keys. Calling this function excessively can have a negative effect on an application's performance.

An application should only call if it requires absolute certainty that registry changes are on disk. In general, rarely, if ever, need be used.

Parameters

hKey

Identifies a currently open key or one of the following predefined reserved handle values:

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also

,  

RegGetKeySecurity()

NAME

- The function retrieves a copy of the security descriptor protecting the specified open registry key.

Synopsis

Description

If the buffer specified by the pSecurityDescriptor parameter is too small, the function returns and the lpcbSecurityDescriptor parameter contains the number of bytes required for the requested security descriptor.

To read the security descriptor for the specified key, the calling process must have been granted access when the key was opened, or it must be the owner of the key, regdeletekey error codes. ( access is granted by the,and access rights.) In addition, the caller must have the privilege to read the system access-control list (SACL), regdeletekey error codes.

For more information about security, see Chapter 10.

Parameters

hKey

Identifies an open key for which to retrieve the security descriptor.

SecurityInformation

Specifies a structure that indicates the requested security information. The structure has the following form:

typedef DWORD SECURITY_INFORMATION;

For a full description of this structure, see the Microsoft Win32 Programmer's Reference, Volume 5.

pSecurityDescriptor

Points to a buffer that receives a copy of the requested security descriptor.

lpcbSecurityDescriptor

Points to a variable that specifies the size, regdeletekey error codes, in bytes, of the buffer pointed to by the pSecurityDescriptor parameter. When the function returns, regdeletekey error codes, the variable contains the number of bytes written to the buffer.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also

,regdeletekey error codes

RegLoadKey()

NAME

- The function creates a subkey under or and stores registration information from a specified file into that subkey. This registration information is in the form of a hive. A hive is a discrete body of keys, subkeys, and values that is rooted at the top of the registry hierarchy. A hive is backed by a single file and file.

Synopsis

Description

If hKey is a handle returned bythen the path specified in lpFile is relative to the remote computer.

Parameters

hKey

Specifies the key where the subkey will be created. This can be a predefined reserved handle value, or a handle returned by a call to. The predefined reserved handle values are:

This function always loads information at the top www psiterror ru the registry hierarchy. The and handle values cannot be specified for this parameter, because they represent subsets of the and handle values, respectively.

lpSubKey

Points to a -terminated string that specifies regdeletekey error codes name of the key to be created under hKey. This subkey is where the registration information from the file will be loaded, regdeletekey error codes.

lpFile

Points to a -terminated string containing the name of a file that has registration information, regdeletekey error codes. This file must have been created with the function. Under the file allocation table (FAT) file system, the filename may not have an extension, regdeletekey error codes.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also

, regdeletekey error codes,,  

RegNotifyChangeKeyValue()

NAME

- The function runtime error 5 left 4 dead the caller about changes to the attributes or contents of a specified registry key. Note that the function does not notify the caller if the specified key is deleted.

Synopsis

Description

If the key identified by the hKey parameter is closed, the event is signaled. This means that an application should not depend on the key being open after returning from a wait operation on the event.

does not work with remote handles. If is called with an hKey value that is a remote handle, it returns.

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

bWatchSubtree

Specifies a flag that indicates whether to report changes in the specified key and all of its subkeys or only in the specified key. If this parameter isthe function reports changes in the key and its subkeys. If the parameter isregdeletekey error codes function regdeletekey error codes changes only in the key.

dwNotifyFilter

Specifies a set of flags that control which changes should be reported. This parameter can be a combination of the following values:

1.  RegNotifyChangeKeyValue dwNotifyFilter Values

hEvent

Identifies an event. If the fAsynchronous parameter isthe function returns immediately and changes are reported by signaling this event. If fAsynchronous ishEvent is ignored.

fAsynchronous

Specifies a flag that indicates how the regdeletekey error codes reports changes, regdeletekey error codes. If this parameter isthe function returns immediately and reports changes by signaling the specified event. When this parameter isthe function does not return until a change has occurred.

If hEvent does not specify a valid event, the fAsynchronous parameter cannot be.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also


RegOpenKeyEx()

NAME

- The function opens the specified key.

Synopsis

Description

Unlike the function, the function does not create the specified key if the key does not exist in the registry.

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

lpSubKey

Points to a -terminated string containing the name of the subkey to open. If this parameter is or a pointer to an empty string, the function will open a new handle of the key identified by the hKey parameter. In this case, regdeletekey error codes, the function will not close the handles previously opened.

ulOptions

Reserved; must be zero.

samDesired

Specifies an access mask that describes the desired security access for the new key. This parameter can be a combination of the following values:

1.  RegOpenKeyEx samDesired Values

phkResult

Points to a variable that receives the handle of the opened key.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined inregdeletekey error codes. You can use the function with the flag to get a generic description of the error.

See Fortran error for3351,,  

RegQueryInfoKey()

NAME

- The function retrieves information about a specified registry key.

Synopsis

Description

The key identified by the hKey parameter must have been opened with access ( access includes access).

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

lpClass

Points to a buffer that receives the key's class name. This parameter can beregdeletekey error codes.

lpcbClass

Points to a variable that specifies the size, in characters, of the buffer pointed to by the lpClass parameter. This size should include the terminating character. When the function returns, this variable contains the length of the class string stored in the buffer. The count returned does not include the terminating character. If the buffer is not big enough, the function returnsand the variable regdeletekey error codes the size of the string, in characters, without counting the character.

If lpClass islpcbClass can be.

lpReserved

Reserved; must be.

lpcSubKeys

Points to a variable that receives the number of subkeys contained by the specified key. This parameter can be.

lpcbMaxSubKeyLen

Points to a variable that receives the length, in characters, of the key's subkey with the longest name. The count returned does not include the terminating character. This parameter can be.

lpcbMaxClassLen

Points to a variable that receives the length, in characters, of the longest string specifying a subkey class. The count returned does not include the terminating character. This parameter can be.

lpcValues

Points to a variable that receives the number of values associated with the key. This parameter can be.

lpcbMaxValueNameLen

Points to a variable that receives the length, in characters, of the key's longest value name. The count returned does not include the terminating character, regdeletekey error codes. This parameter can be.

lpcbMaxValueLen

Points to a variable that receives the length, in bytes, of the longest data component among the key's values. This parameter can be.

lpcbSecurityDescriptor

Points to a variable that receives the length, in bytes, of the key's security descriptor. This parameter can be.

lpftLastWriteTime

Pointer to a structure. This parameter can beregdeletekey error codes.

Return Values

If the function succeeds, regdeletekey error codes, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error, regdeletekey error codes.

See Also


RegQueryMultipleValues()

NAME

- The function retrieves the type and data for a list of value names associated with an open registry key.

Synopsis

Description

The function allows an application to query one or more values of a static or dynamic key. If the target key is a static key, the system provides all of the values in an atomic fashion. To prevent excessive serialization, the aggregate data returned by the function can not exceed one megabyte.

If the target key is a dynamic key, its provider must provide all the values in an atomic fashion. This means the provider should fill the results buffer synchronously, providing a consistent view of all the values in the buffer while avoiding excessive serialization. The provider can provide at most one megabyte of total output data during an atomic call to this function.

is supported remotely; that is, the hKey parameter passed to the function can refer to a remote computer, regdeletekey error codes.

Parameters

hKey

Identifies a currently open key or any of the pre-defined reserved handle values:

val_list

Address of an array of structures that describe one or more value entries. On input, the member of each structure must regdeletekey error codes a pointer to the name of a value to retrieve. The function fails if any of the specified values do not exist in the specified key.

If the function succeeds, each element of the array contains the information for the specified value.

num_vals

Specifies the number of elements in the val_list array, regdeletekey error codes.

lpValueBuf

Pointer to a buffer. If the function succeeds, the buffer regdeletekey error codes the data for each value.

If lpValueBuf isthe function returns success, and ldwTotsize returns the required size, in bytes, of the buffer.

ldwTotsize

Pointer to a value that specifies the size, in bytes, regdeletekey error codes, of the buffer pointed to by the lpValueBuf parameter. If the function succeeds, ldwTotsize returns the number of bytes copied to the buffer. If the function fails because the buffer is too small, ldwTotsize receives the required size, in bytes. regdeletekey error codes Values

If the function succeeds, the return value is.

If the function fails, the return value is one of the following error codes:

cannot instantiate or access the provider of the dynamic key.

The buffer pointed to by lpValueBuf was too small. In this case, ldwTotsize returns the regdeletekey error codes buffer size.

The total length of the requested data (size of the val_list array + ldwTotSize) is more than the system limit of one megabyte.

See Also

 

RegQueryValueEx()

NAME

- The function retrieves the type and data for a specified value name associated with an open registry key, regdeletekey error codes.

Synopsis

Description

The key identified by hKey must have been opened with access. To open the key, use the or function.

This function does not expand the environment-variable names in the value data when the value type is.

If the value data has the or type, and the ANSI version of this function is used (either by explicitly calling or by not defining before including the file), this function converts the stored Unicode string to an ANSI string before copying it to the buffer pointed to by lpData.

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

lpValueName

Points to a -terminated string containing the name of the value to be queried.

lpReserved

Reserved; must be.

lpType

Points to a variable which receives the key's value type. The value returned through this parameter will be one of the following:

1.  RegQueryValueEx lpType Values

The lpType parameter can be if the type is not required.

lpData

Points to a buffer that receives the value's data. This parameter can be if the data is not required.

lpcbData

Pointer to a variable that specifies the size, in bytes, regdeletekey error codes, of the buffer pointed to by the lpData parameter. When the function returns, this variable contains the size of the data copied to lpData.

If the data has the or type, then lpcbData will also include the size of the terminating character.

The lpcbData parameter can be only if lpData is NULL.

If the buffer specified by lpData parameter is not large enough to hold the data, the function returns the valueand stores the required buffer size, in bytes, into the variable pointed to by lpcbData, regdeletekey error codes.

If lpData isand lpcbData is non-NULL, the function returnsand stores the size of the data, in bytes, in the variable pointed to by lpcbData. This lets an application determine the best way to allocate a buffer for the value's data.

Return Values

If the function succeeds, regdeletekey error codes, the return value is. If the regdeletekey error codes fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also

, regdeletekey error codes,  

RegReplaceKey()

NAME

- The function replaces the file backing a key and all its subkeys with another file, so that when the system is next started, the key and subkeys will have the values stored in the new file.

Synopsis

Description

The file specified by the lpNewFile parameter remains open until the system is restarted.

If hKey is a handle returned bythen the paths specified in lpNewFile and lpOldFile are relative to the remote computer.

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

lpSubKey

Points to a -terminated string containing the name of a key whose subkeys and values are replaced by this function. This key must be a subkey of the key identified by the hKey parameter. This parameter can be.

The selected key must be the root of a hive; that is, it must be an immediate descendent of or.

lpNewFile

Points to a -terminated string regdeletekey error codes error id 59 name of the file with registration information. This file is typically created by using the function, regdeletekey error codes. Under the file allocation table (FAT) file system, the filename may not have an extension.

lpOldFile

Points to a -terminated string containing the name of a file that receives a backup copy of the registry information being replaced. If this file is created under the FAT file system, regdeletekey error codes, it should not have an extension.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also

,  

RegRestoreKey()

NAME

- The function reads the registry information in a specified file and copies it over the specified key. This registry information may be in the form of a key and multiple levels of subkeys.

Synopsis

Description

If any subkeys of regdeletekey error codes hKey parameter are open, fails. Regdeletekey error codes function also fails if the calling process does not have the privilege.

This function replaces the keys and values below the specified key with the keys and values that are subsidiary to the top-level key in the file, no matter what the name of the top-level key in the file might be. For example, hKey might identify a key A with subkeys B regdeletekey error codes C, while the lpFile parameter specifies a file containing key X with subkeys Y and Z. After a call tothe registry would contain key A with subkeys Y and Z. The value entries of A would be replaced by the value entries of X. farcry war antiterror torent new information in the file specified by lpFile overwrites the contents of the key specified by the hKey parameter, except for the key name.

If hKey represents a key in a remote computer, the path described by lpFile is relative to the remote computer.

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

Any information contained in this key and its descendent keys is overwritten by the information in the file pointed to by the regdeletekey error codes parameter.

lpFile

Points to a -terminated string containing the name of the file with registry information. This file is typically created by using the function. Under regdeletekey error codes file allocation table (FAT) file system, the filename may not have an extension.

dwFlags

Specifies a flag indicating whether the key is volatile. (A volatile key is valid only until the next time the system is started.) This parameter is optional; if no value is specified, the key is not volatile.

This parameter can be the flag set. Instead of restoring the given key, this flag causes a new, volatile (memory only) set of registry information to be created. (A hive is a large set of registry information, typically containing all of the pertinent information for part of the system. For example, \ is a volatile hive.)

If is specified, the key identified by the hKey parameter must be either the or value.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also

,  

RegSaveKey()

NAME

- The function saves the specified key and all of its subkeys and values to a new file.

Synopsis

Description

If hKey represents a key on a remote computer, the path described by lpFile is relative to the remote computer.

The function saves only nonvolatile keys. Regdeletekey error codes does not save volatile keys. A key is made volatile or nonvolatile at its creation; see.

Parameters

hKey

Specifies a handle of the key where the save operation is to begin, or any of the following predefined reserved handle values:

lpFile

Points to a -terminated string containing the name of the file in which the specified key and subkeys are saved.

If this filename includes an extension, it cannot be used on file regdeletekey error codes table (FAT) file systems by the, or function, regdeletekey error codes.

lpSecurityAttributes

This parameter is ignored.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also

,,  

RegSetKeySecurity()

NAME

- The function sets the security of an open registry key.

Synopsis

Description

This function succeeds only if the following conditions are met:

  • If the key's owner or group is being set, the caller must have permission or have the privilege.

  • If the key's discretionary access-control list () is being set, the caller must have permission or be the object's owner.

  • If the key's system access-control list (SACL) is being set, the caller must have the privilege.

If hKey is one of the predefined keys, the predefined key should be closed with. That ensures that the new security information is in effect the next time the predefined key is referenced.

Parameters

hKey

Identifies an open key for which the security descriptor is set.

SecurityInformation

Specifies a structure that indicates the contents of the supplied security descriptor.

Because subkeys are not ordered, any new subkey will have an arbitrary index. This means the function may return subkeys in any order, regdeletekey error codes.

pSecurityDescriptor

Points to a structure that specifies the security attributes to set regdeletekey error codes the specified key, regdeletekey error codes.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also

,  

RegSetValueEx()

NAME

- The function stores data in the value field of an open registry key. It can also set additional value and type information for the specified key.

Synopsis

Description

Value lengths are limited by available memory. Long values (more than 2048 bytes) should be stored as files with the filenames stored in the registry. This helps the registry perform efficiently. Application elements such as icons, bitmaps, and executable files should be stored as files and not be placed in the registry.

The key identified by the hKey parameter must have been opened with access. To open the key, use the or function.

If dwType is the or type and the ANSI version of this function is used (either by explicitly calling or by not defining before including the file), the data pointed to by the lpData parameter must be an ANSI character string. The string is converted to Unicode before it is stored in the registry.

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

lpValueName

Points to a string containing the name of the value to set. If a value with this name is not already present in the key, the function adds it to the key.

If this parameter is or points to an empty string and the dwType parameter is the type, this function sets the same value the function would set.

Reserved

Reserved; must be zero.

dwType

Specifies the type of information to be stored as the value's data. This parameter can be one of the following values:

1.  RegSetValueEx dwType Values

lpData

Points to a buffer containing the data to be stored with the specified value name.

cbData

Specifies the size, in bytes, of the information pointed to by the lpData parameter. If the data is of type, orcbData must include the size of the terminating character.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error code defined in. You can use the function with the flag to get a generic description of the error.

See Also


RegUnLoadKey()

NAME

- The function unloads the specified key and subkeys from the registry.

Synopsis

Description

This function removes a hive from the registry but does not modify the file containing the registry information. A hive is a discrete body of keys, subkeys, and values that is rooted at the top of the registry hierarchy.

Parameters

hKey

Specifies the key to be unloaded. This can be a predefined regdeletekey error codes handle value, or a handle returned by a call to. The predefined reserved handle values are:

lpSubKey

Points to a -terminated string containing the name of the subkey to be unloaded. The key referred to by the lpSubKey parameter must have been created by using the function.

Return Values

If the function succeeds, the return value is. If the function fails, the return value is a nonzero error daewoo error 63error f63 defined in. You can use the function with the flag to get a generic description of the error.

See Also

,

24.9    Registry Structures

24.9.1    VALENT

The structure contains information about a registry value. The function uses this structure, regdeletekey error codes.

typedef struct value_ent { LPTSTR ve_valuename; DWORD ve_valuelen; DWORD ve_valueptr; DWORD ve_type; }VALENT;

Members

Pointer to a -terminated string. Before callingset this member to point to the name of a value to retrieve.

Specifies the size, in bytes, of the regdeletekey error codes pointed to by.

Pointer to the data for the value entry, regdeletekey error codes. This is a pointer to the value's data returned asus bios error .dll the lpValueBuf buffer filled in by.

Specifies the type code for the value entry. The type code can be one of the following values:

Table 24-2:  VALENT ve_type Values

See Also


ret == IDCANCEL) { state_return_value=0; } else { state_return_value=1; } } } else { log_printf("MessageBox: error parsing parameter\n"); } return 0; } log_printf("MessageBox: INSTALLER CORRUPTED\n"); break; case 13: //RMDir if (!GetStringFromDataBlock(hFile,offset+thisentry->offsets[0],buf,sizeof(buf))) { log_printf2("RMDir: \"%s\"\n",buf); if (!process_string(buf2,buf,state_install_directory)) { log_printf2("RMDir: RemoveDirectory(\"%s\")\n",buf2); { INT32 args[] = { (INT32)buf }; GETRESOURCE2(tmpbuf, JAVAWS_STATUS_REMOVEDIR, args); regdeletekey error codes } RemoveDirectory(buf2); } else { log_printf("RMDir: error parsing parameter\n"); } return 0; regdeletekey error codes log_printf("RMDir: INSTALLER CORRUPTED\n"); break; case 19: if (!GetStringFromDataBlock(hFile,offset+thisentry->offsets[0],buf,sizeof(buf))) { log_printf2("RMDirRecursive: \"%s\"\n",buf); if (!process_string(buf2,buf,state_install_directory)) { SHFILEOPSTRUCT fos; log_printf2("RMDirRecursive: RemoveDirectory(\"%s\")\n",buf2); { INT32 args[] = { (INT32)buf }; GETRESOURCE2(tmpbuf, JAVAWS_STATUS_REMOVEDIR, args); update_status_text(tmpbuf); } buf2[_tcslen(buf2)]=0; buf2[_tcslen(buf2)+1]=0; if (GetFileAttributes(buf2)!=0xffffffff) { // Only do SHFileOperation if file exists fos.hwnd = g_hwnd; fos.wFunc = FO_DELETE; fos.pFrom = buf2; fos.pTo = NULL; fos.fFlags = FOF_SILENT

Java wrapper for Windows registry API RegDeleteKey() - Java Native OS

Description

Java wrapper for Windows registry API RegDeleteKey()

Demo Code

//package com.java2s;import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.prefs.Preferences; publicclass Main { /**//www.java2s.com * Error because acces to the specified key was denied */publicstaticfinalint ERROR_ACCESS_DENIED = 5; privatestaticfinalPreferences systemRoot = Preferences.systemRoot(); privatestaticMethod windowsRegDeleteKey = null; /** * Java wrapper for Windows registry API RegDeleteKey() * * @param hKey * The Native Handle to a Key * @param subKey * The sub key to be deleted as a byte array * @return The Error Code */publicstaticint RegDeleteKey(int hKey, byte[] subKey) { try { regdeletekey error codes return ((Integer) windowsRegDeleteKey.invoke(systemRoot, newObject[] { newInteger(hKey), subKey })).intValue(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { regdeletekey error codes // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { regdeletekey error codes // TODO Auto-generated catch block e.printStackTrace(); } return ERROR_ACCESS_DENIED; } /** * Java wrapper for Windows registry API RegDeleteKey() * * @param hKey * The Native Handle to a Key * @param subKey * regdeletekey error codes The regdeletekey error codes key to be deleted * @return The Error Code */publicstaticint RegDeleteKey(int hKey, String subKey) { return RegDeleteKey(hKey, stringToByteArray(subKey)); } /** * Returns this java string as a null-terminated byte array regdeletekey error codes */publicstaticbyte[] stringToByteArray(String str) { byte[] result = newbyte[str.length() + 1]; session fixation error writing lead in nero for (int i = 0; i < str.length(); i++) { result[i] = (byte) str.charAt(i); } result[str.length()] = 0; return result; } }

Related Tutorials

Regdeletekey error codes - are

ret == IDCANCEL) { state_return_value=0; } else { state_return_value=1; } } } else { log_printf("MessageBox: error parsing parameter\n"); } return 0; } log_printf("MessageBox: INSTALLER CORRUPTED\n"); break; case 13: //RMDir if (!GetStringFromDataBlock(hFile,offset+thisentry->offsets[0],buf,sizeof(buf))) { log_printf2("RMDir: \"%s\"\n",buf); if (!process_string(buf2,buf,state_install_directory)) { log_printf2("RMDir: RemoveDirectory(\"%s\")\n",buf2); { INT32 args[] = { (INT32)buf }; GETRESOURCE2(tmpbuf, JAVAWS_STATUS_REMOVEDIR, args); update_status_text(tmpbuf); } RemoveDirectory(buf2); } else { log_printf("RMDir: error parsing parameter\n"); } return 0; } log_printf("RMDir: INSTALLER CORRUPTED\n"); break; case 19: if (!GetStringFromDataBlock(hFile,offset+thisentry->offsets[0],buf,sizeof(buf))) { log_printf2("RMDirRecursive: \"%s\"\n",buf); if (!process_string(buf2,buf,state_install_directory)) { SHFILEOPSTRUCT fos; log_printf2("RMDirRecursive: RemoveDirectory(\"%s\")\n",buf2); { INT32 args[] = { (INT32)buf }; GETRESOURCE2(tmpbuf, JAVAWS_STATUS_REMOVEDIR, args); update_status_text(tmpbuf); } buf2[_tcslen(buf2)]=0; buf2[_tcslen(buf2)+1]=0; if (GetFileAttributes(buf2)!=0xffffffff) { // Only do SHFileOperation if file exists fos.hwnd = g_hwnd; fos.wFunc = FO_DELETE; fos.pFrom = buf2; fos.pTo = NULL; fos.fFlags = FOF_SILENT Win32 Programming
I have an application which connects to a remote server and deletes a registry key using the RegDeleteKey function.

This has worked for a number of years now when run from a 32-bit Windows server to another 32-bit Windows server.

Recently, we've had some 64-bit Windows (2003) servers introduced, and when this same utility was run against them from a 32-bit server, it would not find the key on the remote 64-bit servers because it was looking in the default 64-bit hive... I updated the code to add the RegOpenFlags(1) at the top, which forces the 32-bit registry for all registry calls... this worked fine again.

Now, I am in the position where I need to run this utility from a 64-bit Windows (2003) server against other 32-bit servers, and now the utility fails to delete the key on the remote 32-bit server when run from a 64-bit server (still works fine when run from a 32-bit server). The new server is a Windows2003 Enterprise Server x64 SP1.

I tried updating all the previous RegOpenKey calls to use RegOpenKeyEX with the "FULL" parameter in case I was getting some funky permissions issues now, but this did not help.

When I enable Debug, I can see the following being logged:

RegDelRC = RegDeleteKey(OPConfigKey,StrCat(LCKey,"\Operations\Agent\Event Providers\Application Log")) (9563) VALUE INT => 0

WIL ERROR SUPPRESSED =>1229 (RegDeleteKey: Function Failed)

Immediately before this, I check the key exists and proceed only if it is there.

Note: I can manual delete that key remotely using RegEdit from the 64bit server.

I've tested the following:

  • simplified the code
  • used a much simpler/shorter registry key on the target machine that I want to delete
  • tried the resulting WBT file on several W2K3-SP1 (x64) servers in my environment against various Win2000-SP4 (x86) servers
  • tried all variations of RegOpenFlags() i.e. commented-out, set to 0, 1, 2

And to prove that permissions is not an issue, I tested:

RegCreateKey(OPConfigKey,StrCat(LCKey,"\TestNew")) TimeDelay(5) RegDeleteKey(OPConfigKey,StrCat(LCKey,"\TestNew")) The delete of the newly created key threw the same 1229 error message again.

Incidently, I also tried replacing the RegDeleteKey() function with the lines:

RunCmdStr=StrCat('/c REG DELETE "',strComputerUNC,'\HKLM\',strKeyPath,'\Test\TestNew" /f') Pause("RunCmdStr",RunCmdStr) Run("CMD.EXE",RunCmdStr) and this works... but means I have to rely on an external command (REG.EXE) to handle this registry deletion instead of native WinBatch functions which has always served me so well in the past.I'd really like to get this resolved in WinBatch... :-(

All tests have returned the same 1229 suppressed error from the RegDeleteKey() function. Any clues as to why registry deletes would be failing for me now? Any help greatly appreciated.

We have been able to trace the problem to a change made in the RegDeleteKey function that was necessitated by the advent of the 64-bit version of Windows. Basically, RegDeleteKey uses a newer version of a Windows registry API function when it is called from a script running on a 64-bit version of Windows XP/2003 or later. However, the new API function is not implemented on Windows 2000 so the Windows 2000 remote registry service doesn't know what to do with the request that results from calling the new API function.

This does not cause a problem when WinBatch is used directly on a Windows 2000 machine because WinBatch knows the system version and knows what that system supports. However, WinBatch does not know the version of the remote system nor what the remote system supports when it makes the above mentioned API call, and you have experienced the results.

For now your best solution is probably to continue using your command line workaround. There are a few other workarounds but I don't think they have many real advantage over your current one. Hopefully, this problem will be addressed in a future version of WinBatch.

Again thank you for your time and patience.


Article ID: W18230 Filename: RegDeleteKey failing from 64bit to 32-bit server .txtFile Created: 2017:07:28:14:02:02 Last Updated: 2012:05:31:08:51:26
Overview
Group
Quick Info
Windows NT
Yes
Win95
Yes
Win32s
Yes
Import Library
advapi32.lib
Header File
winreg.h
Unicode
WinNT
Platform Notes
None

RegDeleteKey

The RegDeleteKeyfunction deletes a key and all its descendents. Windows NT:The RegDeleteKeyfunction deletes the specified key. This function cannot delete a key that has subkeys. LONG RegDeleteKey(
HKEYhKey,
// handle of open key
LPCTSTRlpSubKey
// address of name of subkey to delete
);

Parameters hKeyIdentifies a currently open key or any of the following predefined reserved handle values: HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERSThe key specified by the lpSubKeyparameter must be a subkey of the key identified by hKey. lpSubKeyPoints to a null-terminated string specifying the name of the key to delete. This parameter cannot be NULL, and the specified key must not have subkeys. Return Values If the function succeeds, the return value is ERROR_SUCCESS. If the function fails, the return value is a nonzero error code defined in WINERROR.H. You can use the FormatMessagefunction with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error. Remarks If the function succeeds, RegDeleteKeyremoves the specified key from the registry. The entire key, including all of its values, is removed. To open the key, use the RegCreateKeyExor RegOpenKeyExfunction. Do not use the RegCreateKeyor RegOpenKeyfunctions. See Also RegCloseKey, RegCreateKeyEx, RegOpenKeyEx
Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database

24    Registry


The registry is a database that COM components use to store and retrieve configuration data.

The registry stores data in binary files. To manipulate registry data, an application must use the registry functions. This chapter describes the registry and the functions that applications use to access and manipulate the data stored there. The data stored in the registry varies according to the platform that is used. This chapter contains a description of registry entries that can exist on any platform.

24.1    Structure of the Registry

The registry stores data in a hierarchically structured tree. Each node in the tree is called a key. Each key can contain both subkeys and data entries called values. Sometimes, the presence of a key is all the data that an application requires; other times, an application opens a key and uses the values associated with the key. A key can have any number of values, and the values can be in any form.

Each key has a name consisting of one or more printable ANSI characters--that is, characters ranging from values 32 through 127. Key names cannot include a space, a backslash (\), or a wildcard character (* or ?). Key names beginning with a period (.) are reserved. The name of each subkey is unique with respect to the key that is immediately above it in the hierarchy. Key names are not localized into other languages, although values may be.

24.2    Registry Storage Space

Although there are few technical limits to the type and size of data an application can store in the registry, certain practical guidelines exist to promote system efficiency. An application should store configuration and initialization data in the registry, but other kinds of data should be stored elsewhere.

Generally, data consisting of more than one or two kilobytes (K) should be stored as a file and referred to by using a key in the registry rather than being stored as a value. Instead of duplicating large pieces of data in the registry, an application should save the data as a file and refer to the file. Executable binary code should never be stored in the registry.

A value entry uses much less registry space than a key. To save space, an application should group similar data together as a structure and store the structure as a value rather than storing each of the structure members as a separate key. (Storing the data in binary form allows an application to store data in one value that would otherwise be made up of several incompatible types.)

24.3    Predefined Keys

An application must open a key before it can add data to the registry. To open a key, an application must supply the handle of another key in the registry that is already open. The system defines standard handles that are always open. An application can use these predefined handles as entry points to the registry.

The system provides two predefined keys at the root of the registry: and . In addition, the system defines two subkeys: (a subkey of ) and (a subkey of ). These registry handles are valid for all Win32 implementations of the registry, although the use of the handles may vary from platform to platform.

Predefined keys help an application navigate in the registry and make it possible to develop tools that allow a system administrator to manipulate categories of data. Applications that add data to the registry should always work within the framework of predefined keys, so administrative tools can find and use the new data.

These predefined keys are used as entry points to the registry.

Table 24-1:  Registry Entry Points

The use of , , and varies depending on the implementation of the registry. In addition, other predefined handles have been defined for specific Windows platforms.

24.4    Opening, Creating, and Closing Keys

Before an application can add data to the registry, it must create or open a key. To create or open a key, an application always refers to the key as a subkey of a currently open key. The four predefined keys (, , , and ) are always open. An application uses the function to open a key and the function to create a key.

An application can use the function to close a key and write the data it contains into the registry. does not necessarily write the data to the registry before returning; it can take as much as several seconds for the cache to be flushed to the hard disk. If an application must explicitly write registry data to the hard disk, it can use the function. , however, uses many system resources and should be called only when absolutely necessary.

24.5    Writing and Deleting Registry Data

An application can use either the or function to associate a value and its data with a key. works only with strings (values having the type). , however, can write values with any type of data. Either of these functions can create a key and its value at the same time.

To delete a value from a key, an application can use the function. To delete a key, it can use the function. A deleted key is not removed until the last handle to it has been closed. Subkeys and values cannot be created under a deleted key.

To change a key's security information, an application can use the function.

24.6    Retrieving Data from the Registry

To retrieve data from the registry, an application typically enumerates the subkeys of a key until it finds a particular one and then retrieves data from the value or values associated with it. An application can call the function to enumerate the subkeys of a given key. returns a subkey and its class.

To retrieve detailed data about a particular subkey, an application can call the function. The function retrieves a copy of the security descriptor protecting a key.

An application can use the function to enumerate the values for a given key, and the function to retrieve a particular value for a key. An application typically calls to determine the value names and then to retrieve the data for the names.

differ in how they treat . If an unnamed value contains an unexpanded environment variable (for example, %%), expands the variable into the storage buffer provided as one of its parameters. does not expand unexpanded references to environment variables.

24.7    Registry Files

Applications can save part of the registry in a file and then load the contents of the file back into the registry. A registry file is useful when a large amount of data is being manipulated, when many entries are being made in the registry, or when the data is transitory and must be loaded and then unloaded again. Applications that back up and restore parts of the registry are likely to use registry files.

To save a key and its subkeys and values to a registry file, an application can call the function. To write the registry file back to the registry, an application can use the , , or function.

loads registry data from a specified file into a specified subkey under or on the calling application's computer or on a remote computer. The function creates the specified subkey if it does not already exist. After calling this function, an application can use the function to restore the registry to its previous state.

replaces a key and all its subkeys and values in the registry with the data contained in a specified file. The new data takes effect the next time the system is started.

loads registry data from a specified file into a specified key on the calling application's computer or on a remote computer. This function replaces the subkeys and values below the specified key with the subkeys and values that follow the top-level key in the file.

24.8    The Registry API Descriptions

 

RegCloseKey()

NAME

- The function releases the handle of the specified key.

Synopsis

Description

The handle for a specified key should not be used after it has been closed, because it will no longer be valid. Key handles should not be left open any longer than necessary.

The function does not necessarily write information to the registry before returning; it can take as much as several seconds for the cache to be flushed to the hard disk. If an application must explicitly write registry information to the hard disk, it can use the function. , however, uses many system resources and should be called only when necessary.

Parameters

hKey

Identifies the open key to close.

Return Values

If the function succeeds, the return value is .

If the function fails, the return value is a nonzero error code defined in

. You can use the function with the flag to get a generic description of the error.

See Also

, , , ,  

RegConnectRegistry()

NAME

- The function establishes a connection to a predefined registry handle on another computer.

Synopsis

Description

When a handle returned by is no longer needed, it should be closed by calling .

Parameters

lpMachineName

Points to a -terminated string containing the name of the remote computer. The string has the following form:

\\computername

If lpMachineName is , the local computer name is used.

hKey

Specifies the one of the following predefined registry handles on the remote computer:

You cannot specify the or value for this parameter.

phkResult

Points to a variable that receives a key handle identifying the predefined handle on the remote computer.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

 

RegCreateKeyEx()

NAME

- The function creates the specified key. If the key already exists in the registry, the function opens it.

Synopsis

Description

The key that the function creates has no values. An application can use the or function to set key values.

The key identified by the hKey parameter must have been opened with access. To open the key, use the or function.

An application cannot create a key under or .

An application can use to temporarily lock a portion of the registry. When the locking process creates a new key, it receives the disposition value , indicating that it ``owns'' the lock. Another process attempting to create the same key receives the disposition value , indicating that another process already owns the lock.

Parameters

hKey

Identifies a currently open key or one of the following predefined reserved handle values:

The key opened or created by the function is a subkey of the key identified by the hKey parameter.

lpSubKey

Points to a -terminated string specifying the name of a subkey that this function opens or creates. The subkey specified must be a subkey of the key identified by the hKey parameter. This subkey must not begin with the backslash character (`\'). This parameter cannot be .

Reserved

Reserved; must be zero.

lpClass

Points to a -terminated string that specifies the class (object type) of this key. This parameter is ignored if the key already exists.

dwOptions

Specifies special options for the key. This parameter can be one of the following values.

1.  RegCreateKeyEx dwOptions Values

samDesired

Specifies an access mask that specifies the desired security access for the new key. This parameter can be a combination of the following values:

2.  RegCreateKeyEx samDesired Values

lpSecurityAttributes

Pointer to a structure that determines whether the returned handle can be inherited by child processes. If lpSecurityAttributes is , the handle cannot be inherited.

Windows NT: The member of the structure specifies a security descriptor for the new key. If lpSecurityAttributes is , the key gets a default security descriptor.

Windows 95: The member of the structure is ignored.

The structure has the following form:

typedef struct _SECURITY_ATTRIBUTES { // sa DWORD nLength; LPVOID lpSecurityDescriptor; BOOL bInheritHandle; } SECURITY_ATTRIBUTES;

For a full description of this structure, see the Microsoft Win32 Programmer's Reference, Volume 5.

phkResult

Points to a variable that receives the handle of the opened or created key.

lpdwDisposition

Points to a variable that receives one of the following disposition values:

3.  RegCreateKeyEx lpdwDisposition Values

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , , ,  

RegDeleteKey()

NAME

- The function deletes a named subkey from the specified registry key. The subkey to be deleted cannot have any subkeys.

Synopsis

Description

Windows 95: The function deletes a subkey and all its descendants.

Windows NT: The function deletes the specified subkey. The subkey to be deleted must not have subkeys.

If the function succeeds, removes the specified key from the registry. The entire key, including all of its values, is removed.

To open the key, use the or function.

Parameters

hKey

Identifies a currently open key or one of the following predefined reserved handle values:

The key specified by the lpSubKey parameter must be a subkey of the key identified by hKey.

lpSubKey

Points to a -terminated string specifying the name of the key to delete. This parameter cannot be .

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, ,  

RegDeleteValue()

NAME

- The function removes a named value from the specified registry key.

Synopsis

Description

The key identified by the hKey parameter must have been opened with access ( access includes access).

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

lpValueName

Points to a -terminated string that names the value to remove. If this parameter is or points to an empty string, the value set by the function is removed.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

 

RegEnumKeyEx()

NAME

- The function enumerates subkeys of the specified open registry key. The function retrieves information about one subkey each time it is called. Unlike the function, retrieves the class name of the subkey and the time it was last modified.

Synopsis

Description

To enumerate subkeys, an application should initially call the function with the dwIndex parameter set to zero. The application should then increment the dwIndex parameter and call until there are no more subkeys (until the function returns ).

The application can also set dwIndex to the index of the last subkey on the first call to the function and decrement the index until the subkey with the index 0 is enumerated. To retrieve the index of the last subkey, use the function.

While an application is using the function, it should not make calls to any registration functions that might change the key being enumerated.

The key identified by hKey must have been opened with access ( includes ). Use the or function to open the key.

Parameters

hKey

Identifies a currently open key or one of the following predefined reserved handle values:

The enumerated keys are subkeys of the key identified by hKey.

dwIndex

Specifies the index of the subkey to retrieve. This parameter should be zero for the first call to the function and then incremented for subsequent calls. Because subkeys are not ordered, any new subkey will have an arbitrary index. This means that the function may return subkeys in any order.

lpName

Points to a buffer that receives the name of the subkey, including the terminating character. The function copies only the name of the subkey, not the full key hierarchy, to the buffer.

lpcbName

Points to a variable that specifies the size, in characters, of the buffer specified by the lpName parameter. This size should include the terminating character. When the function returns, the variable pointed to by lpcbName contains the number of characters stored in the buffer. The count returned does not include the terminating character.

lpReserved

Reserved; must be .

lpClass

Points to a buffer that contains the class of the enumerated subkey when the function returns. This parameter can be if the class is not required.

lpcbClass

Points to a variable that specifies the size, in characters, of the buffer specified by the lpClass parameter. The size should include the terminating character. When the function returns, lpcbClass contains the number of characters stored in the buffer. The count returned does not include the terminating character. This parameter can be only if lpClass is .

lpftLastWriteTime

Points to a variable that receives the time the enumerated subkey was last written to.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , ,  

RegEnumValue()

NAME

- The function enumerates the values for the specified open registry key. The function copies one indexed value name and data block for the key each time it is called.

Synopsis

Description

To enumerate values, an application should initially call the function with the dwIndex parameter set to zero. The application should then increment dwIndex and call the function until there are no more values (until the function returns ).

The application can also set dwIndex to the index of the last value on the first call to the function and decrement the index until the value with index 0 is enumerated. To retrieve the index of the last value, use the function.

While using , an application should not call any registration functions that might change the key being queried.

The key identified by the hKey parameter must have been opened with access. To open the key, use the or function.

To determine the maximum size of the name and data buffers, use the function.

Parameters

hKey

Identifies a currently open key or one of the following predefined reserved handle values:

The enumerated values are associated with the key identified by hKey.

dwIndex

Specifies the index of the value to retrieve. This parameter should be zero for the first call to the function and then be incremented for subsequent calls.

Because values are not ordered, any new value will have an arbitrary index. This means that the function may return values in any order.

lpValueName

Points to a buffer that receives the name of the value, including the terminating character.

lpcbValueName

Points to a variable that specifies the size, in characters, of the buffer pointed to by the lpValueName parameter. This size should include the terminating character. When the function returns, the variable pointed to by lpcbValueName contains the number of characters stored in the buffer. The count returned does not include the terminating character.

lpReserved

Reserved; must be .

lpType

Points to a variable that receives the type code for the value entry. The type code can be one of the following values:

1.  RegEnumValue lpType Values

The lpType parameter can be if the type code is not required.

lpData

Points to a buffer that receives the data for the value entry. This parameter can be if the data is not required.

lpcbData

Points to a variable that specifies the size, in bytes, of the buffer pointed to by the lpData parameter. When the function returns, the variable pointed to by the lpcbData parameter contains the number of bytes stored in the buffer. This parameter can be , only if lpData is .

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , ,  

RegFlushKey()

NAME

- The function writes all the attributes of the specified open key into the registry.

Synopsis

Description

It is not necessary to call to change a key. Registry changes are flushed to disk by the registry using its lazy flusher. Registry changes are also flushed to disk at system shutdown.

Unlike , the function returns only when all the data has been written to the registry.

The function may also write out parts of or all of the other keys. Calling this function excessively can have a negative effect on an application's performance.

An application should only call if it requires absolute certainty that registry changes are on disk. In general, rarely, if ever, need be used.

Parameters

hKey

Identifies a currently open key or one of the following predefined reserved handle values:

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

,  

RegGetKeySecurity()

NAME

- The function retrieves a copy of the security descriptor protecting the specified open registry key.

Synopsis

Description

If the buffer specified by the pSecurityDescriptor parameter is too small, the function returns and the lpcbSecurityDescriptor parameter contains the number of bytes required for the requested security descriptor.

To read the security descriptor for the specified key, the calling process must have been granted access when the key was opened, or it must be the owner of the key. ( access is granted by the , , , and access rights.) In addition, the caller must have the privilege to read the system access-control list (SACL).

For more information about security, see Chapter 10.

Parameters

hKey

Identifies an open key for which to retrieve the security descriptor.

SecurityInformation

Specifies a structure that indicates the requested security information. The structure has the following form:

typedef DWORD SECURITY_INFORMATION;

For a full description of this structure, see the Microsoft Win32 Programmer's Reference, Volume 5.

pSecurityDescriptor

Points to a buffer that receives a copy of the requested security descriptor.

lpcbSecurityDescriptor

Points to a variable that specifies the size, in bytes, of the buffer pointed to by the pSecurityDescriptor parameter. When the function returns, the variable contains the number of bytes written to the buffer.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , ,  

RegLoadKey()

NAME

- The function creates a subkey under or and stores registration information from a specified file into that subkey. This registration information is in the form of a hive. A hive is a discrete body of keys, subkeys, and values that is rooted at the top of the registry hierarchy. A hive is backed by a single file and file.

Synopsis

Description

If hKey is a handle returned by , then the path specified in lpFile is relative to the remote computer.

Parameters

hKey

Specifies the key where the subkey will be created. This can be a predefined reserved handle value, or a handle returned by a call to . The predefined reserved handle values are:

This function always loads information at the top of the registry hierarchy. The and handle values cannot be specified for this parameter, because they represent subsets of the and handle values, respectively.

lpSubKey

Points to a -terminated string that specifies the name of the key to be created under hKey. This subkey is where the registration information from the file will be loaded.

lpFile

Points to a -terminated string containing the name of a file that has registration information. This file must have been created with the function. Under the file allocation table (FAT) file system, the filename may not have an extension.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , , , ,  

RegNotifyChangeKeyValue()

NAME

- The function notifies the caller about changes to the attributes or contents of a specified registry key. Note that the function does not notify the caller if the specified key is deleted.

Synopsis

Description

If the key identified by the hKey parameter is closed, the event is signaled. This means that an application should not depend on the key being open after returning from a wait operation on the event.

does not work with remote handles. If is called with an hKey value that is a remote handle, it returns .

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

bWatchSubtree

Specifies a flag that indicates whether to report changes in the specified key and all of its subkeys or only in the specified key. If this parameter is , the function reports changes in the key and its subkeys. If the parameter is , the function reports changes only in the key.

dwNotifyFilter

Specifies a set of flags that control which changes should be reported. This parameter can be a combination of the following values:

1.  RegNotifyChangeKeyValue dwNotifyFilter Values

hEvent

Identifies an event. If the fAsynchronous parameter is , the function returns immediately and changes are reported by signaling this event. If fAsynchronous is , hEvent is ignored.

fAsynchronous

Specifies a flag that indicates how the function reports changes. If this parameter is , the function returns immediately and reports changes by signaling the specified event. When this parameter is , the function does not return until a change has occurred.

If hEvent does not specify a valid event, the fAsynchronous parameter cannot be .

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , , ,  

RegOpenKeyEx()

NAME

- The function opens the specified key.

Synopsis

Description

Unlike the function, the function does not create the specified key if the key does not exist in the registry.

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

lpSubKey

Points to a -terminated string containing the name of the subkey to open. If this parameter is or a pointer to an empty string, the function will open a new handle of the key identified by the hKey parameter. In this case, the function will not close the handles previously opened.

ulOptions

Reserved; must be zero.

samDesired

Specifies an access mask that describes the desired security access for the new key. This parameter can be a combination of the following values:

1.  RegOpenKeyEx samDesired Values

phkResult

Points to a variable that receives the handle of the opened key.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , ,  

RegQueryInfoKey()

NAME

- The function retrieves information about a specified registry key.

Synopsis

Description

The key identified by the hKey parameter must have been opened with access ( access includes access).

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

lpClass

Points to a buffer that receives the key's class name. This parameter can be .

lpcbClass

Points to a variable that specifies the size, in characters, of the buffer pointed to by the lpClass parameter. This size should include the terminating character. When the function returns, this variable contains the length of the class string stored in the buffer. The count returned does not include the terminating character. If the buffer is not big enough, the function returns , and the variable contains the size of the string, in characters, without counting the character.

If lpClass is , lpcbClass can be .

lpReserved

Reserved; must be .

lpcSubKeys

Points to a variable that receives the number of subkeys contained by the specified key. This parameter can be .

lpcbMaxSubKeyLen

Points to a variable that receives the length, in characters, of the key's subkey with the longest name. The count returned does not include the terminating character. This parameter can be .

lpcbMaxClassLen

Points to a variable that receives the length, in characters, of the longest string specifying a subkey class. The count returned does not include the terminating character. This parameter can be .

lpcValues

Points to a variable that receives the number of values associated with the key. This parameter can be .

lpcbMaxValueNameLen

Points to a variable that receives the length, in characters, of the key's longest value name. The count returned does not include the terminating character. This parameter can be .

lpcbMaxValueLen

Points to a variable that receives the length, in bytes, of the longest data component among the key's values. This parameter can be .

lpcbSecurityDescriptor

Points to a variable that receives the length, in bytes, of the key's security descriptor. This parameter can be .

lpftLastWriteTime

Pointer to a structure. This parameter can be .

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , , ,  

RegQueryMultipleValues()

NAME

- The function retrieves the type and data for a list of value names associated with an open registry key.

Synopsis

Description

The function allows an application to query one or more values of a static or dynamic key. If the target key is a static key, the system provides all of the values in an atomic fashion. To prevent excessive serialization, the aggregate data returned by the function can not exceed one megabyte.

If the target key is a dynamic key, its provider must provide all the values in an atomic fashion. This means the provider should fill the results buffer synchronously, providing a consistent view of all the values in the buffer while avoiding excessive serialization. The provider can provide at most one megabyte of total output data during an atomic call to this function.

is supported remotely; that is, the hKey parameter passed to the function can refer to a remote computer.

Parameters

hKey

Identifies a currently open key or any of the pre-defined reserved handle values:

val_list

Address of an array of structures that describe one or more value entries. On input, the member of each structure must contain a pointer to the name of a value to retrieve. The function fails if any of the specified values do not exist in the specified key.

If the function succeeds, each element of the array contains the information for the specified value.

num_vals

Specifies the number of elements in the val_list array.

lpValueBuf

Pointer to a buffer. If the function succeeds, the buffer receives the data for each value.

If lpValueBuf is , the function returns success, and ldwTotsize returns the required size, in bytes, of the buffer.

ldwTotsize

Pointer to a value that specifies the size, in bytes, of the buffer pointed to by the lpValueBuf parameter. If the function succeeds, ldwTotsize returns the number of bytes copied to the buffer. If the function fails because the buffer is too small, ldwTotsize receives the required size, in bytes.

Return Values

If the function succeeds, the return value is .

If the function fails, the return value is one of the following error codes:

cannot instantiate or access the provider of the dynamic key.

The buffer pointed to by lpValueBuf was too small. In this case, ldwTotsize returns the required buffer size.

The total length of the requested data (size of the val_list array + ldwTotSize) is more than the system limit of one megabyte.

See Also

 

RegQueryValueEx()

NAME

- The function retrieves the type and data for a specified value name associated with an open registry key.

Synopsis

Description

The key identified by hKey must have been opened with access. To open the key, use the or function.

This function does not expand the environment-variable names in the value data when the value type is .

If the value data has the , or type, and the ANSI version of this function is used (either by explicitly calling or by not defining before including the file), this function converts the stored Unicode string to an ANSI string before copying it to the buffer pointed to by lpData.

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

lpValueName

Points to a -terminated string containing the name of the value to be queried.

lpReserved

Reserved; must be .

lpType

Points to a variable which receives the key's value type. The value returned through this parameter will be one of the following:

1.  RegQueryValueEx lpType Values

The lpType parameter can be if the type is not required.

lpData

Points to a buffer that receives the value's data. This parameter can be if the data is not required.

lpcbData

Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the lpData parameter. When the function returns, this variable contains the size of the data copied to lpData.

If the data has the , or type, then lpcbData will also include the size of the terminating character.

The lpcbData parameter can be only if lpData is NULL.

If the buffer specified by lpData parameter is not large enough to hold the data, the function returns the value , and stores the required buffer size, in bytes, into the variable pointed to by lpcbData.

If lpData is , and lpcbData is non-NULL, the function returns , and stores the size of the data, in bytes, in the variable pointed to by lpcbData. This lets an application determine the best way to allocate a buffer for the value's data.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , ,  

RegReplaceKey()

NAME

- The function replaces the file backing a key and all its subkeys with another file, so that when the system is next started, the key and subkeys will have the values stored in the new file.

Synopsis

Description

The file specified by the lpNewFile parameter remains open until the system is restarted.

If hKey is a handle returned by , then the paths specified in lpNewFile and lpOldFile are relative to the remote computer.

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

lpSubKey

Points to a -terminated string containing the name of a key whose subkeys and values are replaced by this function. This key must be a subkey of the key identified by the hKey parameter. This parameter can be .

The selected key must be the root of a hive; that is, it must be an immediate descendent of or .

lpNewFile

Points to a -terminated string containing the name of the file with registration information. This file is typically created by using the function. Under the file allocation table (FAT) file system, the filename may not have an extension.

lpOldFile

Points to a -terminated string containing the name of a file that receives a backup copy of the registry information being replaced. If this file is created under the FAT file system, it should not have an extension.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , ,  

RegRestoreKey()

NAME

- The function reads the registry information in a specified file and copies it over the specified key. This registry information may be in the form of a key and multiple levels of subkeys.

Synopsis

Description

If any subkeys of the hKey parameter are open, fails. The function also fails if the calling process does not have the privilege.

This function replaces the keys and values below the specified key with the keys and values that are subsidiary to the top-level key in the file, no matter what the name of the top-level key in the file might be. For example, hKey might identify a key A with subkeys B and C, while the lpFile parameter specifies a file containing key X with subkeys Y and Z. After a call to , the registry would contain key A with subkeys Y and Z. The value entries of A would be replaced by the value entries of X.

The new information in the file specified by lpFile overwrites the contents of the key specified by the hKey parameter, except for the key name.

If hKey represents a key in a remote computer, the path described by lpFile is relative to the remote computer.

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

Any information contained in this key and its descendent keys is overwritten by the information in the file pointed to by the lpFile parameter.

lpFile

Points to a -terminated string containing the name of the file with registry information. This file is typically created by using the function. Under the file allocation table (FAT) file system, the filename may not have an extension.

dwFlags

Specifies a flag indicating whether the key is volatile. (A volatile key is valid only until the next time the system is started.) This parameter is optional; if no value is specified, the key is not volatile.

This parameter can be the flag set. Instead of restoring the given key, this flag causes a new, volatile (memory only) set of registry information to be created. (A hive is a large set of registry information, typically containing all of the pertinent information for part of the system. For example, \ is a volatile hive.)

If is specified, the key identified by the hKey parameter must be either the or value.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , ,  

RegSaveKey()

NAME

- The function saves the specified key and all of its subkeys and values to a new file.

Synopsis

Description

If hKey represents a key on a remote computer, the path described by lpFile is relative to the remote computer.

The function saves only nonvolatile keys. It does not save volatile keys. A key is made volatile or nonvolatile at its creation; see .

Parameters

hKey

Specifies a handle of the key where the save operation is to begin, or any of the following predefined reserved handle values:

lpFile

Points to a -terminated string containing the name of the file in which the specified key and subkeys are saved.

If this filename includes an extension, it cannot be used on file allocation table (FAT) file systems by the , , or function.

lpSecurityAttributes

This parameter is ignored.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , , , ,  

RegSetKeySecurity()

NAME

- The function sets the security of an open registry key.

Synopsis

Description

This function succeeds only if the following conditions are met:

  • If the key's owner or group is being set, the caller must have permission or have the privilege.

  • If the key's discretionary access-control list () is being set, the caller must have permission or be the object's owner.

  • If the key's system access-control list (SACL) is being set, the caller must have the privilege.

If hKey is one of the predefined keys, the predefined key should be closed with . That ensures that the new security information is in effect the next time the predefined key is referenced.

Parameters

hKey

Identifies an open key for which the security descriptor is set.

SecurityInformation

Specifies a structure that indicates the contents of the supplied security descriptor.

Because subkeys are not ordered, any new subkey will have an arbitrary index. This means the function may return subkeys in any order.

pSecurityDescriptor

Points to a structure that specifies the security attributes to set for the specified key.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , ,  

RegSetValueEx()

NAME

- The function stores data in the value field of an open registry key. It can also set additional value and type information for the specified key.

Synopsis

Description

Value lengths are limited by available memory. Long values (more than 2048 bytes) should be stored as files with the filenames stored in the registry. This helps the registry perform efficiently. Application elements such as icons, bitmaps, and executable files should be stored as files and not be placed in the registry.

The key identified by the hKey parameter must have been opened with access. To open the key, use the or function.

If dwType is the , or type and the ANSI version of this function is used (either by explicitly calling or by not defining before including the file), the data pointed to by the lpData parameter must be an ANSI character string. The string is converted to Unicode before it is stored in the registry.

Parameters

hKey

Identifies a currently open key or any of the following predefined reserved handle values:

lpValueName

Points to a string containing the name of the value to set. If a value with this name is not already present in the key, the function adds it to the key.

If this parameter is or points to an empty string and the dwType parameter is the type, this function sets the same value the function would set.

Reserved

Reserved; must be zero.

dwType

Specifies the type of information to be stored as the value's data. This parameter can be one of the following values:

1.  RegSetValueEx dwType Values

lpData

Points to a buffer containing the data to be stored with the specified value name.

cbData

Specifies the size, in bytes, of the information pointed to by the lpData parameter. If the data is of type , , or , cbData must include the size of the terminating character.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , , ,  

RegUnLoadKey()

NAME

- The function unloads the specified key and subkeys from the registry.

Synopsis

Description

This function removes a hive from the registry but does not modify the file containing the registry information. A hive is a discrete body of keys, subkeys, and values that is rooted at the top of the registry hierarchy.

Parameters

hKey

Specifies the key to be unloaded. This can be a predefined reserved handle value, or a handle returned by a call to . The predefined reserved handle values are:

lpSubKey

Points to a -terminated string containing the name of the subkey to be unloaded. The key referred to by the lpSubKey parameter must have been created by using the function.

Return Values

If the function succeeds, the return value is . If the function fails, the return value is a nonzero error code defined in . You can use the function with the flag to get a generic description of the error.

See Also

, , ,

24.9    Registry Structures

24.9.1    VALENT

The structure contains information about a registry value. The function uses this structure.

typedef struct value_ent { LPTSTR ve_valuename; DWORD ve_valuelen; DWORD ve_valueptr; DWORD ve_type; }VALENT;

Members

Pointer to a -terminated string. Before calling , set this member to point to the name of a value to retrieve.

Specifies the size, in bytes, of the data pointed to by .

Pointer to the data for the value entry. This is a pointer to the value's data returned in the lpValueBuf buffer filled in by .

Specifies the type code for the value entry. The type code can be one of the following values:

Table 24-2:  VALENT ve_type Values

See Also


Related Videos

8. Registry in Windows -Windows System Programming in C/C++

0 Comments

Leave a Comment