Re: Threads

new topic     » goto parent     » topic index » view thread      » older message » newer message

This is a multi-part message in MIME format.

------=_NextPart_000_0043_01C27036.EBF45B40
	charset="iso-8859-1"


I have found it very easy to trigger application-defined events in =
another window by registering a Windows Message using =
RegisterWindowMessage(). The routine takes a pointer to a =
null-terminated character-string as an argument to identify a unique =
system-wide message. Any other window that then uses that same string in =
a call to RegisterWindowMessage(), recieves the same value as the first =
did, to use as a window message. The message will remain system-wide for =
the duration of the windows session, I believe.

Since the routines in memshare.ew also take character-strings ( or even =
sequences, with limitations ) to identify a block of shared memory =
throughout the system, you can do some interesting things with the two. =
For Example:

Use shared-memory to sm_create() a block of shared memory using a =
file-name, even appending some string onto the file-name for better =
security (like "C:\database\myfile.dbf-Eu-Process"). Then use the shared =
memory to store the window-handle of the process that has access to the =
file, plus any other data you wish.

If another application wants to open the file, it can call sm_create(), =
which will fail if the memory is already allocated using that string =
(file-name). The second application can then sm_open() the block of =
memory, and read the window-handle of the first application, then use a =
unique window message to send a message to the first, requesting access, =
or the others read/write status, or whatever you need to do. You could =
even pass the window-handle of the second application in the unique =
windows message, and when the first application is done, it can =
PostMessage() a "file-released" message to the second.

In the very least it offers a way to flag, across the entire system, =
that a file is open by another application.

Jason


------=_NextPart_000_0043_01C27036.EBF45B40
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have found it very easy to trigger=20
application-defined events in another window by registering a Windows =
Message=20
using RegisterWindowMessage(). The routine takes a pointer to a =
null-terminated=20
character-string as an argument to identify a unique system-wide =
message. Any=20
other window that then uses that same string in a call to=20
RegisterWindowMessage(), recieves the same value as the first did, to =
use as a=20
window message. The message will&nbsp;remain system-wide for the =
duration of the=20
windows session, I believe.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Since the routines in memshare.ew also =
take=20
character-strings ( or even sequences, with limitations&nbsp;) to =
identify a=20
block of shared memory throughout the system, you can do some =
interesting things=20
with the two. For Example:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Use shared-memory to sm_create() a =
block of shared=20
memory using a file-name, even appending some string onto the file-name =
for=20
better security (like "C:\database\myfile.dbf-Eu-Process"). Then use the =
shared=20
memory to store the window-handle of the process that has access to the =
file,=20
plus any other data you wish.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>If another application wants to open =
the file, it=20
can call sm_create(), which will fail if the memory is already allocated =
using=20
that string (file-name). The second application can then sm_open() the =
block of=20
memory, and read the window-handle of the first application,&nbsp;then =
use=20
a&nbsp;unique window message to send a message to the first, requesting =
access,=20
or the others read/write status, or whatever you need to do. You could =
even pass=20
the window-handle of the second application&nbsp;in the unique windows =
message,=20
and when the first application is done, it can PostMessage() a =
"file-released"=20
message to the second.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>In the very least it offers a way to =
flag, across=20
the entire system, that a file is open by another =
application.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Jason</FONT></DIV>

------=_NextPart_000_0043_01C27036.EBF45B40--

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu