🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #17219

Re: Een bestand 'memory mappen' in C.

#17219
From: Jos Branders
Date: Sun, 30 Jan 2000 00:00
44 lines
1940 bytes
Iets in deze stijl:

    m_hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)0);
    if ( m_hFile == INVALID_HANDLE_VALUE )  return;
    m_hFileMapping = CreateFileMapping(m_hFile,NULL, PAGE_READONLY, 0,
0,NULL);
    if ( m_hFileMapping == 0 )  {
        // Oops.  Something went wrong.  Clean up.
        CloseHandle(m_hFile);
        m_hFile = INVALID_HANDLE_VALUE;
        return;
    }
    m_pMemoryMappedFileBase =
PCHAR)MapViewOfFile( m_hFileMapping,FILE_MAP_READ, 0, 0, 0);
    if ( m_pMemoryMappedFileBase == 0 )   {
        // Oops.  Something went wrong.  Clean up.
        CloseHandle(m_hFileMapping);
        m_hFileMapping = 0;
        CloseHandle(m_hFile);
        m_hFile = INVALID_HANDLE_VALUE;
        return;
    }

Voor andere opties, zie de Windows API documentatie voor CreateFileMapping
en MapViewOfFile.

--
Jos Branders

Those who can, do.
Those who can't, teach.
Those who can't teach, rule.
(Free after George Bernard Shaw)

Andy Peeters <andy.peeters@advalvas.be> wrote in message
news:86v7af$o81$1@news1.skynet.be...
> Yow,
>
> Hoe kan je in C een bestand 'memory mappen' ?
>
> Andy.
>
>
Technical Details
Message-ID: <870spe$5to$1@news.worldonline.be>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <86v7af$o81$1@news1.skynet.be>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fcea4,d2bea607bcd14d75
X-Google-Attributes: gidfcea4,public
From: "Jos Branders" <nospam.jb@mediaport.org>
Subject: Re: Een bestand 'memory mappen' in C.
Date: 2000/01/30
Message-ID: <870spe$5to$1@news.worldonline.be>
X-Deja-AN: 579431792
References: <86v7af$o81$1@news1.skynet.be>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
X-Complaints-To: abuse@worldonline.be
X-Trace: news.worldonline.be 949220974 6072 212.233.41.200 (30 Jan 2000 08:29:34 GMT)
Organization: WorldOnline News server
X-MSMail-Priority: Normal
NNTP-Posting-Date: 30 Jan 2000 08:29:34 GMT
Newsgroups: be.comp.programming