实在不行用Replace(str," ","")去掉空格好了

解决方案 »

  1.   

    Const HKEY_CURRENT_USER = &H80000001
    Const HKEY_LOCAL_MACHINE = &H80000002
    Const REG_SZ = 1&
    Const KEY_QUERY_VALUE = &H1&
    Const KEY_ENUMERATE_SUB_KEYS = &H8&
    Const KEY_NOTIFY = &H10&
    Const READ_CONTROL = &H20000
    Const STANDARD_RIGHTS_READ = READ_CONTROL
    Const KEY_READ = STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY
    Const HKEY_USERS = &H80000003Function GetStringValue(ByVal MainKeyHandle As Long, ByVal Subkey As String, entry As String)
       
       rtn = RegOpenKeyEx(MainKeyHandle, Subkey, 0, KEY_READ, hkey) 'open the key
       
       If rtn = ERROR_SUCCESS Then 'if the key could be opened then
          sBuffer = Space(255)     'make a buffer
          lBufferSize = Len(sBuffer)
          rtn = RegQueryValueEx(hkey, entry, 0, REG_SZ, sBuffer, lBufferSize) 'get the value from the registry
          If rtn = ERROR_SUCCESS Then 'if the value could be retreived then
             rtn = RegCloseKey(hkey)  'close the key
             sBuffer = Trim(sBuffer)
             GetStringValue = Left(sBuffer, Len(sBuffer) - 1) 'return the value to the user
          Else                        'otherwise, if the value couldnt be retreived
             GetStringValue = "" 'return Error to the user
          End If
       Else 'otherwise, if the key couldnt be opened
          GetStringValue = ""       'return Error to the user
       End IfEnd Function    SysIcon = GetStringValue(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\DefaultIcon", "")
      

  2.   

    试试这样,首先这样定义RegQueryValueEx:
    Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExW" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long         
    注意上面定义的Alias是RegQueryValueExW而不是通常的RegQueryValueExA
    然后对获得的结果进行strConv转换:
        sysicon = GetStringValue(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon", "")
        Debug.Print StrConv(sysicon, vbFromUnicode)
      

  3.   

    savesettings & getsettings
      

  4.   

    不行啊!在win98下这些代码都没错
    到了win2000下就没辙了……
      

  5.   

    那么你就用这个来试试
    Function CutSpace(Str as string) as string
    if not instr(str," ") then _
    cutspace=str: _
    exit function
    dim s() as string,i as integer,return_str as string
    s=split(str," ")
    for i= 0 to ubound(s)
    return_str=return_str+s(i)
    next
    erase s
    CutSpace=return_str
    End Function
      

  6.   

    我还是说清楚些吧
    返回的字符串用Debug命令print出来是
    abcde d e 
    若设置成abcdefg则返回
    abcdefg e f g
    而用MsgBox "返回字符串"则显示为abcde和abcdefg
    但用MsgBox "返回字符串"&"1"则还是显示为abcde和abcdefg而不是abcde1和abcdefg1
      

  7.   

    给你一个函数
    Private Function TrimNull(ByVal szNull As String) As String
        Dim m%
        
        m = InStr(szNull, Chr$(0))
        If (m) Then                                 ' Win95 puts adds a null value
            TrimNull = Mid$(szNull, 1, m - 1)
            
        Else
            TrimNull = ""                           ' WinNT does not add a nullchar
        End If
    End Function把这句话
    sBuffer = Trim(sBuffer)
    换成        
    sBuffer = TrimNull(sBuffer)