⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sh.htm

📁 硬件的操作系统语言
💻 HTM
字号:
<BODY>

<CENTER><H3><FONT COLOR="#a0a099">

Making 
Multiple Instances of an Application run in the Same Process 
Space

</FONT></H3></CENTER><HR>

<!-- Author and contact details -->This 
article was contributed by <A href="mailto:ramakrsna@hotmail.com">V. <U><FONT 
color=#0000ff>Rama Krishna</FONT></U>.

<!-- Sample image - gif or jpg --> 
</A>
<P>If you are familiar with Internet Explorer 4.0 you would find that in the 
Advanced Internet Settings there is an option &quot;Browse in a New 
Process&quot;. If you uncheck this check box and run IExplorer.exe and then 
start task manager (or Process Viewer) you would find that there is no IExplorer 
in the processes yet the Internet Explorer appears. Checking &quot;Browse in a 
new process&quot; and starting Internet Explorer runs it as IExplorer.exe again. 
</P>
<P>In the first case instead of a separate process being created for Internet 
Explorer a thread is created in explorer.exe and instances of Internet Explorer 
run in different threads within the process space of explorer.exe. Recently, I 
also found the need to do the same in my application. This article demonstrates 
how this could be achieved.</P>
<P>This is partcularly useful when lots of data need to be shared among 
instances of applications. Typically the first instance of the application loads 
data from the disk file or initializes through other methods and this data needs 
to be more or less constant throughout the application. Memory mapped file is 
obviously an alternative but it requires quite a bit of pointer arithmetic and 
to a lot of extent convenience is lost.This alternative is convinient but has 
certain risks associated like if a single instance of the application crashes 
then all the instances are gone.</P>
<H4>Implementation</H4>
<P>Coming to the implementation, it's quite simple. Any instance of the 
application launched either through explorer or through API calls such as 
CreateProcess, first detects if a window of a particular class exists, if it 
doesnot it creates one. If the window does exists the newly created process 
simple sends a message to the window and transfers the control to the other 
running instance. The already running instance of the application launches a 
separate thread that encapsulates an instance of an application like creating 
the window etc.</P>
<PRE><TT><FONT COLOR="#990000">

[Any source code goes here]

<!-- end the block of source code -->
</FONT></TT></PRE>


<!-- create more blocks of source code as needed -->

<!-- demo project -->
<p><A HREF="[demo project zip file name here]">Download demo project - [size in KB] KB</A>

<!-- Zipped source -->
<p><A HREF="[source code zip file name here]">Download source - [size in KB] KB</A>

<!-- Posted / Update  date Month day, year (eg August 11, 1998) - add to the list -->
<p>Date Posted: August 11, 1998

<!--#include virtual="footer.shtml" --></p></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -