VB的一段代码~~不知道在干什么,,求指点啊!~!

Private Declare Function GetWindowsDirectory Lib "kernel32" Alias _
"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long '在form窗体中声明改函数

Private Declare Function SystemParametersInfo Lib "user32" Alias _
"SystemParametersInfoA" (ByVal uAction&, ByVal uParam&, ByVal lpvParam As Any, ByVal fuWinIni&) As Long

Const SPI_SetDeskWallpaper = 20
Const SPIF_SENDWININICHANGE = &H2
Const SPIF_UPDATEINIFILE = &H1
Const REG_SZ As Long = 1
Const HKEY_CURRENT_USER = &H80000001

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias _
"RegOpenKeyExA" (ByVal hKey&, ByVal lpSubKey$, ByVal ulOptions&, ByVal samDesired&, phkResult&) As Long

Private Declare Function RegSetValueExString Lib "advapi32.dll" Alias _
"RegSetValueExA" (ByVal hKey&, ByVal lpValueName$, ByVal Reserved&, ByVal dwType&, ByVal lpValue$, ByVal cbData&) As Long

Private Declare Function RegSetValueExLong Lib "advapi32.dll" Alias _
"RegSetValueExA" (ByVal hKey&, ByVal lpValueName$, ByVal Reserved&, ByVal dwType&, lpValue&, ByVal cbData&) As Long

第1个回答  2012-07-05
GetWindowsDirectory函数获取Windows目录的完整路径名
SystemParametersInfo函数查询或设置系统级参数
RegCloseKey保存注册表键值
RegOpenKeyEx打开注册表键值
RegSetValueExString修改注册表键值
这段代码主要是应用于自动切换桌面相关函数说明,他具体代码为
新建工程,在窗体加入一个timer控件,一个image控件
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize 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_SETDESKWALLPAPER = 20
Const SPIF_SENDWININICHANGE = &H2
Const SPIF_UPDATEINIFILE = &H1
Const REG_SZ As Long = 1
Const HKEY_CURRENT_USER = &H80000001

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Private 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

Private 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

Private 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 Sub Form_Load()
Timer1.Interval = 5000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static i As Integer
i = i Mod 2 + 1
Dim Path As String, strSave As String
strSave = String(50, Chr$(0))
Path = Left$(strSave, GetWindowsDirectory(strSave, Len(strSave)))
Image1.Picture = LoadPicture(App.Path & "\" & i & ".JPG")
SavePicture Image1, Path & "\" & i & ".bmp"
Dim aa As String
aa = Path & "\" & i & ".bmp"
ChangeWP = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, aa, 0)
End Sub

然后把文件夹里的图片名称修改为1.JPG,2.JPG。。。。。会自动更换桌面
经测试通过
第2个回答  2012-06-24
这些都是Windows系统提供的API函数和常量,具体含义可以分别百度,比如GetWindowsDirectory,百度百科的解释:http://baike.baidu.com/view/1292121.htm
每个API函数都有自己的用法,你可以看一些网上的例子,这些api函数也不光是VB可以用,VC、Delph等也可以用,是Windows系统本身提供的接口,语句里面的Lib "advapi32.dll",表名了提供该函数的动态连接库文件是"advapi32.dll",一般来说,无论xp、2000、win7,都支持这些API函数,但有个别是有限制的。
第3个回答  2012-06-24
SystemParametersInfo
该函数查询或设置系统级参数。该函数也可以在设置参数中更新用户配置文件。
SystemParametersInfo
这个函数能获取Windows目录的完整路径名。在这个目录里,保存了大多数windows应用程序文件及初始化文件

后面的就是写组册表用的啦。你把函数在百度上搜一下都能找到
第4个回答  2012-06-24
e ....什么啊这是。

VB的一段代码~~不知道在干什么,,求指点啊!~!
RegCloseKey保存注册表键值 RegOpenKeyEx打开注册表键值 RegSetValueExString修改注册表键值 这段代码主要是应用于自动切换桌面相关函数说明,他具体代码为 新建工程,在窗体加入一个timer控件,一个image控件 Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer...

vb小白求解释一段代码 各位高人求指教!!!
Finish = UBound 表示数组的上界 这两个主要是做循环用 Min = a 是初始化Min变量为数组第一个元素 For i = Start To Finish 'If a(i) < Min Then Min = a(i)Next i 这个代表遍历数组a 每一次循环 都会用当前最小数(也就是Min的值) 与数组a当前下标的元素比较 如果发现数组中的...

VB定时按键代码,不知道哪里错了,求高手指点
Timer1.Enabled = False End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If Format(Now, "HH:MM:SS") = "16:24:00" Then SendKeys"a"End If End Sub End Class ...

VB下标越界 半夜坐等 急!求指点!
Dim nn As Single Dim x(1 To 100) As Single Dim z(1 To 100) As Single Dim f(1 To 100) As Single Dim ny(1 To 100) As Single Dim lz(1 To 100) As Single n = 10000 For i = 1 To 100 x(i) = (6 * sl \/ 100) * (2 * i - 1) \/ 2 z(i) = (x(i) ...

VB中这段代码是什么意思?请高手指点,求详解。
Do Line Input #1, s '把文件1逐行读入变量s s = Trim(s) '把字符串前后的空格都去掉 If 1 = InStr(1, s,"$number") Then '如果字符串的开头是“$number”s =modifysecond(s, num) '就执行自定义函数modifysecond End If Loop While Not EOF(1) '循环读取文件1的下...

怎样用vb做出以下效果求高手指点!!!
form1代码:Private Sub Command1_Click()Unload Me Form2.Show End Sub form2代码:Private Sub Form_Load()Timer1.Enabled = False Timer1.Interval = 60000 Timer1.Enabled = True End Sub Private Sub Timer1_Timer()Unload Me Form1.Show End Sub ...

vb代码求注释呀,有个地方看不明白,求大神指点
Next b 这段代码,从2到a-1依次与a进行取余运算,只有当这所有取余结果都不为零(即不能整除)时,可判断a为素数。而这时,b刚好和a的值相等。 如果中途有任何一个数取余为零,立即中止判断(根据定义,只要有一个数能被整除,它就不是素数,没有必要再判断下去),这时退出循环,必然会使得b...

如下一段VB程序,运行时提示运行错误13,类型不匹配。求高手指点_百度知 ...
【运行错误13,类型不匹配】这个,一般是指变量被赋予了一个不匹配类型的数值,比如把字符串赋给一个整形变量的时候。j(1)是什么,自定义的函数吗?参数的类型是什么?因为,有时参数传递时也会导致【类型不匹配】。我请问:报错时,断点出现在哪一行上?顺便…咳…问一声:有没有可能考虑一下,使用...

VB程序问题,急急急,求助!
1、提供界面让用户输入,只要一对文本框输入坐标,采用多次输入的方式(每次输入一个点)。在两个文本框输入坐标(x,y)后点击“添加”按钮,保存该坐标,如此循环录入即可。最好用一个标签提示当前已经输入的坐标。可以用二维数组保存所有已经输入的坐标(当然因为个数不确定,用集合Collection更好)。至于...

vb 填写补充一段程序的代码 求高手教教
1、k=left -1 是设定进行比较的数组元素的上限。由 A(Left) 跟[ A(Left-1) 到 A(1)] 进行比较 2、I 值的作用是返回相同元素的位置。3、left 是不断变化的,所以 for 肯定也在不断变化地比较。要理解这段代码,最好是自己跟着算一遍,下面是一个实际计算过程:最初数组: 5 9 6 ...

相似回答