📄 wpw_w32_task_95.html
字号:
<HTML>
<HR><A NAME=WIN32_task_1_inst>
Return to <a href="wpw_w32_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Ensuring only 1 copy of program running</H4><PRE>
In article <3usji6$fo7@news.midland.co.nz>, raymondg@talktech.co.nz says...
>
>
>I was wondering if anyone could tell me how to only run 1 instance of a
>Windows program. I understand about the hPrevInstance getting passed to the
>new instance but how do I use this to activate the previous instance and make
>sure the new instance isn't started (like what happens when you try to start a
>second instance of clock.exe)?
>
>I am using Windows 3.1 and Borland C++ 4.02 and would appreciate any
>suggestions, especially if anyone knows how to do this using OWL (2.0).
>
>Thanks
>
>Raymond
>
>raymondg@talktech.co.nz
>
>
>
hPrevInst will ALWAYS be 0 under NT. Try this instead:
HWND hWnd = FindWindow( "WindowClass", "WindowTitle" );
if ( hWnd ) {
BringWindowToTop( GetLastActivePopup(hWnd) );
return 0;
}
Cheers, Stefan
--
Stefan H. Holek, <holek@iv.co.at>
</PRE>
<HR><A NAME=WIN32_W95_IPC>
Return to <a href="wpw_w32_index.html#TOC">Table of Contents for this chapter</a><br><I>Supported by </I><a href="ixf.html"><B>Interactive Cross Reference for Windows</A></B><br>
<H4>Subject: Inter-application communication</H4><PRE>
In article <3vd6uq$5ks@news.asiaonline.net>, dion@asiaonline.net (Dion M Wiggins) writes:
|> Hi does anyone know of a good method to communicate between two
|> applications running on the same machine under Windows 95. On NT you can
|> use Named pipes, but Win 95 has a limitation in named pipes in that it
|> will not allow you to create a "Client Side Server", that is you can only
|> connect to a pipe, but can not create a pipe.
|>
|> We can use DDE, but like many people I hate DDe, its a bad implementation
|> in itself.
|>
|> In Win 16, you can send messages to top level windows, which can trigger
|> a real from memory map files or global attoms, but in Win 95, this does
|> not work, as each app has its own ownership, and the messages are never
|> recieved.
|>
|> Presently we have had to resort to sockets (TCP/IP) and point to
|> localserver. This is not a desireable solution as you must assume that
|> the user has TCP/IP installed.
|>
|> Any help appreciated.
|>
|> Reagards
|>
|> Dion wiggins
|>
|> --
Use Anonymous Pipes
This should work, according to Documentation.
I am getting ready to do some of this work myself and this is how I plan
to do this task. Someone out there could verify my plan and let me know
if I hhave it right.
Assume App 1 needs to read and App 2 needs to write.
App 1 creates the pipe using CreatePipe().
App 1 Gets a handle to App 2.
App 1 duplicates the write handle returned from CreatePipe() for App 2
using DuplicateHandle().
App 1 sends App 2 the handle returned from DuplicateHandle using any other
method, Windows message, shared memory, mail box etc.
App 1 closes the write handle returned from CreatePipe().
App 1 can now read from the pipe and App 2 can write the pipe.
</PRE>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -