this is my problem:
=================
I mapped a file with this:
=================

invoke GetAppPath,ADDR buffer ;masmlib
invoke lstrcat,ADDR buffer,ADDR NomFichierEad;"chemin et nom fichier"

;en lecture /?criture ? ou lecture seule?
;-------------------------
invoke CreateFile,ADDR buffer,\
GENERIC_READ or GENERIC_WRITE ,\
FILE_SHARE_READ or FILE_SHARE_WRITE,\
NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_ARCHIVE,\
NULL
mov hFileEad,eax

;cr?? Memory Mapped File et y mappe tt le fichier
;pMemoryEad = d?part du fichier mapp?
;-----------------
invoke CreateFileMapping,hFileEad,NULL,PAGE_READWRITE,0,0,NULL
mov hMapFileEad,eax

invoke MapViewOfFile,hMapFileEad,FILE_MAP_WRITE,0,0,0
mov pMemoryEad,eax
;--------------
;size of file
;--------------
invoke GetFileSize,hFileEad,NULL
mov LenFileEad,eax


.......
.....

========================
here I delete a data in mapped file:
=========================
I am deleting an data while transferring the last part of file ,on the data that I want to delete,
(overwriting)

push ecx
push esi
push edi
mov ecx,eax; number bytes to move
mov esi,EndData
mov edi,BeginData
cld
xor eax,eax
stosb
rep movsb

pop edi
pop esi
pop ecx

==============
then this is the code:
;------------------------
;point to the begin of file
invoke SetFilePointer,hFileEad,0,NULL,FILE_BEGIN
;---------------------------------------
;calculate the new size of file
;---------------------------------------
mov ecx,BeginData
mov ebx,EndData
sub ebx,ecx ;Long de la dd supprim?e en ebx

mov ecx,LenFileEad ;old size of file
sub ecx,ebx
mov LenFileEad,ecx ;new size du fichier

invoke WriteFile,hFileEad,pMemoryEad,LenFileEad,ADDR SizeReadWrite,NULL
===========
so I read that in the BOOK:
===========
;If you called CreateFileMapping to create a file-mapping object
;for hFile, you must first call UnmapViewOfFile to unmap all views
;and call CloseHandle to close the file-mapping object
;before you can call SetEndOfFile.
==========
so I make this:
===========

invoke UnmapViewOfFile,pMemoryEad
invoke CloseHandle,hMapFileEad
;met EOF ? la nvelle place
invoke SetEndOfFile,hFileEad

.IF hMapFileEad!=0
;invoke CloseHandle,hMapFileEad
mov hMapFileEad,0
invoke CloseHandle,hFileEad
.ENDIF

call OuvreFichierEad; open again and map file again
invoke RempliListBoxEad,hListBoxChoixNomEad
....................
........................

The problem is that seems to work fine with Windows 98

With windowsXP ,I saw the file with an editor, and I remarked that the file has the same size that the old size (not with 98)
that there is a EOF (00) at the end of part that I had transferred
ex 00 0D 00 74 79 74 (not with 98)
where is my error?
00 00
Posted on 2002-06-30 04:50:02 by franlou
I advise you use SetEndOfFile.
Posted on 2002-06-30 12:18:35 by comrade
I thought that 'SendEndOfFile' was to shrink the file?
Posted on 2002-06-30 12:23:05 by franlou
SetEndOfFile sets new EOF at current position set with SetFilePointer.
What are you trying to do?
Posted on 2002-06-30 12:25:08 by comrade