Newsgroups: comp.windows.ms.programmer
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!fauern!NewsServ!rommel
From: rommel@Informatik.TU-Muenchen.DE (Kai-Uwe Rommel)
Subject: Re: HELP with GlobalDosAlloc
Message-ID: <1991Apr15.162442.11660@Informatik.TU-Muenchen.DE>
Keywords: Windows Arggg help GlobalDosAlloc
Sender: news@Informatik.TU-Muenchen.DE
Organization: Technische Universitaet Muenchen, Germany
References: <26158@hydra.gatech.EDU>
Distribution: na
Date: Mon, 15 Apr 1991 16:24:42 GMT
Lines: 37

In article <26158@hydra.gatech.EDU> go3@prism.gatech.EDU (OLIVE JR,GEORGE A) writes:
>
>We are trying to use GlobalDosAlloc to allocate a block of memory to be
>shared by a Windows application and a DOS application which has been
>started using WinExec.  The following code shows the basic calls that
....
>when read by the DOS application.  We would be extremely grateful to 
>anyone who can point out what we are doing wrong.
>

>DWORD dwGlobalDos;
>WORD wDosSeg;
>HANDLE hDos;
>LPSTR lpDos;
>
>dwGlobalDos = GlobalDosAlloc(DOS_ALLOC_SIZE);
>wDosSeg = HIWORD(dwGlobalDos);
>hDos = LOWORD(GlobalHandle(LOWORD(dwGlobalDos)));
>lpDos = (LPSTR) GlobalLock(hDos);

The last two lines should be replaced by:

lpDos = (LPSTR) MAKELONG(0, LOWORD(dwGlobalDos));

because the low word of the result of GlobalDosAlloc() is a valid
protected mode segment selector which only has to be converted to a 
far pointer by adding an offset of zero to it.

This works well for me.

Kai Uwe Rommel

/* Kai Uwe Rommel, Munich ----- rommel@lan.informatik.tu-muenchen.dbp.de */

DOS ... is still a real mode only non-reentrant interrupt
handler, and always will be.                -Russell Williams (MS)

