🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #162

Re: Memory mapped files in a Service

#162
From: Colin B Maharaj
Date: Sat, 28 Jun 2008 12:11
90 lines
3345 bytes
Hi Mike, thanks for the reply,


Mike Collins wrote:
> Colin,
> 
> "Global\\".  This should work in all cases, regardless of Vista or XP (the 
> only exception being Windows 2K <).  I did not notice anothing in the 
> article that suggested "at times". 

The "at times" is what I have experienced in XP...
BTW: does Windows 2K < include Windows 2K or just NT/9x.

  I have a similar situation and it seems
> ot work in both Vista and XP.
> 
> Have you checked which part of your process is not working?
> 

The fact is that all objects are created without error.
However when you open the named object it simply says
file not found.

> Is it the initial CreateFileMapping or the OpenFileMapping?
> 
Open file mapping ...

> What does GetLastError() return?
> 
.... File Not found.


> What does ProcExplorer.exe show up as the file map name?
> 
Have to double check this....

> How are you controlling access to your MMF?
what do you mean by this? This is my code...

..........
// Code in Service

    bool Is9x = (Win32Platform == VER_PLATFORM_WIN32_WINDOWS);

    if (Is9x == false)//nt/2000/2003 server/xp pro/
    {
      //Beep(1000,20);
      SECURITY_DESCRIPTOR  sd;
      SECURITY_ATTRIBUTES  sa;
      InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
      SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
      sa.nLength = sizeof(sa);
      sa.lpSecurityDescriptor = &sd;
      sa.bInheritHandle = TRUE;
      mmHandle = CreateFileMapping((HANDLE) 0xFFFFFFFF,
                  &sa, PAGE_READWRITE, 0, mmSize, __TEXT(mmName));
    }
    else
    {
      mmHandle = CreateFileMapping((HANDLE) 0xFFFFFFFF,
                  NULL, PAGE_READWRITE, 0, mmSize, __TEXT(mmName));
    }

...........

//Code in Front end client

    hFileMapT = OpenFileMapping(FILE_MAP_READ | FILE_MAP_WRITE,
       FALSE, __TEXT(mmName));




> 
> Mike C
> 
> 
> "Colin B Maharaj" <noreply@myhost.com> wrote in message 
> news:48637046$1@newsgroups.borland.com...
>> Hi folks,
>> I recently had to fix a bug where my memory mapped file
>> that was running in my service application was not
>> visible to my foreground application.
>>
>> To fix this I had to add Global to the name like this.....
>>
>> From: "MMAPFILE"
>> To: "Global\\MMAPFILE"
>>
Technical Details
Message-ID: <48662A60.3060605@myhost.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail
References: <48637046$1@newsgroups.borland.com> <4863ab8c$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,ef43529cc999a6b2
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Message-ID: <48662A60.3060605@myhost.com>
Date: Sat, 28 Jun 2008 08:11:12 -0400
From: Colin B Maharaj <noreply@myhost.com>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Memory mapped files in a Service
References: <48637046$1@newsgroups.borland.com> <4863ab8c$1@newsgroups.borland.com>
In-Reply-To: <4863ab8c$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Antivirus: avast! (VPS 080628-0, 06/28/2008), Outbound message
X-Antivirus-Status: Clean
NNTP-Posting-Host: 190.58.98.8
X-Trace: newsgroups.borland.com 1214655072 190.58.98.8 (28 Jun 2008 05:11:12 -0700)
Lines: 90
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail