本帖最后由 bcrun 于 2010-08-16 11:33:10 编辑

解决方案 »

  1.   

    Function XiuGai(ZhuoMianLujing As String)
    Dim re, hkey As Long
    re = RegOpenKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\user Shell Folders", hkey)
    If re = 0 Then
     RegSetValueEx hkey, "desktop", 0, REG_EXPAND_SZ, ZhuoMianLujing, 100
     MsgBox "已经成功修改,要起作用,请立即注销!", 64, "kg提示"
     regclosekey hkey '添加API,打开了可要记得关闭啊
    End If
    End FunctionPrivate Sub Command2_Click()
    Call XiuGai("C:\Documents and Settings\Administrator\桌面")
    End SubPrivate Sub OKButton_Click()
    Call XiuGai(Text1)
    End Sub
      

  2.   

    都是主窗体的代码
    private 过程只能在一个模块里使用(模块局部)
    public 的定义在函数里的全局(全部的模块)通用,定义在窗体模块或者类模块的需要用Form.xxx加上类前缀调用
      

  3.   

    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, ByVal lpData As String, ByVal cbData As Long) As Long         ' Note that if you declare the lpData parameter as String, you must pass it By Value.