× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Not sure if it applies to spool files, but I know when using data queues
you need to use IcwbxStringConverter to and from bytes...

Dave
====
www.openDave.com

----------------------------------------

From: "ibm" <ibm@xxxxxxxxxx>
Sent: Thursday, June 25, 2009 10:34 AM
To: MIDRANGE-L@xxxxxxxxxxxx
Subject: API: cwbOBJ_ReadSplF

I'm trying to read the contents of a spooled file, but all I am getting
is garbage. Anyone have any insight into this?

Thanks

_

Public Shared Function cwbOBJ_ReadSplF(ByVal objectHandle As IntPtr,
_

ByVal bBuffer As IntPtr, _

ByVal bytesToRead As Integer,
_

ByRef bytesRead As Integer, _

ByVal errorHandle As IntPtr)
As Integer

End Function

Public Sub TryObjList()

Dim listSize As Integer = 0

Dim objHandle As IntPtr = IntPtr.Zero

Dim bBuffer As IntPtr = IntPtr.Zero

Dim bbBuffer(1000) As Byte

Dim bytesRead As Integer = 0

Dim CWBOBJ_RC_SPLFENDOFFILE As Integer = (6000 + 8)

m_LastError = cwbOBJ_CreateListHandle(m_SystemName,
enumObjListType.CWBOBJ_LIST_SPLF, m_Handle_ObjList, m_Handle_Error)

m_LastError = cwbOBJ_OpenList(m_Handle_ObjList,
enumObjListOpenType.CWBOBJ_LIST_OPEN_SYNCH, m_Handle_Error)

m_LastError = cwbOBJ_GetListSize(m_Handle_ObjList, listSize,
enumObjListStatus.CWBOBJ_LISTSTS_COMPLETED, m_Handle_Error)

For n As Integer = 0 To listSize - 1

Debug.WriteLine("-------------splf " & n.ToString & "
------------------")

m_LastError = cwbOBJ_GetObjHandle(m_Handle_ObjList, n,
objHandle, m_Handle_Error)

m_LastError = cwbOBJ_OpenSplF(objHandle, m_Handle_Error)

m_LastError = cwbOBJ_SeekSplF(objHandle,
enumSeekOrigin.CWBOBJ_SEEK_BEGINNING, 0, m_Handle_Error)

Do Until m_LastError = CWBOBJ_RC_SPLFENDOFFILE

bBuffer = Marshal.AllocHGlobal(1000)

m_LastError = cwbOBJ_ReadSplF(objHandle, bBuffer, 1000,
bytesRead, m_Handle_Error)

Marshal.Copy(bBuffer, bbBuffer, 0, 1000)

'Debug.WriteLine(System.Text.Encoding.ASCII.GetString(bbBuffer))

Debug.WriteLine(Marshal.PtrToStringUni(bBuffer))

Array.Clear(bbBuffer, 0, 1000)

Try

Marshal.FreeHGlobal(bBuffer)

Catch ex As Exception

End Try

Loop

m_LastError = cwbOBJ_CloseSplF(objHandle, m_Handle_Error)

m_LastError = cwbOBJ_DeleteObjHandle(objHandle,
m_Handle_Error)

objHandle = New IntPtr

Next

m_LastError = cwbOBJ_CloseList(m_Handle_ObjList, m_Handle_Error)

m_LastError = cwbOBJ_DeleteListHandle(m_Handle_ObjList,
m_Handle_Error)

End Sub


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.