如何与工作组中的其他计算机共享注册表项 [英] How can I share a registry key with other computers in a work group

查看:90
本文介绍了如何与工作组中的其他计算机共享注册表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请首先如何在O/S级别和代码级别与工作组中的其他计算机共享注册表项.

我的意思是,要共享一个文件夹,我只需右键单击该文件夹,然后选择文件共享和安全性,然后选中网络上的共享文件夹"复选框,并允许其他用户更改我的文件复选框.我右键单击一个注册表项,随后出现的对话框是相当奇怪和不寻常的,并且使用了不熟悉的语言.
我需要与网络上其他计算机共享注册表项的帮助,因为我的窗口应用程序必须为远程计算机上的客户端版本提供服务.

更好的是他们的代码例程,希望我可以执行此注册表共享,而不是要求用户手动进行共享.我想在我的应用程序创建注册表项时为他们完成此操作.




从我的Visual Studio MSDN中检查一下过去的内容:


RegConnectRegistry函数

建立与另一台计算机上的预定义注册表项的连接.


长WINAPI RegConnectRegistry(
__在LPCTSTR lpMachineName中,
__在HKEY hKey中,
__out PHKEY phkResult
);

参数
lpMachineName
远程计算机的名称.该字符串具有以下形式:

\\计算机名

调用者必须有权访问远程计算机,否则功能将失败.

如果此参数为NULL,则使用本地计算机名称.

hKey
预定义的注册表句柄.此参数可以是远程计算机上以下预定义的键之一.


HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_PERFORMANCE_DATA
HKEY_USERS

Windows Me/98/95:此参数也可以是下列值之一:

HKEY_CURRENT_CONFIG
HKEY_DYN_DATA

phkResult
指向变量的指针,该变量接收用于标识远程计算机上预定义句柄的键句柄.

返回值
如果函数成功,则返回值为ERROR_SUCCESS.

如果函数失败,则返回值是Winerror.h中定义的非零错误代码.您可以将FormatMessage函数与FORMAT_MESSAGE_FROM_SYSTEM标志一起使用,以获取对该错误的一般描述.

备注
当访问远程计算机时,不能保证HKEY_CURRENT_USER密钥是交互式用户的密钥.很可能是HKEY_USER \.默认值.

当不再需要RegConnectRegistry返回的句柄时,应通过调用RegCloseKey将其关闭.

如果计算机已加入工作组,并且启用了使用本地帐户强制进行网络登录以验证为来宾身份"策略,则该功能将失败.请注意,如果计算机已加入工作组,则默认情况下将启用此策略.

如果当前用户对远程计算机没有适当的访问权限,则对RegConnectRegistry的调用将失败.要连接到远程注册表,请在调用RegConnectRegistry之前使用LOGON32_LOGON_NEW_CREDENTIALS和ImpersonateLoggedOnUser调用LogonUser.

Windows 2000:一个可能的解决方法是使用一组不同的凭据建立到管理共享(例如IPC $)的会话.若要指定当前用户以外的凭据,请使用WNetAddConnection2函数连接到共享.完成访问注册表后,请取消连接.
Windows XP Home Edition:您不能使用此功能连接到运行Windows XP Home Edition的远程计算机.即使本地计算机在运行Windows XP Home Edition,它也可以使用它的名称,因为它绕过了身份验证层.

Please how can I share a registry key with other computers in a work group first, at the O/S level and at code level.

What I mean is that to share a folder I simply right click on the folder and select file share and security and check the Share Folder on the network check box and and allow other users to change my file check box. I right clicked on a registry key and the ensuing dialog box was rather strange and unusual and used unfamiliar language.
I need help in sharing registry keys with other computers on the net work because my window application must service it client version on remote computers.

Better still is their a code routine with wish I can do this registry sharing rather than requiring users to go through the sharing manually I would like to do this for them at the point that my application created the registry key.




Check this cut and past from my Visual studio MSDN out:


RegConnectRegistry Function

Establishes a connection to a predefined registry key on another computer.


LONG WINAPI RegConnectRegistry(
__in LPCTSTR lpMachineName,
__in HKEY hKey,
__out PHKEY phkResult
);

Parameters
lpMachineName
The name of the remote computer. The string has the following form:

\\computername

The caller must have access to the remote computer or the function fails.

If this parameter is NULL, the local computer name is used.

hKey
A predefined registry handle. This parameter can be one of the following predefined keys on the remote computer.


HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_PERFORMANCE_DATA
HKEY_USERS

Windows Me/98/95: This parameter can also be one of the following values:

HKEY_CURRENT_CONFIG
HKEY_DYN_DATA

phkResult
A pointer to a variable that receives a key handle identifying the predefined handle on the remote computer.

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.

Remarks
When accessing a remote computer, the HKEY_CURRENT_USER key is not guaranteed to be that of the interactive user. Most likely, this will be HKEY_USER\.Default.

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

If the computer is joined to a workgroup and the "Force network logons using local accounts to authenticate as Guest" policy is enabled, the function fails. Note that this policy is enabled by default if the computer is joined to a workgroup.

If the current user does not have proper access to the remote computer, the call to RegConnectRegistry fails. To connect to a remote registry, call LogonUser with LOGON32_LOGON_NEW_CREDENTIALS and ImpersonateLoggedOnUser before calling RegConnectRegistry.

Windows 2000: One possible workaround is to establish a session to an administrative share such as IPC$ using a different set of credentials. To specify credentials other than those of the current user, use the WNetAddConnection2 function to connect to the share. When you have finished accessing the registry, cancel the connection.
Windows XP Home Edition: You cannot use this function to connect to a remote computer running Windows XP Home Edition. This function does work with the name of the local computer even if it is running Windows XP Home Edition because this bypasses the authentication layer.

推荐答案

使用一组不同的凭据.若要指定当前用户以外的凭据,请使用WNetAddConnection2函数连接到共享.完成访问注册表后,取消连接.
Windows XP Home Edition:您不能使用此功能连接到运行Windows XP Home Edition的远程计算机.即使本地计算机正在运行Windows XP Home Edition,该功能也可以使用它的名称,因为它绕过了身份验证层.
using a different set of credentials. To specify credentials other than those of the current user, use the WNetAddConnection2 function to connect to the share. When you have finished accessing the registry, cancel the connection.
Windows XP Home Edition: You cannot use this function to connect to a remote computer running Windows XP Home Edition. This function does work with the name of the local computer even if it is running Windows XP Home Edition because this bypasses the authentication layer.


您无法共享注册表远程计算机.期间.
You can''t share your registry remote machines. Period.


这篇关于如何与工作组中的其他计算机共享注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆