Repository navigation
inproc
Directory actions
More options
Directory actions
More options
inproc
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
<!--TO READ THIS HELP FILE, RIGHT-CLICK ON THE FILE NAME IN THE
SOLUTION EXPLORER PANE AND SELECT "VIEW IN BROWSER"-->
<html><head><title>INPROC Sample: Demonstrates an In-Process Automation Server Application</title></head><body><h1>INPROC Sample: Demonstrates an In-Process Automation Server Application</h1><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()"></div><p /><p>The INPROC sample is an in-process Automation (formerly OLE Automation) server. Unlike the other MFC automation server samples, INPROC can be loaded as a dynamic-link library (DLL) in the client's address space. In-process servers are usually more efficient than servers implemented as separate EXEs because a remote procedure call (RPC) is not necessary to invoke methods on the objects implemented by the server. </p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Security Note </th></tr><tr><td><p>This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.</p></td></tr></table></div><h1 class="heading">Building and Running the Sample</h1><div id="sectionSection0" class="seeAlsoNoToggleSection"><h4 class="subHeading">To build and run the INPROC sample</h4><div class="subSection"><ol><li><p>Open the solution inproc.sln.</p></li><li><p>On the <b>Build</b> menu, click <b>Build</b>.</p></li><li><p>Register INPROC's DLL using the project's .reg file, that is, either run <code>regedit INPROC.REG</code>, or use REGSVR from the REGSVR sample. </p><p>If you use REGEDIT, be sure that Inproc.dll is on the system path. Alternately, you can modify the .reg file to refer to the path of Inproc.dll explicitly. </p><p>A DLL cannot be run stand alone, as an EXE can; therefore, to test INPROC, you must "drive" it from a client application. INPROC can be driven from Visual Basic or from Visual C++. See the IPDRIVE sample for an example of driving INPROC from Visual C++. </p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note </th></tr><tr><td><p>You can build an EXE version or a DLL version of INPROC. Set the EXE variant in the sample's project settings. An EXE version of INPROC only registers itself in the Windows registry.</p></td></tr></table></div></li></ol></div></div><h1 class="heading">INPROC Classes</h1><div id="sectionSection1" class="seeAlsoNoToggleSection"><p>The <b>CVariantMap </b>class implements a <b>VARIANT</b> to <b>VARIANT</b> map. This allows any <b>VARIANT</b> to be mapped to any other <b>VARIANT</b>. Although this is probably not useful to Visual C++ programmers (who would probably use <b>CMap</b> directly), it does bring the power of MFC's collection classes to Visual Basic users. The <b>CVariantMap</b> class is accessed by the name <code>mfc.inproc.varmap</code>. This is how the object is registered in the Windows registry. <b>CVariantMap</b> implements the standard collection methods and properties as well as the <b>_NewEnum</b> method.</p><p>The <b>CStringCollect</b> class implements an array of strings. Its implementation is simpler than the <b>CVariantMap</b> class, even though it implements many of the same automation features as <b>CVariantMap</b>. The <b>CStringCollect</b> object is accessed by the name <code>mfc.inproc.strcoll</code>. It implements most of the standard collection methods and properties and is a good example for how to implement your own collections. Of particular interest is its implementation of the <b>_NewEnum</b> method, which allows Visual Basic users to use the <code>For Each... In</code> syntax when enumerating the contents of a collection. <b>CStringCollect</b> uses <b>CEnumVariant</b> to implement this functionality (it implements <b>IEnumVARIANT</b> using the MFC interface maps). You may find <b>CEnumVariant</b> useful in your own applications.</p><p>Finally, the sample implements a few dummy properties, which are used simply to compare the performance of in-process servers and LocalServer servers. These are the properties tested by IPDRIVE's Test1 and Test2 buttons.</p></div><h1 class="heading">Keywords</h1><div id="sectionSection2" class="seeAlsoNoToggleSection"><p>This sample demonstrates the following keywords:</p><p>AfxIsValidAddress; AfxMessageBox; AfxOleInit; AfxOleLockApp; AfxOleUnlockApp; AfxThrowMemoryException; AfxThrowOleException; CCmdTarget::EnableAutomation; CCmdTarget::GetIDispatch; CCmdTarget::OnFinalRelease; CString::AllocSysString; CWinApp::InitInstance; CWinApp::RunAutomated; CWinApp::RunEmbedded; DllCanUnloadNow; DllGetClassObject; min</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note </th></tr><tr><td><p>Some samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task. </p></td></tr></table></div></div></div><div id="footer"><div class="footerLine"></div>
© Microsoft Corporation. All rights reserved. Send <a href="mailto:DevDocs@microsoft.com?subject=Documentation Feedback :INPROC Sample: Demonstrates an In-Process Automation Server Application">comments</a> about this topic to Microsoft.
</div></div></body></html>