我现在取环境变量path的他的位置在注册表里的
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment 这个下面我现在写的取值格式不知道对不对? 请大家指教下?  s = QueryValue(HKEY_LOCAL_MACHINE, "SYSTEM\ControlSet001\Control\Session Manager\Environment", "Path")用这个我取出来的是空值
下面是API代码 从 http://topic.csdn.net/t/20030124/15/1390232.html  这个地方拷贝过来用的 
请大家指教下 急用 谢谢~

解决方案 »

  1.   

    他的这个函数有问题
    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   REG_SZ,2:   
                              sValue   =   String(cch,   0)   
                              lrc   =   RegQueryValueExString(lhKey,   szValueName,   0&,   lType,   sValue,   cch)   
                              If   lrc   =   ERROR_NONE   Then   
                                      vValue   =   Left$(sValue,   cch   -   1)   
                              Else   
                                      vValue   =   Empty   
                              End   If   
        
                      Case   REG_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   lType=2也是字符串类型
    Select   Case   lType   这地方漏了一个判断,给你改了一下