监控注册表值并修改

zss427607 2009-08-25 08:43:16
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Licensing Core,在该键下一个名为“EnableConcurrentSessions”的DWORD值,该值的数据为1。

各位如何监视以上注册表的值是否为“1“,如果不是就进行修改使之为1、是的话无动作。



不知能否实现以上功能



先谢谢了
...全文
255 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zss427607 2010-01-02
  • 打赏
  • 举报
回复
各位 高人
谢谢了
chenhui530 2009-08-26
  • 打赏
  • 举报
回复
微软公开的或者常用的一些方法,比如微点提供的api都是事后处理,还有比如象wmi等都是这样
如果要事先处理最好是拦截api或者事先触发的回调,好像只有2003支持
of123 2009-08-26
  • 打赏
  • 举报
回复

不需要那么复杂,微软已经提供了 RegNotifyChangeKeyValue 函数。下面是例子:

Option Explicit

'This program shows you how to use the RegNotifyChangeKeyValue-function
'As its name predicts, RegNotifyChangeKeyValue will notify our program
'when the registry changes.
'Follow these steps to test this program:
'1. Start this program
'2. Start Regedit.exe (located in your Windows-directory)
'3. Go to HKEY_CURRENT_USER
'4. Change the value of HKEY_CURRENT_USER
'5. You will see that our program returns from the RegNotifyChangeKeyValue

'WARNING: Playing with the registry can have serious consequences !
' If you don't know what you're doing, I advise you not to delete anything

Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_NOTIFY_CHANGE_NAME = &H1 ' Create or delete (child)
Const REG_NOTIFY_CHANGE_ATTRIBUTES = &H2
Const REG_NOTIFY_CHANGE_LAST_SET = &H4 ' time stamp
Const REG_NOTIFY_CHANGE_SECURITY = &H8
Const REG_NOTIFY_ALL = (REG_NOTIFY_CHANGE_NAME Or REG_NOTIFY_CHANGE_ATTRIBUTES Or REG_NOTIFY_CHANGE_LAST_SET Or REG_NOTIFY_CHANGE_SECURITY)
Private Declare Function RegNotifyChangeKeyValue Lib "advapi32" (ByVal hKey As Long, ByVal bWatchSubtree As Boolean, ByVal dwNotifyFilter As Long, ByVal hEvent As Long, ByVal fAsynchronous As Boolean) As Long
Private Sub Form_Load()
'Create a temporary registry key
SaveSetting "Registry Notification", "Hello", "Testing", "123"
'Call the function .. This will notify us when something changes at HKEY_CURRENT_USER
RegNotifyChangeKeyValue HKEY_CURRENT_USER, True, REG_NOTIFY_ALL, ByVal 0&, False
MsgBox "Registry changed"
Unload Me
End Sub
threenewbee 2009-08-26
  • 打赏
  • 举报
回复
拦截API函数。
我的[URL=http://blog.caozhongyan.com]BLOG[/URL]有。
嗷嗷叫的老马 2009-08-26
  • 打赏
  • 举报
回复
添加一个模块:

http://www.m5home.com/bbs/dispbbs.asp?boardid=28&Id=422&page=2

然后在一个定时器里写代码:

private sub timer1_timer()
if GetDWORDValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Licensing Core","EnableConcurrentSessions")<>1 then
call SetDWORDValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\Licensing Core","EnableConcurrentSessions",1)
end if
end sub
zss427607 2009-08-25
  • 打赏
  • 举报
回复
可以 上传个实例吗
嗷嗷叫的老马 2009-08-25
  • 打赏
  • 举报
回复
简单点的,用个定时器,定期查询,不是1就改成1......

复杂点的恐怕你是做不了,即拦截注册表操作的相关API,进行监控....

据说需要写驱动?或者要进行RING3下的全局拦截之类??
Delphi彻底更换桌面壁纸及剪贴板监控程序,需要使用到下列delphi类库:   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,    StdCtrls, registry, Clipbrd, ExtCtrls{监视剪贴板单元};   定义函数实现壁纸的注册表修改:   procedure TForm1.Button2Click(Sender: TObject);   Var    Reg:Tregistry; //Tregistry 对象在Registry 单元中声明,需用Uses令引用Registry单元   Begin    Reg:=Tregistry.Create;{创建Tregistry对象的实例}    Reg.Rootkey:= Hkey_Current_User;{设置根键名称}    Reg.OpenKey('Control Panel\Desktop',False); {打开Control Panel\Desktop 路径对应的主键}    Reg.WriteString('TileWallPaper', '0');    Reg.WriteString('Wallpaper','C:\C:\My Documents\Beautiful.bmp') ; //向TileWallpaper 和Wallpaper串覆盖写入新    Systemparametersinfo(SPI_SETDESKWallpaper,0,Nil,SPIF_SendChange);{向Windows发送消息,通知Windows更换壁纸}    Reg.CloseKey;{将更改内容写入注册表并关闭}    Reg.Free;{释放对象}   End;   //处理剪切板内容,剪贴板监控功能:   //将WM_DRAWCLIPBOARD消息传递到下一个观察链中的窗口   SendMessage(NextClipHwnd,AMessage.Msg,AMessage.WParam,AMessage.LParam);   //查询剪贴板中特定格式的数据内容   if (Clipboard.HasFormat(CF_TEXT) or Clipboard.HasFormat(CF_OEMTEXT)) then   begin    //处理剪贴板中文本内容    Memo1.Lines.Add(Clipboard.asText) ;   End Else   if Clipboard.HasFormat(CF_BITMAP) Then   Begin    //处理剪贴板中图片内容    Bitmap := TBitmap.Create;    try    Bitmap.Assign(Clipboard);    Image1.Canvas.Draw(0, 0, Bitmap);    finally    Bitmap.Free;    end;   End ;如需完整源码,请在本面底部下载链接下载。

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧