The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => The Orphanage => Topic started by: shankle on October 24, 2011, 01:07:23 PM

Title: Windows question
Post by: shankle on October 24, 2011, 01:07:23 PM
Looked for examples in Masm32 and Izellion. Couldn't quite find an ex. of what
I need.
Two programs running at the same time with an rsrc file used by both.
Is that an Dynamic Data Exchange or an MDI or something else?
My something else doesn't quite hack it.... :(
Title: Re: Windows question
Post by: ToutEnMasm on October 24, 2011, 01:34:21 PM
At run time,you need to pass the adress of the resource to the prog who haven't a ressource.
This need an exhange of messages between the two prog.
More simple soluce is to write in the same directory ,two progs who share the same resource file .rc.
Each prog have there own resource,but it's the same.
Perfect soluce is to write  a DLL.
Title: Re: Windows question
Post by: dedndave on October 24, 2011, 01:56:24 PM
if you like, you can use the same program to do both   :P

you can use a WM_USER+nnnn message to exchange window handles
or use the command line to pass window handle 1 to window 2, then use WM_COPYDATA to send handle 2 to window 1
after that, use WM_COPYDATA to communicate - at least, i found that to be the simplest way
Title: Re: Windows question
Post by: ToutEnMasm on October 24, 2011, 02:10:43 PM

For the WM_COPYDATA the WM_USER msg is not very secure.The same msg cn exist twice or more.
Msdn prefered to know the class of the receiving window:
Quote
hwDispatch = FindWindow( "Disp32Class", "Hidden Window" );
   if( hwDispatch != NULL )
      SendMessage( hwDispatch,
                   WM_COPYDATA,
                   (WPARAM)(HWND) hWnd,
                   (LPARAM) (LPVOID) &MyCDS );
   else
      MessageBox( hWnd, "Can't send WM_COPYDATA", "MyApp", MB_OK );

http://msdn.microsoft.com/en-us/library/windows/desktop/ms649009(v=vs.85).aspx
Title: Re: Windows question
Post by: jj2007 on October 24, 2011, 02:13:48 PM
Quote from: shankle on October 24, 2011, 01:07:23 PM
... or something else?

It is something else. Resources get stored in the executable, so no interprocess communication required.
You might check So how does one share resources among processes? (http://msdn.microsoft.com/en-us/library/ms810501.aspx) in a well-known MS article, though - interesting reading.
Title: Re: Windows question
Post by: dedndave on October 24, 2011, 03:29:38 PM
nice find, Yves
i am going to play with that method

Jochen - the link you posted brings up "Give Me a Handle, and I'll Show You an Object"
which is nice reading also   :P
i hope ms doesn't get too fancy with the article titles - i want to be able to find stuff
EDIT: ok - about half way down the page, i found what you were talking about   :U

i am also playing with RegisterWindowMessage
the only thing i don't like is that the message stays registered to end of session
i guess it isn't a huge resource hog   :P
it is easy to use - i'll say that much
Title: Re: Windows question
Post by: shankle on October 24, 2011, 10:23:56 PM
Thanks guys,
Working on your suggestions. It will take me awhile.