Click here to Skip to main content
16,005,491 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: looking for hex->decimal editor Pin
Mike Nordell6-Sep-02 18:47
Mike Nordell6-Sep-02 18:47 
GeneralRe: looking for hex->decimal editor Pin
TyMatthews6-Sep-02 13:20
TyMatthews6-Sep-02 13:20 
QuestionIcon position in systemtray? Pin
Andreas Saurwein6-Sep-02 3:52
Andreas Saurwein6-Sep-02 3:52 
AnswerRe: Icon position in systemtray? Pin
Joaquín M López Muñoz6-Sep-02 6:49
Joaquín M López Muñoz6-Sep-02 6:49 
GeneralRe: Icon position in systemtray? Pin
Anonymous6-Sep-02 7:27
Anonymous6-Sep-02 7:27 
GeneralRe: Icon position in systemtray? Pin
Andreas Saurwein6-Sep-02 10:54
Andreas Saurwein6-Sep-02 10:54 
GeneralRe: Icon position in systemtray? Pin
Andreas Saurwein6-Sep-02 10:53
Andreas Saurwein6-Sep-02 10:53 
GeneralFilemapping Pin
Zizilamoroso6-Sep-02 3:37
Zizilamoroso6-Sep-02 3:37 
I've created an mfc-dll which contains a shared memory zone, to be shared by 2 instances.

The first instance creates the memory zone using CreateFileMapping(). The second instance opens the memory zone using OpenFileMapping(). They both get the pointer to the address of the first byte of the memory using MapViewOfFile().

That works just fine on a win98 machine. The 2 instances get the same address.

But if we run it on a winNT, the MapViewOfFile returns different addresses for the 2 instances (shared memory huh?). How is that possible?


Here's how I created the memory:
//  bInit is true for the first call
if(bInit)
{
    //  first process creates file mapping object
    //  =========================================
    hMapHandle=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,SHMEMSIZE,"XE_MEMORY_MAP");
    if(!hMapHandle)
        AfxMessageBox("CreateFileMapping failed");
}
else
{
    //  other process opens existing file mapping object
    //  ================================================
    hMapHandle=OpenFileMapping(FILE_MAP_ALL_ACCESS,FALSE,"XE_MEMORY_MAP");
    if(!hMapHandle)
        AfxMessageBox("OpenFileMapping failed");
}

//  all processes create a virtual map view
//  =======================================
lpMapAddress=MapViewOfFile(hMapHandle,FILE_MAP_ALL_ACCESS,0,0,0);
if(!lpMapAddress)
    AfxMessageBox("MapViewOfFile failed");

if(bInit)
    memset(lpMapAddress,0,SHMEMSIZE);

char buf[100];
sprintf(buf,"memory initialised: %d",bInit);
AfxMessageBox(buf);
sprintf(buf,"\tlpMapAddress=%p",lpMapAddress);
AfxMessageBox(buf);


lpMapAddress points to the same address on win98, but not on NT.



[VISUAL STUDIO 6.0] [MFC] [WIN98/2]

Dead | X| Bluute tette! Dead | X|
GeneralRe: Filemapping Pin
Joel Lucsy6-Sep-02 3:45
Joel Lucsy6-Sep-02 3:45 
GeneralRe: Filemapping Pin
Zizilamoroso6-Sep-02 3:54
Zizilamoroso6-Sep-02 3:54 
GeneralRe: Filemapping Pin
Tomasz Sowinski6-Sep-02 4:03
Tomasz Sowinski6-Sep-02 4:03 
GeneralRe: Filemapping Pin
Zizilamoroso6-Sep-02 4:12
Zizilamoroso6-Sep-02 4:12 
GeneralRe: Filemapping Pin
Tomasz Sowinski6-Sep-02 4:25
Tomasz Sowinski6-Sep-02 4:25 
GeneralRe: Filemapping Pin
Zizilamoroso6-Sep-02 4:31
Zizilamoroso6-Sep-02 4:31 
GeneralRe: Filemapping Pin
Tomasz Sowinski6-Sep-02 4:38
Tomasz Sowinski6-Sep-02 4:38 
GeneralRe: Filemapping Pin
Zizilamoroso6-Sep-02 4:43
Zizilamoroso6-Sep-02 4:43 
GeneralRe: Filemapping Pin
Joel Lucsy6-Sep-02 4:01
Joel Lucsy6-Sep-02 4:01 
GeneralRe: Filemapping Pin
Tomasz Sowinski6-Sep-02 3:48
Tomasz Sowinski6-Sep-02 3:48 
GeneralRe: Filemapping Pin
Todd Smith6-Sep-02 18:23
Todd Smith6-Sep-02 18:23 
GeneralCompile Error for _ConnectionPtr Pin
kiekar6-Sep-02 3:02
kiekar6-Sep-02 3:02 
GeneralRe: Compile Error for _ConnectionPtr Pin
Jawache6-Sep-02 3:40
Jawache6-Sep-02 3:40 
GeneralRe: Compile Error for _ConnectionPtr Pin
kiekar6-Sep-02 4:22
kiekar6-Sep-02 4:22 
GeneralRe: Compile Error for _ConnectionPtr Pin
Jawache6-Sep-02 4:43
Jawache6-Sep-02 4:43 
GeneralRe: Compile Error for _ConnectionPtr Pin
kiekar6-Sep-02 4:54
kiekar6-Sep-02 4:54 
GeneralRe: Compile Error for _ConnectionPtr Pin
Michael P Butler6-Sep-02 5:21
Michael P Butler6-Sep-02 5:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.