#include once "window9.bi"

Function PeekS(ByVal Memory As Any Ptr, iLen As Integer = 0) As String Export
	Dim sRetString As String
	Dim iCountBytes As Integer
	If iLen = 0 Then
		While TRUE
			If *Cast(Byte Ptr,(Memory+iCountBytes))<>0 Then
				iCountBytes+=1
			Else
				Exit While
			EndIf
		Wend
	Else
		iCountBytes = iLen
	EndIf
	If iCountBytes<>0 Then
		sRetString = Space(iCountBytes)
		CopyMemory(SAdd(sRetString),Cast(Byte Ptr,Memory),iCountBytes)
		Return sRetString
	EndIf
End Function
