Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!unix.cis.pitt.edu!dsinc!netnews.upenn.edu!eniac.seas.upenn.edu!gururaj From: gururaj@eniac.seas.upenn.edu (Ravi Gururaj) Newsgroups: comp.windows.ms Subject: Windows GlobalNotify Correction and Questions! Message-ID: <21154@netnews.upenn.edu> Date: 2 Mar 90 11:26:41 GMT Sender: news@netnews.upenn.edu Reply-To: gururaj@eniac.seas.upenn.edu (Ravi Gururaj) Organization: University of Pennsylvania Lines: 82 I need help! Has anyone used the GlobalNotify function. I am trying to figure out how it works. Apparently there was a problem with the documentation on the function in the SDK 2.0 Update - and Microsoft sent me a correction sheet. Summarised below for the benefit of others is the correction: ********* START UPDATE *********** Jan 12, 1990 1 The information on GlobalNotify() on Pages 12 and 13 of the "Microsoft Windows SDK Ver 2.0 Update" manual is incomplete. 2 The GlobalNotify() callback function will receive the segment address of the memory block, not the handle, as implied in the Ver 2.0 SDK Update manual. To retrieve the handle, callback routines should call GlobalHandle(). 3 Callback functions should not assume the data or stack segments of the application. 4 Do not call any routine that has the potential of moving memory. 5 To get your own DS, save it in the code segment. ********* END UPDATE *********** My Questions: 1 What are the implications of Point 3 above. 2 How do you achieve Point 4 above. What happens if you call a function in another code segment that then has to loaded into memory - hence maybe moving memory. Does all the code I intend to use in NotifyProc have to be in memory. 3 Here is what I am trying to use GlobalNotify for: Step 1: First I set up the notification procedure and allocate my mem block: GlobalNotify(MakeProcInstance(NotifyProc, hInstance)); gHandle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DISCARDABLE|GMEM_NOTIFY, 1000); Step 2: Here is the notification procedure: /* Start Listing */ BOOL FAR PASCAL NotifyProc(HANDLE mSegment) { HANDLE mHandle; LPSTR lpBuff; int fp, mSize; mHandle = GlobalHandle(mSegment); mSize = GlobalSize(mHandle); lpBuff = GlobalLock(mHandle); fp = _lcreat("MemDump.tmp", 2); _lwrite(fp, lpBuff, mSize); _lclose(fp); GlobalUnlock(mHandle); return(TRUE); } /* End Listing */ What the above will help me achieve is swap a global block of memory to disk before it is discarded and hence lost. I am trying to create a "virtual memory system" for some of my memory objects. The code above is almost exactly the code I have been trying to use. Can anyone explain how Points 3 & 4 affect my code. Yes - I have got everything else correct - like adding the NofifyProcto EXPORTS section of my .def file etc. I will be glad to post a final copy of the source to my virtual object system - only if I can very get it to work. Calling Microsoft has not helped - and it is quite difficult to explain my problem over the phone. No I don't have ONLINE. Maybe someon with ONLINE could put this question to MS. Thanks in advance for any suggestions, code samples and references etc. Ravi