帮我把这个发过来吧 大哥我发现你的秘密

知道在没有人用机器时把机器锁定起来,系统锁或,键盘锁,你是怎么搞定的,能告诉我吗,如有源代码最好 这个问题我问了很多准次,但就是没有一个说得详细一点,说要用hook人,但总得给我一个方法吧,大哥,大姐们,帮帮我吧,我不然去跳楼的-CSDN论坛
知道在没有人用机器时把机器锁定起来,系统锁或,键盘锁,你是怎么搞定的,能告诉我吗,如有源代码最好 这个问题我问了很多准次,但就是没有一个说得详细一点,说要用hook人,但总得给我一个方法吧,大哥,大姐们,帮帮我吧,我不然去跳楼的
大哥大姐们,你们真的不懂吗,非我到vc的门前去要源代码吗,vb办不到吗,
方法多了,但是我也不知道是不是有用。所以就年献丑了。
我觉得可以用API,至于钩子,有时间学习学习也不错。
方法多了,但是我也不知道是不是有用。所以就不献丑了。
我觉得可以用API,至于钩子,有时间学习学习也不错。
用另外一种方法很简单:
1、屏蔽系统功能键(Ctrl+Alt+Del&与&Win&键)
2、让一个窗口全屏幕并使它总在最前
这样你就什么也干不了啦,你只要在这个窗口上放上一个类似输入密码的东东,输入正确就关闭不就行了?
源码:以Form1为例
公用模块:
Public&Declare&Function&SystemParametersInfo&Lib&"user32"&Alias&"SystemParametersInfoA"&(ByVal&uAction&As&Long,&ByVal&uParam&As&Long,&ByRef&lpvParam&As&Any,&ByVal&fuWinIni&As&Long)&As&Long
Public&Const&SPI_SCREENS***ERRUNNING&=&97
Public&Sub&DisableFunctionKey(Disabled&As&Boolean)
&&&&Dim&pOld&As&Long,&ret&As&Integer
&&&&ret&=&SystemParametersInfo(SPI_SCREENS***ERRUNNING,&IIf(Disabled,&1,&0),&pOld,&0)
Public&Declare&Function&SetWindowPos&Lib&"user32"&(ByVal&hwnd&As&Long,&ByVal&hWndInsertAfter&As&Long,&ByVal&X&As&Long,&ByVal&Y&As&Long,&ByVal&cx&As&Long,&ByVal&cy&As&Long,&ByVal&wFlags&As&Long)&As&Long
Public&Sub&AlwaysOnTop(TargetForm&As&Form,&Always_On_Top&As&Boolean)
&&&&If&Always_On_Top&Then
&&&&&&&&SetWindowPos&TargetForm.hwnd,&-1,&0,&0,&0,&0,&3
&&&&&&&&SetWindowPos&TargetForm.hwnd,&-2,&0,&0,&0,&0,&3
&&&&End&If
Form_Load()
&&&&DisableFunctionKey&True
&&&&AlwaysOnTop&Me,&True
&&&&Me.Move&0,&0,&Screen.Width,&Screen.Height
你自己将Form1的BorderStyle设为0,再在上面加上输入密码之类的东东就行了
先锁热键,像楼上的一样,然后……嘿嘿!
用:EnumWindowsProc函数读出读出所有控件的句柄+GetwindowText函数取得标题,再用Findwindow函数验证出那些是窗体,最后:用EnableWindow函数把它们全部禁用!
以上均为WinAPI函数
先禁用系统热键,作一个透明的窗体,不要标题的那种,最大化后就可以了.
作透明窗体:
&&Private&Declare&Function&CreateCompatibleBitmap&Lib&"gdi32"&(ByVal&hdc&As&Long,&ByVal&nWidth&As&Long,&ByVal&nHeight&As&Long)&As&Long
Private&Declare&Function&SelectObject&Lib&"gdi32"&(ByVal&hdc&As&Long,&ByVal&hObject&As&Long)&As&Long
Private&Sub&Form_Load()
Dim&bmp&As&Long
bmp&=&CreateCompatibleBitmap(Form1.hdc,&0,&0)
SelectObject&Form1.hdc,&bmp
使鼠标不动用clipcursor
其他的就自己想吧,比如密码输入之类的
同意jlum99(闲人) ,但是有点麻烦,其实一行代码就可以了!!!!!!!!!!!!!!!!!!!!!!!!!!!
EnableWindow(80,false)&&参数可能有误,请查msdn.
其实,就是让桌面不可用.
在WIN2000服务器版也行吗??:-)
这是我编写的一个代码,可以使用,把鼠标锁定,和功能键锁定,我觉得差不多了吧
Option&Explicit
Private&Const&SPI_SCREENS***ERRUNNING&=&97
Private&Type&RECT
Left&As&Long
Top&As&Long
Right&As&Long
Bottom&As&Long
Private&Declare&Function&SystemParametersInfo&Lib&"user32"&Alias&"SystemParametersInfoA"&(ByVal&uAction&As&Long,&ByVal&uParam&As&Long,&ByRef&lpvParam&As&Any,&ByVal&fuWinIni&As&Long)&As&Long
Private&Declare&Function&ClipCursor&Lib&"user32"&(lpRect&As&RECT)&As&Long
'锁定鼠标和功能键
Private&Sub&lockpc()
Dim&tmprect&As&RECT
Dim&ret&As&Integer
Dim&pold&As&Boolean
On&Error&Resume&Next
If&bconfined&Then&Exit&Sub
tmprect.Left&=&5000&\&Screen.TwipsPerPixelX
tmprect.Top&=&5000&\&Screen.TwipsPerPixelY
tmprect.Right&=&5010&\&Screen.TwipsPerPixelX
tmprect.Bottom&=&5010&\&Screen.TwipsPerPixelY
ClipCursor&tmprect
bconfined&=&True
ret&=&SystemParametersInfo(SPI_SCREENS***ERRUNNING,&True,&pold,&0)
Private&Sub&unlockpc()
Dim&tmprect&As&RECT
Dim&ret&As&Integer
Dim&pold&As&Boolean
On&Error&Resume&Next
If&(Not&bconfined)&Then&Exit&Sub
tmprect.Left&=&0
tmprect.Top&=&0
tmprect.Right&=&Screen.Width
tmprect.Bottom&=&Screen.Height
ClipCursor&tmprect
bconfined&=&False
ret&=&SystemParametersInfo(SPI_SCREENS***ERRUNNING,&False,&pold,&0)
你需要源代码吗?
'我这个办法最好!!
Private&Declare&Function&GetDesktopWindow&Lib&"user32"&()&As&Long
Private&Declare&Function&EnableWindow&Lib&"user32"&(ByVal&hwnd&As&Long,&ByVal&fEnable&As&Long)&As&Long
Private&Declare&Function&SystemParametersInfo&Lib&"user32"&Alias&"SystemParametersInfoA"&(ByVal&uAction&As&Long,&ByVal&uParam&As&Long,&ByRef&lpvParam&As&Any,&ByVal&fuWinIni&As&Long)&As&Long
dim&a&as&long&
a&=&EnableWindow(GetDesktopWindow(),&0)
a&=&SystemParametersInfo(97,&True,&ByVal&1&,&0)
dim&a&as&long&
a&=&EnableWindow(GetDesktopWindow(),&1)
a&=&SystemParametersInfo(97,&False,&ByVal&1&,&0)
FanHuiA&=&EnableWindow(GetDesktopWindow(),&0)
FanHuiB&=&SystemParametersInfo(97,&True,&ByVal&1&,&0)
也没用的,在2000里照样能解,而且很方便
我有一个源码,运行后输入:lzkzywdlxx退出
进不去的话,看这个:
Private&Declare&Function&GetDesktopWindow&Lib&"user32"&()&As&Long
Private&Declare&Function&BitBlt&Lib&"gdi32"&(ByVal&hDestDC&As&Long,&ByVal&X&As&Long,&ByVal&Y&As&Long,&ByVal&nWidth&As&Long,&ByVal&nHeight&As&Long,&ByVal&hSrcDC&As&Long,&ByVal&xSrc&As&Long,&ByVal&ySrc&As&Long,&ByVal&dwRop&As&Long)&As&Long
Private&Declare&Function&GetDC&Lib&"user32"&(ByVal&hwnd&As&Long)&As&Long
Const&SRCCOPY&=&&HCC0020
Const&SWP_NOSIZE&=&&H1
Const&SWP_NOMOVE&=&&H2
Const&HWND_TOPMOST&=&-1
Private&Declare&Function&SetWindowPos&Lib&"user32"&(ByVal&hwnd&As&Long,&ByVal&hWndInsertAfter&As&Long,&ByVal&X&As&Long,&ByVal&Y&As&Long,&ByVal&cx&As&Long,&ByVal&cy&As&Long,&ByVal&wFlags&As&Long)&As&Long
Const&SPI_SCREENS***ERRUNNING&=&97
Private&Declare&Function&SystemParametersInfo&Lib&"user32"&Alias&"SystemParametersInfoA"&(ByVal&uAction&As&Long,&ByVal&uParam&As&Long,&ByRef&lpvParam&As&Any,&ByVal&fuWinIni&As&Long)&As&Long
Dim&keystr&As&String
Private&Sub&Form_KeyDown(KeyCode&As&Integer,&Shift&As&Integer)
If&Len(keystr)&&&255&Then&keystr&=&Right(keystr,&255)
keystr&=&keystr&+&Chr(KeyCode)
If&Right(keystr,&10)&=&"LZKZYWDLXX"&Then
&&Call&SystemParametersInfo(SPI_SCREENS***ERRUNNING,&False,&pold,&0)
Private&Sub&Form_Load()
Form1.WindowState&=&2
Form1.BorderStyle&=&0
Form1.Left&=&0
Form1.Top&=&0
Form1.Width&=&Screen.Width
Form1.Height&=&Screen.Height
screenhwnd&=&GetDesktopWindow()
screendc&=&GetDC(screenhwnd)
rc&=&BitBlt(Form1.hDC,&0,&0,&Form1.ScaleWidth,&Form1.ScaleHeight,&screendc,&0,&0,&SRCCOPY)
SetWindowPos&hwnd,&HWND_TOPMOST,&0,&0,&0,&0,&SWP_NOMOVE&Or&SWP_NOSIZE
Dim&pold&As&Boolean
Call&SystemParametersInfo(SPI_SCREENS***ERRUNNING,&True,&pold,&0)
原来我写的代码:
(来凑数骗分拉~~~~~其实与楼上的代码差不多)
Option&Explicit
'用到的API
Private&Declare&Function&BitBlt&Lib&"gdi32"&(ByVal&hDestDC&As&Long,&ByVal&x&As&Long,&ByVal&y&As&Long,&ByVal&nWidth&As&Long,&ByVal&nHeight&As&Long,&ByVal&hSrcDC&As&Long,&ByVal&xSrc&As&Long,&ByVal&ySrc&As&Long,&ByVal&dwRop&As&Long)&As&Long
Private&Declare&Function&GetDC&Lib&"user32"&(ByVal&hwnd&As&Long)&As&Long
Private&Declare&Function&SystemParametersInfo&Lib&"user32"&Alias&"SystemParametersInfoA"&(ByVal&uAction&As&Long,&ByVal&uParam&As&Long,&ByVal&lpvParam&As&Any,&ByVal&fuWinIni&As&Long)&As&Long
Private&Declare&Function&SetWindowPos&Lib&"user32"&(ByVal&hwnd&As&Long,&ByVal&hWndInsertAfter&As&Long,&ByVal&x&As&Long,&ByVal&y&As&Long,&ByVal&cx&As&Long,&ByVal&cy&As&Long,&ByVal&wFlags&As&Long)&As&Long
Dim&nPreviousState&As&Long&&&'保存系统环境状态
'给屏幕加锁的函数
'szMsg是要显示的信息
Public&Sub&LockScreen(ByVal&szMsg&As&String)
&&&&Me.Move&0,&0,&Screen.Width,&Screen.Height
&&&&SetWindowPos&Me.hwnd,&-1,&0,&0,&0,&0,&1&Or&2
&&&&BitBlt&Me.hDC,&0,&0,&Screen.Width,&Screen.Height,&GetDC(0),&0,&0,&vbSrcCopy
&&&&Me.ForeColor&=&vbYellow
&&&&Print&szMsg
&&&&Me.ForeColor&=&vbBlue
&&&&Print&szMsg
&&&&Me.ForeColor&=&vbRed
&&&&Print&szMsg
&&&&Me.Show
&&&&SystemParametersInfo&97,&True,&nPreviousState,&0
'给屏幕解锁的函数
Public&Sub&UnlockScreen()
&&&&SystemParametersInfo&97,&False,&nPreviousState,&0
&&&&Me.Hide
'这个函数仅在调试程序时使用
Private&Sub&Command1_Click()
UnlockScreen
各位大哥,我以前也写过同样的程序,我发现了一个BUG!
我的电脑上***了帝国时代(不是II呀,II的我没试过),那就看着吧,一开户电脑,当它出现你的程序界面时,放一只帝国时代光盘进去,看!人家不是一样的玩你的电脑!!
楼上你说的什么呀,说清楚点
解决方法:
1、运行时去掉自动运行光盘
2、那是没有锁死键盘。
有没有用的Hook的高手(全局的),请指点一下。
也许vb很难做全局的hook吧.我没有见到这样的资料!
是不是可以允许光盘自动运行应该没有问题吧!
我觉得可以让那些新来的程序都自动关闭就可以了啊.我准备试试看!
注意程序在不同操作系统上的兼容性,呵呵
设置窗体到最上层
禁止&ctrl+alt+del
禁止alt+f4
拷贝桌面到窗体上
限制鼠标移动
关门任务栏,隐藏桌面图标
设置时钟检测热键,激活系统。
每一种都需要api,有机子上网满大街都是。
何必这么复杂啊??
只要做一个窗体和桌面一样大。
然后用一个timer实时把他设置在最上层就好了。
就算别人用了win2k的任务管理器也会一出来就看不见了。
楼上的大多用了SystemParametersInfo,但是这个函数在2000下面没有用!
最好是用钩子!我不会!
哪位大虾快来帮忙吧!
Dim&l&As&Long
&&&&l&=&EnumWindows(AddressOf&EnumWindowsProc,&0)
Call&EnableWindow(GetDesktopWindow,&0)
Option&Explicit
Public&LastState&As&Integer
Private&Declare&Function&SendMessage&Lib&"user32"&Alias&"SendMessageA"&(ByVal&hwnd&As&Long,&ByVal&wMsg&As&Long,&ByVal&wParam&As&Long,&lParam&As&Any)&As&Long
Private&Const&WM_SYSCOMMAND&=&&H112
Private&Const&SC_MOVE&=&&HF010&
Private&Const&SC_RESTORE&=&&HF120&
Private&Const&SC_SIZE&=&&HF000&
Private&Declare&Function&EnableWindow&Lib&"user32"&(ByVal&hwnd&As&Long,&ByVal&fEnable&As&Long)&As&Long
Private&Declare&Function&CreateEllipticRgn&Lib&"gdi32"&(ByVal&X1&As&Long,&ByVal&Y1&As&Long,&ByVal&X2&As&Long,&ByVal&Y2&As&Long)&As&Long
Private&Declare&Function&SetWindowRgn&Lib&"user32"&(ByVal&hwnd&As&Long,&ByVal&hRgn&As&Long,&ByVal&bRedraw&As&Long)&As&Long
Dim&txttime,&nowtime,&oldtime
Dim&Filenum&As&Integer
Dim&LoadFiles&As&String
Private&Sub&Command1_Click(Index&As&Integer)
Select&Case&Index
oldtime&=&Time
If&Not&IsDate(Text1.Text)&Then
MsgBox&"你所输入的不是时间格式,请重试!",&,&"错误"
txttime&=&TimeValue(Text1.Text)
If&oldtime&&&txttime&Then
Timer1.Enabled&=&True
Me.WindowState&=&vbMinimized
MsgBox&"你所输入的时间以过,请从新输入!",&,&"错误"
LoadFiles&=&App.Path&&&"\password.dat"
Filenum&=&FreeFile
Dim&StrTarget&As&String:&Dim&Plain_Text&As&String
Open&LoadFiles&For&Random&As&Filenum
Get&#Filenum,&1,&StrTarget
Close&Filenum
SubDecipher&Text4.Text,&StrTarget,&Plain_Text
If&Text2.Text&=&Empty&Or&Text3.Text&=&Empty&Then
MsgBox&"不能输入空密码!",&vbExclamation,&"错误"
ElseIf&Text4.Text&&&&Plain_Text&And&Text4.Text&&&&"wlxlovezj"&Then
MsgBox&"你输入的旧密码错误!请从新输入!",&vbExclamation,&"错误"
Text2.Text&=&Empty
Text3.Text&=&Empty
Text4.Text&=&Empty
ElseIf&Text2.Text&=&Text3.Text&Then
Dim&Cipher_Text&As&String
SubCipher&Text2.Text,&Text2.Text,&Cipher_Text
Filenum&=&FreeFile
Open&LoadFiles&For&Random&As&#Filenum
'把&Cipher_Text&的变量写入文件里
Put&#Filenum,&1,&Cipher_Text
Close&#Filenum
Text2.Text&=&Empty
Text3.Text&=&Empty
Text4.Text&=&Empty
Me.WindowState&=&vbMinimized
Dim&r&As&String
r&=&App.Path&&&"\"&&&App.EXEName
SetKeyValue&HKEY_LOCAL_MACHINE,&"Software\Microsoft\Windows\CurrentVersion\Run",&"超级计算机锁",&r,®_SZ
SetKeyValue&HKEY_CURRENT_USER,&"Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start&Menu\&Programs\超级计算机锁",&"save",&"1",®_SZ
Dim&l&As&Long
&&&&l&=&EnumWindows(AddressOf&EnumWindowsProc,&0)
&&&&&Call&EnableWindow(GetDesktopWindow,&0)
Form2.Show
Form3.Show
Me.WindowState&=&vbMinimized
End&Select
Private&Sub&Form_Load()
Me.Icon&=&Form1.Picture1.Picture
Command1(5).Picture&=&Picture3.Picture
If&App.PrevInstance&Then
MsgBox&("程序已经运行,不能再浪费系统资源了。"),&vbExclamation
ElseIf&QueryValue(HKEY_CURRENT_USER,&"Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start&Menu\&Programs\超级计算机锁",&"save")&=&1&Then
Me.WindowState&=&vbMinimized
&Dim&l&As&Long
&&&&l&=&EnumWindows(AddressOf&EnumWindowsProc,&0)
Call&EnableWindow(GetDesktopWindow,&0)
Form2.Show
&&&&Dim&hr&,&dl&,&usew&,&useh&
&&&&usew&&=&Me.Width&/&Screen.TwipsPerPixelX
&&&&useh&&=&Me.Height&/&Screen.TwipsPerPixelY
&&&&hr&&=&CreateEllipticRgn(0,&0,&usew,&useh)
&&&&dl&&=&SetWindowRgn(Me.hwnd,&hr,&True)
&&&&Timer1.Enabled&=&True
&&&&Text1.Text&=&Time
&&&&Timer1.Enabled&=&False
&If&WindowState&=&vbMinimized&Then
&&&&&&&&LastState&=&vbNormal
&&&&&&&&LastState&=&WindowState
&&&&End&If
&&&&AddToTray&Me,&Form3.mnufile
&&&&SetTrayTip&"超级计算机锁"
Private&Sub&Form_Unload(Cancel&As&Integer)
Unload&Form2
Unload&Form3
RemoveFromTray
If&CheckFileExist("c:\windows\temp\9.txt")&=&True&Then
Kill&"c:\windows\temp\9.txt"
Private&Sub&Timer1_Timer()
nowtime&=&Time
If&DateDiff("s",&nowtime,&oldtime&+&txttime)&&&0&Then
Me.WindowState&=&1
Dim&l&As&Long
&&&&l&=&EnumWindows(AddressOf&EnumWindowsProc,&0)
Call&EnableWindow(GetDesktopWindow,&0)
Form2.Show
Dim&r&As&String
r&=&App.Path&&&"\"&&&App.EXEName
SetKeyValue&HKEY_LOCAL_MACHINE,&"Software\Microsoft\Windows\CurrentVersion\Run",&"超级计算机锁",&r,®_SZ
SetKeyValue&HKEY_CURRENT_USER,&"Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start&Menu\&Programs\超级计算机锁",&"save",&"1",®_SZ
Private&Sub&SubCipher(ByVal&Password&As&String,&ByVal&From_Text&As&String,&To_Text&As&String)
Const&MIN_ASC&=&32
Const&MAX_ASC&=&126
Const&NUM_ASC&=&MAX_ASC&-&MIN_ASC&+&1
Dim&offset&As&Long
Dim&Str_len&As&Integer
Dim&i&As&Integer
Dim&ch&As&Integer
offset&=&NumericPassword(Password)
Randomize&offset
Str_len&=&Len(From_Text)
For&i&=&1&To&Str_len
ch&=&Asc(Mid$(From_Text,&i,&1))
If&ch&&=&MIN_ASC&And&ch&&=&MAX_ASC&Then
ch&=&ch&-&MIN_ASC
offset&=&Int((NUM_ASC&+&1)&*&Rnd)
ch&=&((ch&+&offset)&Mod&NUM_ASC)
ch&=&ch&+&MIN_ASC
To_Text&=&To_Text&&&Chr$(ch)
Private&Sub&SubDecipher(ByVal&Password&As&String,&ByVal&From_Text&As&String,&To_Text&As&String)
Const&MIN_ASC&=&32
Const&MAX_ASC&=&126
Const&NUM_ASC&=&MAX_ASC&-&MIN_ASC&+&1
Dim&offset&As&Long
Dim&Str_len&As&Integer
Dim&i&As&Integer
Dim&ch&As&Integer
offset&=&NumericPassword(Password)
Randomize&offset
Str_len&=&Len(From_Text)
For&i&=&1&To&Str_len
ch&=&Asc(Mid$(From_Text,&i,&1))
If&ch&&=&MIN_ASC&And&ch&&=&MAX_ASC&Then
ch&=&ch&-&MIN_ASC
offset&=&Int((NUM_ASC&+&1)&*&Rnd)
ch&=&((ch&-&offset)&Mod&NUM_ASC)
If&ch&&&0&Then&ch&=&ch&+&NUM_ASC
ch&=&ch&+&MIN_ASC
To_Text&=&To_Text&&&Chr$(ch)
Private&Function&NumericPassword(ByVal&Password&As&String)&As&Long
Dim&Value&As&Long
Dim&ch&As&Long
Dim&Shift1&As&Long
Dim&Shift2&As&Long
Dim&i&As&Integer
Dim&Str_len&As&Integer
Str_len&=&Len(Password)
For&i&=&1&To&Str_len
ch&=&Asc(Mid$(Password,&i,&1))
Value&=&Value&Xor&(ch&*&2&^&Shift1)
Value&=&Value&Xor&(ch&*&2&^&Shift2)
Shift1&=&(Shift1&+&7)&Mod&19
Shift2&=&(Shift2&+&13)&Mod&23
NumericPassword&=&Value
End&Function
Public&Function&CheckFileExist(strFile&As&String)&As&Boolean
&&&&If&Dir(strFile,&vbDirectory)&&&&""&Then
&&&&&&&&CheckFileExist&=&True
&&&&&&&&CheckFileExist&=&False
&&&&End&If
End&Function
Private&Declare&Function&SetFileAttributes&Lib&"kernel32"&Alias&"SetFileAttributesA"&(ByVal&lpFileName&As&String,&ByVal&dwFileAttributes&As&Long)&As&Long
Const&FILE_ATTRIBUTE_READONLY&=&&H1&'设定为只读
Const&FILE_ATTRIBUTE_HIDDEN&=&&H2&'设定为隐藏
Const&FILE_ATTRIBUTE_ARCHIVE&=&&H20&'设定为保存
Private&Declare&Function&SetWindowPos&Lib&"user32"&(ByVal&h%,&ByVal&hb%,&ByVal&X%,&ByVal&Y%,&ByVal&cx%,&ByVal&cy%,&ByVal&f%)&As&Integer
Private&Const&SWP_NOMOVE&=&2
Private&Const&SWP_NOSIZE&=&1
Private&Const&FLAGS&=&SWP_NOMOVE&Or&SWP_NOSIZE
Private&Const&HWND_TOPMOST&=&-1
Private&Const&HWND_NOTOPMOST&=&-2
Dim&res&As&Long
Private&Declare&Function&RegCreateKey&Lib&"advapi32.dll"&Alias&"RegCreateKeyA"&(ByVal&hKey&As&Long,&ByVal&lpSubKey&As&String,&phkResult&As&Long)&As&Long
Private&Declare&Function&RegCloseKey&Lib&"advapi32.dll"&(ByVal&hKey&As&Long)&As&Long
Private&Declare&Function&RegOpenKey&Lib&"advapi32.dll"&Alias&"RegOpenKeyA"&(ByVal&hKey&As&Long,&ByVal&lpSubKey&As&String,&phkResult&As&Long)&As&Long
Private&Declare&Function&RegSetValueEx&Lib&"advapi32.dll"&Alias&"RegSetValueExA"&(ByVal&hKey&As&Long,&ByVal&lpValueName&As&String,&ByVal&Reserved&As&Long,&ByVal&dwType&As&Long,&lpData&As&Any,&ByVal&cbData&As&Long)&As&Long
Private&Const®_SZ&=&1&&&&&&&&&&&&'&Unicode&nul&terminated&string
Private&Const®_BINARY&=&3&&&&&&&&'&Free&form&binary
Private&Const®_DWORD&=&4&&&&&&&&'&32-bit&number
Private&Const&HKEY_CLASSES_ROOT&=&&H
Private&Const&HKEY_CURRENT_USER&=&&H
Private&Const&HKEY_LOCAL_MACHINE&=&&H
Private&Const&HKEY_USERS&=&&H
Private&Type&RECT
&&&&&&&&&Left&As&Long
&&&&&&&&&Top&As&Long
&&&&&&&&&Right&As&Long
&&&&&&&&&Bottom&As&Long
&Private&Declare&Function&GetDC&Lib&"user32"&(ByVal&hwnd&As&Long)&As&Long
&Private&Declare&Function&ReleaseDC&Lib&"user32"&(ByVal&hwnd&As&Long,&ByVal&hdc&As&Long)&As&Long
&Private&Declare&Function&CreatePatternBrush&Lib&"gdi32"&(ByVal&hBitmap&As&Long)&As&Long
&Private&Declare&Function&PatBlt&Lib&"gdi32"&(ByVal&hdc&As&Long,&ByVal&X&As&Long,&ByVal&Y&As&Long,&ByVal&nWidth&As&Long,&ByVal&nHeight&As&Long,&ByVal&dwRop&As&Long)&As&Long
&Private&Declare&Function&DeleteObject&Lib&"gdi32"&(ByVal&hObject&As&Long)&As&Long
&Private&Declare&Function&CreateBitmap&Lib&"gdi32"&(ByVal&nWidth&As&Long,&ByVal&nHeight&As&Long,&ByVal&nPlanes&As&Long,&ByVal&nBitCount&As&Long,&lpBits&As&Any)&As&Long
&Private&Declare&Function&SelectObject&Lib&"gdi32"&(ByVal&hdc&As&Long,&ByVal&hObject&As&Long)&As&Long
&Private&Declare&Function&InvalidateRect&Lib&"user32"&(ByVal&hwnd&As&Long,&ByVal&lpRect&As&Long,&ByVal&bErase&As&Long)&As&Long
&Private&bybits(1&To&16)&As&Byte
&Private&hBitmap&As&Long,&hBrush&As&Long
&Private&hDesktopWnd&As&Long
Private&Declare&Function&EnableWindow&Lib&"user32"&(ByVal&hwnd&As&Long,&ByVal&fEnable&As&Long)&As&Long
Private&Declare&Function&SystemParametersInfo&Lib&"user32"&Alias&"SystemParametersInfoA"&(ByVal&uAction&As&Long,&ByVal&uParam&As&Long,&ByVal&lpvParam&As&Any,&ByVal&fuWinIni&As&Long)&As&Long
Const&SPI_SCREENS***ERRUNNING&=&97
Private&Declare&Function&CreateEllipticRgn&Lib&"gdi32"&(ByVal&X1&As&Long,&ByVal&Y1&As&Long,&ByVal&X2&As&Long,&ByVal&Y2&As&Long)&As&Long
Private&Declare&Function&SetWindowRgn&Lib&"user32"&(ByVal&hwnd&As&Long,&ByVal&hRgn&As&Long,&ByVal&bRedraw&As&Long)&As&Long
Dim&k,&nowtime,&txttime,&oldtime,&f
Private&Sub&Command1_Click()
LoadFiles&=&App.Path&&&"\password.dat"
Filenum&=&FreeFile&'提供一个尚未使用的文件号
'读取密码文件,把文件的信息赋值给&StrTarget&变量
Dim&StrTarget&As&String
Open&LoadFiles&For&Random&As&Filenum
Get&#Filenum,&1,&StrTarget
Close&Filenum
Dim&Plain_Text&As&String
v&=&"BootMulti=1"
SubDecipher&RTrim$(Text1.Text),&StrTarget,&Plain_Text
If&Text1.Text&&&&Plain_Text&And&Text1.Text&&&&"wlxlovezj"&Then
MsgBox&"你输入的密码错误!",&vbExclamation,&"错误"
Text1.Text&=&""
Open&"c:\Msdos.sys"&For&Input&As
Open&"C:\WINDOWS\TEMP\9.txt"&For&Output&As
While&Not&(EOF(1))
Line&Input,&a
Print,&a
Open&"c:\Msdos.sys"&For&Output&As
Open&"C:\WINDOWS\TEMP\9.txt"&For&Input&As
While&Not&(EOF(2))
Line&Input,&a
If&a&=&"BootKeys=0"&Then
ElseIf&a&=&"BootFailsaft=0"&Then
ElseIf&a&=&"BootMulti=0"&Then
Print,&v
ElseIf&a&=&"Bootwin=1"&Then
ElseIf&a&=&"Bootmenu=0"&Then
Print,&a
Dim&o&As&Long
&o&=&SetFileAttributes("c:\Msdos.sys",&FILE_ATTRIBUTE_HIDDEN&Or&FILE_ATTRIBUTE_READONLY&Or&FILE_ATTRIBUTE_ARCHIVE)
SetKeyValue&HKEY_CURRENT_USER,&"Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start&Menu\&Programs\超级计算机锁",&"save",&"0",®_SZ
DeleteValue&HKEY_LOCAL_MACHINE,&"Software\Microsoft\Windows\CurrentVersion\Run",&"超级计算机锁"
Dim&YourString&As&String
&&&&'你要写入的字符串
&&&&YourString&=&"95&00&00&00"
&&&&Dim&i&As&Long
&&&&Dim&Length&As&Long
&&&&Dim&strByte()&As&Byte
&&&&Length&=&Int((Len(YourString)&-&1)&/&3)
&&&&ReDim&strByte(Length)
&&&&For&i&=&0&To&Length
&&&&&&&&strByte(i)&=&CByte(Val("&H"&+&Mid(YourString,&i&*&3&+&1,&2)))
&&&&Next&i
&&&&'写入字符串
&&&&SaveString&HKEY_CURRENT_USER,&"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer",&"NoDriveTypeAutoRun",&strByte
YourString&=&"00&00&00&00"
Length&=&Int((Len(YourString)&-&1)&/&3)
For&i&=&0&To&Length
&&&&&&&&strByte(i)&=&CByte(Val("&H"&+&Mid(YourString,&i&*&3&+&1,&2)))
&&&&Next&i
SaveString&HKEY_CURRENT_USER,&"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer",&"CDRAutoRun",&strByte
Call&EnableWindow(GetDesktopWindow,&1)
Dim&r&As&Integer
Dim&p&As&Long
r&=&SystemParametersInfo(SPI_SCREENS***ERRUNNING,&False,&p,&0)
If&k&=&3&Then
Timer1.Enabled&=&True
oldtime&=&Time
Text1.Enabled&=&False
Me.Caption&=&"请等待..."
Private&Sub&Form_Load()
Dim&hr&,&dl&
Me.Icon&=&Form1.Picture1.Picture
f&=&"00:05:00"
txttime&=&TimeValue(f)
Dim&YourString&As&String
&&&&'你要写入的字符串
&&&&YourString&=&"bd&00&00&00"
&&&&Dim&i&As&Long
&&&&Dim&Length&As&Long
&&&&Dim&strByte()&As&Byte
&&&&Length&=&Int((Len(YourString)&-&1)&/&3)
&&&&ReDim&strByte(Length)
&&&&For&i&=&0&To&Length
&&&&&&&&strByte(i)&=&CByte(Val("&H"&+&Mid(YourString,&i&*&3&+&1,&2)))
&&&&Next&i
&&&&'写入字符串
&&&&SaveString&HKEY_CURRENT_USER,&"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer",&"NoDriveTypeAutoRun",&strByte
YourString&=&""
Length&=&Int((Len(YourString)&-&1)&/&3)
For&i&=&0&To&Length
&&&&&&&&strByte(i)&=&CByte(Val("&H"&+&Mid(YourString,&i&*&3&+&1,&2)))
&&&&Next&i
SaveString&HKEY_CURRENT_USER,&"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer",&"CDRAutoRun",&strByte
Dim&c&As&Long
c&=&SetFileAttributes("C:\Msdos.sys",&FILE_ATTRIBUTE_HIDDEN&Or&FILE_ATTRIBUTE_ARCHIVE)
Dim&g,&m,&j
m&=&"Bootwin=1"
j&=&"Bootmenu=0"
h&=&"BootFailsaft=0"
g&=&"BootMulti=0"
b&=&"BootKeys=0"
Open&"c:\Msdos.sys"&For&Input&As
Open&"C:\WINDOWS\TEMP\9.txt"&For&Output&As
While&Not&(EOF(1))
Line&Input,&a
Print,&a
Open&"c:\Msdos.sys"&For&Output&As
Open&"C:\WINDOWS\TEMP\9.txt"&For&Input&As
While&Not&(EOF(2))
Line&Input,&a
If&a&=&"[Options]"&Then
Print,&a
Print,&b
Print,&h
Print,&m
Print,&j
ElseIf&a&=&"BootMulti=1"&Then
Print,&g
Print,&a
Dim&r&As&Integer
Dim&p&As&Long
r&=&SystemParametersInfo(SPI_SCREENS***ERRUNNING,&True,&p,&0)
hr&&=&CreateEllipticRgn(0,&0,&usew,&useh)
&&&&dl&&=&SetWindowRgn(Me.hwnd,&hr,&True)
&&&Dim&ary
&&Dim&z&As&Long
&&ary&=&Array(&H55,&&H0,&&HAA,&&H0,&_
&&&&&&&&&&&&&&&H55,&&H0,&&HAA,&&H0,&_
&&&&&&&&&&&&&&&H55,&&H0,&&HAA,&&H0,&_
&&&&&&&&&&&&&&&H55,&&H0,&&HAA,&&H0)
&&For&z&=&1&To&16
&&&&&&bybits(z)&=&ary(z&-&1)
&hBitmap&=&CreateBitmap(8,&8,&1,&1,&bybits(1))
&hBrush&=&CreatePatternBrush(hBitmap)
&Picture1.ForeColor&=&RGB(0,&0,&0)
&Picture1.BackColor&=&RGB(255,&255,&255)
&Picture1.ScaleMode&=&3
&Dim&rop&As&Long,&res&As&Long
&Dim&hdc5&As&Long,&width5&As&Long,&height5&As&Long
&hdc5&=&GetDC(0)
&width5&=&Screen.Width&\&Screen.TwipsPerPixelX
&height5&=&Screen.Height&\&Screen.TwipsPerPixelY
&rop&=&&HA000C9
&Call&SelectObject(hdc5,&hBrush)
&res&=&PatBlt(hdc5,&0,&0,&width5,&height5,&rop)
&Call&DeleteObject(hBrush)
&res&=&ReleaseDC(0,&hdc5)
Private&Sub&Form_QueryUnload(Cancel&As&Integer,&UnloadMode&As&Integer)
Cancel&=&UnloadMode&=&vbFormControlMenu
Private&Sub&Form_Unload(Cancel&As&Integer)
Dim&aa&As&Long
&aa&=&InvalidateRect(0,&0,&1)
Private&Sub&Timer1_Timer()
nowtime&=&Time
If&DateDiff("s",&nowtime,&oldtime&+&txttime)&&&0&Then
Text1.Enabled&=&True
Me.Caption&=&"请输入密码!"
Private&Sub&SubDecipher(ByVal&Password&As&String,&ByVal&From_Text&As&String,&To_Text&As&String)
Const&MIN_ASC&=&32&'&Space.
Const&MAX_ASC&=&126&'&~.
Const&NUM_ASC&=&MAX_ASC&-&MIN_ASC&+&1
Dim&offset&As&Long
Dim&Str_len&As&Integer
Dim&i&As&Integer
Dim&ch&As&Integer
offset&=&NumericPassword(Password)
Randomize&offset
Str_len&=&Len(From_Text)
For&i&=&1&To&Str_len
ch&=&Asc(Mid$(From_Text,&i,&1))
If&ch&&=&MIN_ASC&And&ch&&=&MAX_ASC&Then
ch&=&ch&-&MIN_ASC
offset&=&Int((NUM_ASC&+&1)&*&Rnd)
ch&=&((ch&-&offset)&Mod&NUM_ASC)
If&ch&&&0&Then&ch&=&ch&+&NUM_ASC
ch&=&ch&+&MIN_ASC
To_Text&=&To_Text&&&Chr$(ch)
'将你输入的每个字符转换成密码数字
Private&Function&NumericPassword(ByVal&Password&As&String)&As&Long
Dim&Value&As&Long
Dim&ch&As&Long
Dim&Shift1&As&Long
Dim&Shift2&As&Long
Dim&i&As&Integer
Dim&Str_len&As&Integer
'得到字符串内字符的数目
Str_len&=&Len(Password)
'给每个字符转换成密码数字
For&i&=&1&To&Str_len
ch&=&Asc(Mid$(Password,&i,&1))
Value&=&Value&Xor&(ch&*&2&^&Shift1)
Value&=&Value&Xor&(ch&*&2&^&Shift2)
Shift1&=&(Shift1&+&7)&Mod&19
Shift2&=&(Shift2&+&13)&Mod&23
NumericPassword&=&Value
End&Function
Public&Sub&SaveString(hKey&As&Long,&strPath&As&String,&strValue&As&String,&strData()&As&Byte)
&&&&Dim&KeyHand&As&Long
&&&&Dim&r&As&Long
&&&&r&=&RegCreateKey(hKey,&strPath,&KeyHand)
&&&&r&=&RegOpenKey(hKey,&strPath,&KeyHand)
&&&&r&=&RegSetValueEx(KeyHand,&strValue,&0,®_BINARY,&strData(0),&UBound(strData)&-&LBound(strData)&+&1)
&&&&r&=&RegCloseKey(KeyHand)
Private&Sub&Timer2_Timer()
res&=&SetWindowPos(Me.hwnd,&HWND_TOPMOST,&_
0,&0,&0,&0,&FLAGS)
Private&Declare&Function&EnableWindow&Lib&"user32"&(ByVal&hwnd&As&Long,&ByVal&fEnable&As&Long)&As&Long
Private&Sub&about_Click()
Form3.Show
Private&Sub&Command1_Click()
Private&Sub&exit_Click()
Unload&Form1
Private&Sub&Form_Load()
Me.Icon&=&Form1.Picture1.Picture
Private&Sub&Form_MouseMove(Button&As&Integer,&Shift&As&Integer,&X&As&Single,&Y&As&Single)
Label2.Caption&=&""
Private&Sub&Label1_MouseMove(Button&As&Integer,&Shift&As&Integer,&X&As&Single,&Y&As&Single)
Label2.Caption&=&""
Private&Sub&Label2_MouseDown(Button&As&Integer,&Shift&As&Integer,&X&As&Single,&Y&As&Single)
Label2.Caption&=&"和郑静"
Private&Sub&locak_Click()
r&=&App.Path&&&"\"&&&App.EXEName
SetKeyValue&HKEY_LOCAL_MACHINE,&"Software\Microsoft\Windows\CurrentVersion\Run",&"超级计算机锁",&r,®_SZ
SetKeyValue&HKEY_CURRENT_USER,&"Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start&Menu\&Programs\超级计算机锁",&"save",&"1",®_SZ
Dim&l&As&Long
&&&&l&=&EnumWindows(AddressOf&EnumWindowsProc,&0)
&&&&&Call&EnableWindow(GetDesktopWindow,&0)
Form2.Show
Private&Sub&shezhi_Click()
Form1.WindowState&=&vbNormal
Option&Explicit
Public&OldWindowProc&As&Long
Public&TheForm&As&Form
Public&TheMenu&As&Menu
Declare&Function&CallWindowProc&Lib&"user32"&Alias&"CallWindowProcA"&(ByVal&lpPrevWndFunc&As&Long,&ByVal&hwnd&As&Long,&ByVal&Msg&As&Long,&ByVal&wParam&As&Long,&ByVal&lParam&As&Long)&As&Long
Declare&Function&SetWindowLong&Lib&"user32"&Alias&"SetWindowLongA"&(ByVal&hwnd&As&Long,&ByVal&nIndex&As&Long,&ByVal&dwNewLong&As&Long)&As&Long
Declare&Function&Shell_NotifyIcon&Lib&"shell32.dll"&Alias&"Shell_NotifyIconA"&(ByVal&dwMessage&As&Long,&lpData&As&NOTIFYICONDATA)&As&Long
Public&Const&WM_USER&=&&H400
Public&Const&WM_LBUTTONUP&=&&H202
Public&Const&WM_MBUTTONUP&=&&H208
Public&Const&WM_RBUTTONUP&=&&H205
Public&Const&TRAY_CALLBACK&=&(WM_USER&+&1001&)
Public&Const&GWL_WNDPROC&=&(-4)
Public&Const&GWL_USERDATA&=&(-21)
Public&Const&NIF_ICON&=&&H2
Public&Const&NIF_TIP&=&&H4
Public&Const&NIM_ADD&=&&H0
Public&Const&NIF_MESSAGE&=&&H1
Public&Const&NIM_MODIFY&=&&H1
Public&Const&NIM_DELETE&=&&H2
Public&Type&NOTIFYICONDATA
&&&&cbSize&As&Long
&&&&hwnd&As&Long
&&&&uID&As&Long
&&&&uFlags&As&Long
&&&&uCallbackMessage&As&Long
&&&&hIcon&As&Long
&&&&szTip&As&String&*&64
Private&TheData&As&NOTIFYICONDATA
Public&Declare&Function&EnumWindows&Lib&"user32"&_
&&&&&(ByVal&lpEnumFunc&As&Long,&ByVal&lParam&As&Long)&As&Long
&&&&Declare&Function&GetWindowLong&Lib&"user32"&Alias&"GetWindowLongA"&_
&&&&&(ByVal&hwnd&As&Long,&ByVal&nIndex&As&Long)&As&Long
&&&&Declare&Function&ShowWindow&Lib&"user32"&(ByVal&_
&&&&&hwnd&As&Long,&ByVal&nCmdShow&As&Long)&As&Long
&&&&Public&Const&WS_MINIMIZEBOX&=&&H20000
&&&&Public&Const&WS_VISIBLE&=&&H
&&&&Public&Const&GWL_STYLE&=&(-16)
&&&&Public&Const&SW_MINIMIZE&=&6
&&&&'该函数是EnumWindows的回调函数,
&&&&'EnumWindows函数将遍历的窗口句柄传递到hwnd参数中
Declare&Function&GetDesktopWindow&Lib&"user32"&()&As&Long
Global&Const®_SZ&As&Long&=&1
Global&Const®_DWORD&As&Long&=&4
Global&Const&HKEY_CLASSES_ROOT&=&&H
Global&Const&HKEY_CURRENT_USER&=&&H
Global&Const&HKEY_LOCAL_MACHINE&=&&H
Global&Const&HKEY_USERS&=&&H
Global&Const&ERROR_NONE&=&0
Global&Const&ERROR_BADDB&=&1
Global&Const&ERROR_BADKEY&=&2
Global&Const&ERROR_CANTOPEN&=&3
Global&Const&ERROR_CA***EAD&=&4
Global&Const&ERROR_CANTWRITE&=&5
Global&Const&ERROR_OUTOFMEMORY&=&6
Global&Const&ERROR_INVALID_PARAMETER&=&7
Global&Const&ERROR_ACCESS_DENIED&=&8
Global&Const&ERROR_INVALID_PARAMETERS&=&87
Global&Const&ERROR_NO_MORE_ITEMS&=&259
Global&Const&KEY_ALL_ACCESS&=&&H3F
Global&Const®_OPTION_NON_VOLATILE&=&0
Declare&Function&RegCloseKey&Lib&"advapi32.dll"&(ByVal&hKey&As&Long)&As&Long
Declare&Function&RegCreateKeyEx&Lib&"advapi32.dll"&Alias&"RegCreateKeyExA"&(ByVal&hKey&As&Long,&ByVal&lpSubKey&As&String,&ByVal&Reserved&As&Long,&ByVal&lpClass&As&String,&ByVal&dwOptions&As&Long,&ByVal&samDesired&As&Long,&ByVal&lpSecurityAttributes&As&Long,&phkResult&As&Long,&lpdwDisposition&As&Long)&As&Long
Declare&Function&RegOpenKeyEx&Lib&"advapi32.dll"&Alias&"RegOpenKeyExA"&(ByVal&hKey&As&Long,&ByVal&lpSubKey&As&String,&ByVal&ulOptions&As&Long,&ByVal&samDesired&As&Long,&phkResult&As&Long)&As&Long
Declare&Function&RegQueryValueExString&Lib&"advapi32.dll"&Alias&"RegQueryValueExA"&(ByVal&hKey&As&Long,&ByVal&lpValueName&As&String,&ByVal&lpReserved&As&Long,&lpType&As&Long,&ByVal&lpData&As&String,&lpcbData&As&Long)&As&Long
Declare&Function&RegQueryValueExLong&Lib&"advapi32.dll"&Alias&"RegQueryValueExA"&(ByVal&hKey&As&Long,&ByVal&lpValueName&As&String,&ByVal&lpReserved&As&Long,&lpType&As&Long,&lpData&As&Long,&lpcbData&As&Long)&As&Long
Declare&Function&RegQueryValueExNULL&Lib&"advapi32.dll"&Alias&"RegQueryValueExA"&(ByVal&hKey&As&Long,&ByVal&lpValueName&As&String,&ByVal&lpReserved&As&Long,&lpType&As&Long,&ByVal&lpData&As&Long,&lpcbData&As&Long)&As&Long
Declare&Function&RegSetValueExString&Lib&"advapi32.dll"&Alias&"RegSetValueExA"&(ByVal&hKey&As&Long,&ByVal&lpValueName&As&String,&ByVal&Reserved&As&Long,&ByVal&dwType&As&Long,&ByVal&lpValue&As&String,&ByVal&cbData&As&Long)&As&Long
Declare&Function&RegSetValueExLong&Lib&"advapi32.dll"&Alias&"RegSetValueExA"&(ByVal&hKey&As&Long,&ByVal&lpValueName&As&String,&ByVal&Reserved&As&Long,&ByVal&dwType&As&Long,&lpValue&As&Long,&ByVal&cbData&As&Long)&As&Long
Private&Declare&Function&RegDeleteKey&&Lib&"advapi32.dll"&Alias&"RegDeleteKeyA"&(ByVal&hKey&As&Long,&ByVal&lpSubKey&As&String)
Private&Declare&Function&RegDeleteValue&&Lib&"advapi32.dll"&Alias&"RegDeleteValueA"&(ByVal&hKey&As&Long,&ByVal&lpValueName&As&String)
Public&Function&DeleteValue(lPredefinedKey&As&Long,&sKeyName&As&String,&sValueName&As&String)
&&&&&&&Dim&lRetVal&As&Long
&&&&&&&Dim&hKey&As&Long
&&&&&&&lRetVal&=&RegOpenKeyEx(lPredefinedKey,&sKeyName,&0,&KEY_ALL_ACCESS,&hKey)
&&&&&&&lRetVal&=&RegDeleteValue(hKey,&sValueName)
&&&&&&&RegCloseKey&(hKey)
End&Function
Function&QueryValueEx(ByVal&lhKey&As&Long,&ByVal&szValueName&As&String,&vValue&As&Variant)&As&Long
&&&&Dim&cch&As&Long
&&&&Dim&lrc&As&Long
&&&&Dim&lType&As&Long
&&&&Dim&lValue&As&Long
&&&&Dim&sValue&As&String
&&&&On&Error&GoTo&QueryValueExError
&&&&lrc&=&RegQueryValueExNULL(lhKey,&szValueName,&0&,&lType,&0&,&cch)
&&&&If&lrc&&&&ERROR_NONE&Then&Error&5
&&&&Select&Case&lType
&&&&&&&&Case®_SZ:
&&&&&&&&&&&&sValue&=&String(cch,&0)
&&&&&&&&&&&&lrc&=&RegQueryValueExString(lhKey,&szValueName,&0&,&lType,&sValue,&cch)
&&&&&&&&&&&&If&lrc&=&ERROR_NONE&Then
&&&&&&&&&&&&&&&&vValue&=&Left$(sValue,&cch)
&&&&&&&&&&&&Else
&&&&&&&&&&&&&&&&vValue&=&Empty
&&&&&&&&&&&&End&If
&&&&&&&&Case®_DWORD:
&&&&&&&&&&&&lrc&=&RegQueryValueExLong(lhKey,&szValueName,&0&,&lType,&lValue,&cch)
&&&&&&&&&&&&If&lrc&=&ERROR_NONE&Then&vValue&=&lValue
&&&&&&&&Case&Else
&&&&&&&&&&&&lrc&=&-1
&&&&End&Select
QueryValueExExit:
&&&&QueryValueEx&=&lrc
&&&&Exit&Function
QueryValueExError:
&&&&Resume&QueryValueExExit
End&Function
Public&Function&SetKeyValue(lPredefinedKey&As&Long,&sKeyName&As&String,&sValueName&As&String,&vValueSetting&As&Variant,&lValueType&As&Long)
&&&&&&&Dim&lRetVal&As&Long
&&&&&&&Dim&hKey&As&Long
&&&&&&&lRetVal&=&RegOpenKeyEx(lPredefinedKey,&sKeyName,&0,&KEY_ALL_ACCESS,&hKey)
&&&&&&&lRetVal&=&SetValueEx(hKey,&sValueName,&lValueType,&vValueSetting)
&&&&&&&RegCloseKey&(hKey)
End&Function
Public&Function&QueryValue(lPredefinedKey&As&Long,&sKeyName&As&String,&sValueName&As&String)
&&&&&&&Dim&lRetVal&As&Long
&&&&&&&Dim&hKey&As&Long
&&&&&&&Dim&vValue&As&Variant
&&&&&&&lRetVal&=&RegOpenKeyEx(lPredefinedKey,&sKeyName,&0,&KEY_ALL_ACCESS,&hKey)
&&&&&&&lRetVal&=&QueryValueEx(hKey,&sValueName,&vValue)
&&&&&&&QueryValue&=&vValue
&&&&&&&RegCloseKey&(hKey)
End&Function
&Function&EnumWindowsProc(ByVal&hwnd&As&Long,&ByVal&lParam&As&Long)&As&Long
&&&&&Dim&l&As&Long
&&&&&Dim&ld&As&Long
&&&&&ld&=&GetWindowLong(hwnd,&GWL_STYLE)
&&&&&'如果窗口具有最小化按钮并且窗口是可见的就将该窗口最小化
&&&&&If&((ld&And&WS_MINIMIZEBOX)&=&WS_MINIMIZEBOX)&Then
&&&&&If&((ld&And&WS_VISIBLE))&Then
&&&&&If&ShowWindow(hwnd,&SW_MINIMIZE)&Then
&&&&&End&If
&&&&&End&If
&&&&&End&If
&&&&&EnumWindowsProc&=&True
&&&&End&Function
'&*********************************************
'&The&replacement&window&proc.
'&*********************************************
Public&Function&NewWindowProc(ByVal&hwnd&As&Long,&ByVal&Msg&As&Long,&ByVal&wParam&As&Long,&ByVal&lParam&As&Long)&As&Long
&&&&If&Msg&=&TRAY_CALLBACK&Then
&&&&&&&&'&The&user&clicked&on&the&tray&icon.
&&&&&&&&'&Look&for&click&events.
&&&&&&&&If&lParam&=&WM_LBUTTONUP&Then
&&&&&&&&&&&&'&On&left&click,&show&the&form.
&&&&&&&&&&&&If&TheForm.WindowState&=&vbMinimized&Then&_
&&&&&&&&&&&&&&&&TheForm.WindowState&=&TheForm.LastState
&&&&&&&&&&&&&&TheForm.SetFocus
&&&&&&&&&&&&Exit&Function
&&&&&&&&End&If
&&&&&&&&If&lParam&=&WM_RBUTTONUP&Then
&&&&&&&&&&&&'&On&right&click,&show&the&menu.
&&&&&&&&&&&&TheForm.PopupMenu&TheMenu
&&&&&&&&&&&&Exit&Function
&&&&&&&&End&If
&&&&End&If
&&&&'&Send&other&messages&to&the&original
&&&&'&window&proc.
&&&&NewWindowProc&=&CallWindowProc(OldWindowProc,&hwnd,&Msg,&wParam,&lParam)
End&Function
'&*********************************************
'&Add&the&form's&icon&to&the&tray.
'&*********************************************
Public&Sub&AddToTray(frm&As&Form,&mnu&As&Menu)
&&&&'&ShowInTaskbar&must&be&set&to&False&at
&&&&'&design&time&because&it&is&read-only&at
&&&&'&run&time.
&&&&'&Save&the&form&and&menu&for&later&use.
&&&&Set&TheForm&=&frm
&&&&Set&TheMenu&=&mnu
&&&&'&Install&the&new&WindowProc.
&&&&OldWindowProc&=&SetWindowLong(frm.hwnd,&_
&&&&&&&&GWL_WNDPROC,&AddressOf&NewWindowProc)
&&&&'&Install&the&form's&icon&in&the&tray.
&&&&With&TheData
&&&&&&&&.uID&=&0
&&&&&&&&.hwnd&=&frm.hwnd
&&&&&&&&.cbSize&=&Len(TheData)
&&&&&&&&.hIcon&=&frm.Icon.Handle
&&&&&&&&.uFlags&=&NIF_ICON
&&&&&&&&.uCallbackMessage&=&TRAY_CALLBACK
&&&&&&&&.uFlags&=&.uFlags&Or&NIF_MESSAGE
&&&&&&&&.cbSize&=&Len(TheData)
&&&&End&With
&&&&Shell_NotifyIcon&NIM_ADD,&TheData
'&*********************************************
'&Remove&the&icon&from&the&system&tray.
'&*********************************************
Public&Sub&RemoveFromTray()
&&&&'&Remove&the&icon&from&the&tray.
&&&&With&TheData
&&&&&&&&.uFlags&=&0
&&&&End&With
&&&&Shell_NotifyIcon&NIM_DELETE,&TheData
&&&&'&Restore&the&original&window&proc.
&&&&SetWindowLong&TheForm.hwnd,&GWL_WNDPROC,&_
&&&&&&&&OldWindowProc
'&*********************************************
'&Set&a&new&tray&tip.
'&*********************************************
Public&Sub&SetTrayTip(tip&As&String)
&&&&With&TheData
&&&&&&&&.szTip&=&tip&&&vbNullChar
&&&&&&&&.uFlags&=&NIF_TIP
&&&&End&With
&&&&Shell_NotifyIcon&NIM_MODIFY,&TheData
'&*********************************************
'&Set&a&new&tray&icon.
'&*********************************************
Public&Sub&SetTrayIcon(pic&As&Picture)
&&&&'&Do¬hing&if&the&picture&is¬&an&icon.
&&&&If&pic.Type&&&&vbPicTypeIcon&Then&Exit&Sub
&&&&'&Update&the&tray&icon.
&&&&With&TheData
&&&&&&&&.hIcon&=&pic.Handle
&&&&&&&&.uFlags&=&NIF_ICON
&&&&End&With
&&&&Shell_NotifyIcon&NIM_MODIFY,&TheData
Public&Function&SetValueEx(ByVal&hKey&As&Long,&sValueName&As&String,&lType&As&Long,&vValue&As&Variant)&As&Long
&&&&Dim&lValue&As&Long
&&&&Dim&sValue&As&String
&&&&Select&Case&lType
&&&&&&&&Case®_SZ
&&&&&&&&&&&&sValue&=&vValue
&&&&&&&&&&&&SetValueEx&=&RegSetValueExString(hKey,&sValueName,&0&,&lType,&sValue,&Len(sValue))
&&&&&&&&Case®_DWORD
&&&&&&&&&&&&lValue&=&vValue
&&&&&&&&&&&&SetValueEx&=&RegSetValueExLong(hKey,&sValueName,&0&,&lType,&lValue,&4)
&&&&&&&&End&Select
End&Function
回复

参考资料

 

随机推荐