
function StreamIn(byval hFile as long,byval pBuffer as long,byval NumBytes as long,byval pBytesRead as long) as boolean

	return ReadFile(hFile,pBuffer,NumBytes,pBytesRead,0) xor 1

end function

function StreamOut(byval hFile as long,byval pBuffer as long,byval NumBytes as long,byval pBytesWritten as long) as boolean

	return WriteFile(hFile,pBuffer,NumBytes,pBytesWritten,0) xor 1

end function

sub ReadTheFile(byval hWin as HWND)
	dim editstream as EDITSTREAM
	dim hFile as HANDLE

	hFile=CreateFile(FileName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0)
	if hFile<>INVALID_HANDLE_VALUE then
		SendMessage(hREd,WM_SETTEXT,0,StrPtr(""))
		nLastLine=0
		editstream.dwCookie=hFile
		editstream.pfnCallback=@StreamIn
		SendMessage(hREd,EM_STREAMIN,SF_TEXT,@editstream)
		SendMessage(hREd,REM_SETBLOCKS,0,0)
		SendMessage(hREd,EM_SETMODIFY,FALSE,0)
		CloseHandle(hFile)
	endif

end sub

sub WriteTheFile(byval hWin as HWND)
	dim editstream as EDITSTREAM
	dim hFile as HANDLE

	hFile=CreateFile(FileName,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0)
	if hFile<>INVALID_HANDLE_VALUE then
		editstream.dwCookie=hFile
		editstream.pfnCallback=@StreamOut
		SendMessage(hREd,EM_STREAMOUT,SF_TEXT,@editstream)
		SendMessage(hREd,EM_SETMODIFY,FALSE,0)
		CloseHandle(hFile)
	endif

end sub

