Article View: comp.windows.ms.programmer
Article #2247Re: Passing data to a DLL; strange problem!
From: Adam Rybicki
Date: Mon, 22 Apr 1991 18:58
Date: Mon, 22 Apr 1991 18:58
54 lines
2110 bytes
2110 bytes
In article <1991Apr22.173022.8930@javelin.sim.es.com> lwallace@javelin.sim.es.com (Raptor) writes:
>(One wonders if I'll ever find a Windows technique that works the
>first time I try it...)
>
>I've recently broken my application up into a DLL and a main program
>module. One of the functions I've exported to the DLL needs to
>enumerate top-level windows, so I want to pass it my application's
>top-level window handle to feed FindWindow().
[...]
>HWND ParentHandle;
>...
>void FAR PASCAL TxferParentHandle(HWND hwnd)
>{
>ParentHandle = hwnd;
>}
>
>This is how I call it from my main module:
>
>HWND ParentHandle;
>...
>WinMain(...)
>{
>...
>TxferParentHandle(hwnd);
>}
>
>
>
>The DLL's copy of ParentHandle remains 0. hwnd is set as expected.
>It was baffling to execute the assignment statement in CodeView and
>see that it doesn't work!
>
>I have discovered, through CodeView, that the address of ParentHandle
>in the DLL is in a different segment from that shown in DS and SS
>(which are equal):
>
[...]
>Has anyone encountered this? Any suggestions?
>--
Yes, I have... There is no problem with your code. You have two
variables with the same name--ParentHandle. CodeView gets confused
and displays the contents of the application's ParentHandle, not the
DLL's. Try using a different variable name.
> Lynn Wallace | I do not represent E&S.
>Evans and Sutherland Computer Corp.| Internet: lwallace@javelin.sim.es.com
> Salt Lake City, UT 84108 | Compu$erve: 70242,101
> Revenge is a dish best not served at all.
----- Adam Rybicki -----
Technical Details
Message-ID:
<1991Apr22.185848.21897@parc.xerox.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!decwrl!parc!rybickiReferences:
<1991Apr22.173022.8930@javelin.sim.es.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!decwrl!parc!rybicki From: rybicki@parc.xerox.com (Adam Rybicki) Newsgroups: comp.windows.ms.programmer Subject: Re: Passing data to a DLL; strange problem! Message-ID: <1991Apr22.185848.21897@parc.xerox.com> Date: 22 Apr 91 18:58:48 GMT References: <1991Apr22.173022.8930@javelin.sim.es.com> Sender: news@parc.xerox.com Organization: Xerox PARC Lines: 54