Article View: borland.public.cppbuilder.nativeapi
Article #5271Re: How to use MapViewOfFile properly
From: Remy Lebeau (TeamB)
Date: Fri, 23 Sep 2005 00:08
Date: Fri, 23 Sep 2005 00:08
41 lines
2273 bytes
2273 bytes
"Thorsten Kettner" <QUESTIONBYthorsten.kettner@otto.de> wrote in message news:4332d7c6$1@newsgroups.borland.com... > I find it strange for instance that I must state again and again > that I want to have read access. You must not have read the MSDN documentation that describes memory-mapped files. An application can have multiple views of a single file, and each view can contain different areas of the file, each one with different access rights. > Then: How do I tell how many bytes to read? Do I use GetFileSize on the file handle? Yes. > In some forum I found VirtualQuery being used. Is that appropriate? That depends on what you are doing with the memory mapping in the first place. Mapping a file gives you access to the bytes of the file, but VirtualQuery() provides information about the paging system that is providing that access. > It gives me a slightly other file size (some bytes more then GetFileSize > and Windows Explorer do). As it should be, since pages have to aligned on particular memory boundaries. The extra bytes being reported are likely due to extra padding that is being applied to align the memory properly. > if(!MyFileMappingHandle) return; You did not close the file handle before returning. > if(!pFileView) return; You did not close the mapping or file handles before returning. Gambit
Technical Details
Message-ID:
<43334746$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4332d7c6$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,4205730aeea5d81c X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <4332d7c6$1@newsgroups.borland.com> Subject: Re: How to use MapViewOfFile properly Date: Thu, 22 Sep 2005 17:08:27 -0700 Lines: 43 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <43334746$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1127434054 68.69.17.41 (22 Sep 2005 17:07:34 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail