[API]
lstrcpynA
lstrcpynW
lstrlenA
lstrlenW

[CODE]
Public Function PeekS(ByVal ptrChar As Long, Optional ByVal MaxLength As Long = -1&) As String
  Dim xLong1 As Long

  If Not ptrChar = 0& Then
    If MaxLength = -1& Then MaxLength = &HFFFF&
    If IsUnicode Then
      xLong1 = lstrlenW(ptrChar)
      If xLong1 > MaxLength Then xLong1 = MaxLength
      PeekS = String(xLong1 + 1&, vbNullChar)
      Call lstrcpynW(StrPtr(PeekS), ptrChar, xLong1 + 1&)
      Else
      xLong1 = lstrlenA(ptrChar)
      If xLong1 > MaxLength Then xLong1 = MaxLength
      PeekS = String(xLong1 + 1&, vbNullChar)
      Call lstrcpynA(PeekS, ptrChar, xLong1 + 1&)
      End If
    PeekS = Left(PeekS, xLong1)
    End If
  End Function
