<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="http://rss.egloos.com/style/blog.xsl" type="text/xsl" media="screen"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
	<title>지향점은 All Round Game Dever</title>
	<link>http://studior.egloos.com</link>
	<description># Start 070903 + ...ReStart 080901 #
--- 풋내기 게임 개발자의 발자취... ---
할말은 아래 방명록에...</description>
	<language>ko</language>
	<pubDate>Sun, 22 Nov 2009 15:29:51 GMT</pubDate>
	<generator>Egloos</generator>
	<image>
		<title>지향점은 All Round Game Dever</title>
		<url>http://pds7.egloos.com/logo/200804/17/79/f0030079.jpg</url>
		<link>http://studior.egloos.com</link>
		<width>80</width>
		<height>81</height>
		<description># Start 070903 + ...ReStart 080901 #
--- 풋내기 게임 개발자의 발자취... ---
할말은 아래 방명록에...</description>
	</image>
  	<item>
		<title><![CDATA[ [ProgramInLife]99단 ]]> </title>
		<link>http://studior.egloos.com/1577473</link>
		<guid>http://studior.egloos.com/1577473</guid>
		<description>
			<![CDATA[ 
  어릴적 외웠던 99단의 쓰임새가...<div>TMP(Template Meta Programming) 와 유사하다는 것을 알았다.</div><div><br />
</div><div>계산과정을 생략함으로서 속도를 향상시킨다는 원리와</div><div>인덱싱을 사용한 접근편이성의 향상이 공통된 매력이리라.</div><div><br />
</div><div>...</div><div>"진짜 프로그래머" 로 가는길은 험하고 멀다.</div>			 ]]> 
		</description>
		<category>toRoad™ :: Life</category>

		<comments>http://studior.egloos.com/1577473#comments</comments>
		<pubDate>Sun, 22 Nov 2009 15:29:51 GMT</pubDate>
		<dc:creator>toRoad™</dc:creator>
	</item>
	<item>
		<title><![CDATA[ [Variable] COM & ATL by Silan Liu #1 ]]> </title>
		<link>http://studior.egloos.com/1562071</link>
		<guid>http://studior.egloos.com/1562071</guid>
		<description>
			<![CDATA[ 
  출처 -&gt;&nbsp;<a href="http://progtutorials.tripod.com/COM.htm"><b>http://progtutorials.tripod.com/COM.htm</b></a><br />
<br />
<span class="Apple-style-span" style="font-family: Gulim; line-height: normal; font-size: medium; "><p class="MsoTitle" align="left" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; text-align: left; font-size: 10pt; font-family: Arial; font-weight: bold; "><a name="_Toc43522767"><span><span style="font-size: 18pt; ">COM &amp; ATL</span></span></a></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; "><span><b><span lang="FR">Silan Liu<o:p></o:p></span></b></span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; "><span><o:p>&nbsp;</o:p></span></p><h1 style="margin-top: 24pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 18pt; text-indent: -18pt; page-break-after: avoid; font-size: 12pt; font-family: Arial; font-variant: small-caps; color: maroon; "><span><a name="_Toc43522133"></a><a name="_Ref43522764"></a><a name="_Ref43522765"></a><a name="_Ref43522766"></a><a name="_Toc43522768"><span><span><span><span><span><span>1.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>COM Basics</span></span></span></span></a></span></h1><span></span><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><a name="_Toc43522134"></a><a name="_Toc43522769"><span><span><span>1.1.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>Service Control Manager (SCM)</span></a></h2><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">A Windows program called Service Control Manager (SCM) does most of the job in COM server invoking. It finds the server through System Registry, runs it, has it create the COM object, sets up local/remote transparency, and returns an interface pointer to the client.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">Then the client can directly invoke methods of the COM object through the pointer, and there is no middleware involved unless it is a remote server, in which case only RPC is involved.</p><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><a name="_Toc43522135"></a><a name="_Toc43522770"><span><span><span>1.2.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>Interface IUnknown</span></a></h2><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">All COM interfaces should inherit interface&nbsp;<b>IUnknown</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">interface&nbsp;<b><span style="color: red; ">IUnknown</span></b></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">{</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><span></span>HRESULT QueryInterface(REFIID iid, void** ppvObject);</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><span></span>ULONG AddRef();</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><span></span>ULONG Release();</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">}</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">One COM object may be used by multiple clients. The COM server maintains a reference count for each interface of the object. When one client asks to create an instance of the interface with<b>CoCreateInstance</b>&nbsp;or&nbsp;<b>CoCreateInstanceEx</b>, the COM server will call that interface’s method&nbsp;<b>AddRef</b>&nbsp;to increment the reference count.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">When one client is finished with an interface, it should call its&nbsp;<b>Release</b>&nbsp;method to decrement the reference count. When the count reaches zero, the COM server should destroy the COM object.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">In Visual Basic, a local COM object is automatically destroyed when leaving scope. To manually delete an object, say</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><a name="_Toc43522771"><span lang="EN-AU">Set objAccount =&nbsp;<b><span style="color: red; ">Nothing</span></b></span></a></p><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><a name="_Toc43522136"></a><a name="_Toc43522772"><span><span><span>1.3.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>Global Unique ID (GUID)</span></a></h2><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">Each coclass and interface has its guid, which is a 128-bit number. For easy use by the programmer, an easy-remember manifest constant is defined for each guid. In Visual C++ these constants are defined in a header file e.g. “Bank_i.c”, and some entries look like:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">const IID&nbsp;<b><span style="color: red; ">IID_IGreet</span></b>&nbsp;= {0x7A5E6E81,0x3DF8,0x11D3,{0x90,0x3D,0x00,0x10,0x5A,0xA4,0x5B,0xDC}};</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">const IID&nbsp;<b><span style="color: red; ">LIBID_BANKLib</span></b>&nbsp;= {0x0FFBDAA1,0xFCA7,0x11D2,{0x8F,0xF4,0x00,0x10,0x5A,0xA4,0x5B,0xDC}};</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">const CLSID&nbsp;<b><span style="color: red; ">CLSID_Account</span></b>&nbsp;= {0x0FFBDAAE,0xFCA7,0x11D2,{0x8F,0xF4,0x00,0x10,0x5A,0xA4,0x5B,0xDC}};</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">GUID constants such as IID_IGreet and CLSID_Account are not globally unique, but it does not matter because they live only in the scope of one application program. The compiler will read the interface definition file to convert the constant to the corresponding guid.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">GUIDs for classes are of type&nbsp;<b>CLSID</b>, and all variables start with “CLSID_” followed by the class name, such as “CLSID_Account”. GUIDs for interfaces are of type&nbsp;<b>IID</b>,<span>&nbsp;&nbsp;</span>and all start with “IID_” followed by the interface name such as “IID_IAccount”.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">To convert between CLSID and unicode array:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CLSID clsid;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">...</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">WCHAR * ostr;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HRESULT hr =&nbsp;<b><span style="color: red; ">StringFromCLSID</span></b>(clsid, &amp;ostr);</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">Program “Microsoft Visual Studio\Common\Tools\<b>Guidgen.exe</b>” is used to generate a guid. Choose the format of the guid and press button “Copy”. The generated guid will be in the clipboard.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">You can also add it to the “Tools” menu with menu “Tools | Customize | Tools”.</p><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><a name="_Toc43522137"></a><a name="_Toc43522773"><span><span><span>1.4.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>OLE/COM Object Viewer</span></a></h2><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">OLE/COM Object Viewer goes through System Registry and collects all info about each coclass and their interfaces, and put them under one entry as their “user names”, which is the help string in the IDL file. You can find this entry under “All Objects” entry.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">The “user name” entry stores the info about the coclass itself. Under it there are entries for all the interfaces of this class. Each entry stores the info about a specific interface.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">OLD/COM Object Viewer can be started both from the “Start” menu and from Visual C++ menu “Tools”.</p><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><a name="_Toc43522138"></a><a name="_Toc43522774"><span><span><span>1.5.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>System Registry</span></a></h2><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">System Registry contains information about the computer. Under its “<b>HKEY_CLASSES_ROOT</b>” entry, all information about a coclass is stored. Under this entry, all coclasses are listed by their&nbsp;<b>ProgID</b>s. Among the countless ProgID entries, there are two other entries: one named&nbsp;<b>CLSID</b>, under which all coclasses are listed by their guids; the other named&nbsp;<b>Interface</b>, under which all interfaces are listed by their guids.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; "><b>ProgIDs</b>&nbsp;are not guaranteed to be unique. They are used by some languages that can not directly refer to guids such as VBScript. VB can directly refer to guids, and can also optionally use ProgIDs. COM library provides to functions which can go through the System Registry and convert a ProgID to a CLSID or vice versa:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CLSID clsid;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><b><span lang="EN-AU" style="color: red; ">CLSIDFromProgID</span></b><span lang="EN-AU">(L"Cars.Jeep.1", &amp;clsid);</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">LPOLESTR progid;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><b><span lang="EN-AU" style="color: red; ">ProgIDFromCLSID</span></b><span lang="EN-AU">(clsid, &amp;progid);</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">We also need an entry to store some attributes about the whole server. For each server we can assign an&nbsp;<b>AppID</b>, under which we store all those atttributes such as&nbsp;<b>AccessPermission</b>,<b>AuthenticationLevel</b>,&nbsp;<b>DllSurogate</b>,&nbsp;<b>LunchPermissions</b>,&nbsp;<b>RemoteServerName</b>, etc. Then under each coclass entry under HKCR\CLSID, we add an AppID entry containing the AppID of the server.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">When a coclass in invoked, the SCM reads the CLSID entry under HKCR\CLSID. If it finds an AppID entry, it will go further to find the AppID entry under HKCR\AppID. There it reads more about the server and knows how to deal with the server. For example, if SCM finds&nbsp;<b>RemoteServerName</b>&nbsp;entry there containing the name of another computer, it knows that the server is located oin another computer and it should contact the SCM of that computer.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">When you call COM library functions such as&nbsp;<b>CoCreateInstance</b>&nbsp;passing a guid constant such as "CLSID_CoCar" or "IID_IRegistration", the compiler converts the guid contstant to the real guid by looking up the guid definition file&nbsp;<b>*_i.c</b>. At run time the real guid is sent to the API function.</p><h3 style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; text-indent: -14.2pt; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: navy; "><span style="font-family: Symbol; color: windowtext; font-weight: normal; "><span>¨<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>DLL server's entries in System Registry</h3><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">A DLL server should have the following basic entries in the System Registry:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\<b><span style="color: red; ">&lt;ProgID&gt;</span></b>\CLSID = &lt;clsid&gt;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\CLSID\<b><span style="color: red; ">&lt;clsid&gt;</span></b>&nbsp;= &lt;ProgID&gt;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\CLSID\&lt;clsid&gt;\<b><span style="color: red; ">InprocServer32</span></b>&nbsp;= &lt;server full path&gt;</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">You do not have to register your type library, for VC can directly #import from any directory, and VB and J++ can browse to find a *.tlb file. However, if you want to do it, you should add the following type library entries:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\CLSID\&lt;clsid&gt;\TypeLib = &lt;libid&gt;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\TypeLib\&lt;libid&gt; = &lt;type library help string&gt;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\TypeLib\&lt;libid&gt;\1.0\0\Win32 = &lt;type library full path&gt;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\TypeLib\&lt;libid&gt;\1.0\FLAGS = 0</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\TypeLib\&lt;libid&gt;\1.0\HELPDIR</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">When client calls&nbsp;<b>CoCreateInstance</b>&nbsp;with a CLSID and a IID, the COM run time will:</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 42.55pt; font-size: 10pt; font-family: Arial; text-indent: -21.25pt; "><span><span>1.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>go to the&nbsp;<b>HKCR\CLSID\&lt;guid&gt;\InProcServer32</b>&nbsp;entry to find the location of the DLL server.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 42.55pt; font-size: 10pt; font-family: Arial; text-indent: -21.25pt; "><span><span>2.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>load the DLL into process, call its exported&nbsp;<b>DllGetClassObject</b>&nbsp;function passing the coclass guid to get an&nbsp;<b>IClassFactory</b>&nbsp;pointer of the corresponding class factory;</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 42.55pt; font-size: 10pt; font-family: Arial; text-indent: -21.25pt; "><span><span>3.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>call the&nbsp;<b>IClassFactory</b>'s&nbsp;<b>CreateInstance</b>&nbsp;method passing the IID of the interface to get a pointer of the interface.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">You can see in the above process that the guids of the interfaces are only used inside the class factory. There is no need to store an entry for an interface in the System Registry.</p><h3 style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; text-indent: -14.2pt; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: navy; "><span style="font-family: Symbol; color: windowtext; font-weight: normal; "><span>¨<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>EXE server's entries in System Registry</h3><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">A EXE server should have similar basic entries as a DLL server except it is&nbsp;<b>LocalServer32</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\<b><span style="color: red; ">&lt;ProgID&gt;</span></b>\CLSID = &lt;clsid&gt;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\CLSID\<b><span style="color: red; ">&lt;clsid&gt;</span></b>&nbsp;= &lt;ProgID&gt;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\CLSID\&lt;clsid&gt;\<b><span style="color: red; ">LocalServer32</span></b>&nbsp;= &lt;server full path&gt;</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">Besides these, it should have the following entries for each interface:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\Interface\&lt;iid&gt;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\Interface\ProxyStubClsid = &lt;proxy/stub dll clsid&gt;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\Interface\ProxyStubClsid32 = &lt;proxy/stub dll clsid&gt;</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">If you use universal marshaller&nbsp;<b>oleaut32.dll</b>, which reads the registered type library and creates proxy/stub classes on the fly, you should put the CLSID of&nbsp;<b>oleaut32.dll</b>&nbsp;under&nbsp;<b>ProxyStubClsid32</b>, add the following interface entry, plus all the type library entries:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">HKEY_CLASSES_ROOT\Interface\TypeLib = &lt;type library libid&gt;</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">For each interface you invoke, one proxy/stub object is instantiated. Therefore, you must set up a correspondence between an interface and its proxy/stub DLL server, so that when client invoke an interface, the SCM can find the corresponding proxy/stub DLL and create the corresponding proxy/stub object from it.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">For this purpose, the System Registry stores the guids of the all interfaces of an EXE server under entry&nbsp;<b>HKCR\Interface</b>. Under each interface guid entry there is a&nbsp;<b>ProxyStubClsid32</b>&nbsp;entry, which stores the&nbsp;<b>CLSID</b>&nbsp;of the custom proxy/stub DLL server which contains the proxy/stub coclass for that interface, or the universal marshaller&nbsp;<b>oleaut32.dll</b>.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">Therefore, if you use the type library marshalling, you must register the type library under&nbsp;<b>HKCR\TypeLib</b>&nbsp;entry and each interface entry.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">System Registry editor can be started at command line by typing “regedit”, or from OLE/COM Object Viewer in Visual C++.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; "><o:p>&nbsp;</o:p></p><h1 style="margin-top: 24pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 17.85pt; text-indent: -17.85pt; page-break-after: avoid; font-size: 12pt; font-family: Arial; font-variant: small-caps; color: maroon; "><a name="_Toc43522139"></a><a name="_Toc43522775"><span><span><span>2.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>Unicode Handling</span></a></h1><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><a name="_Toc43522140"></a><a name="_Toc534441136"></a><a name="_Toc43522776"><span><span><span><span>2.1.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>Definitions of Different Type of Strings</span></span></a></h2><h3 style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; text-indent: -14.2pt; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: navy; "><span style="font-family: Symbol; color: windowtext; font-weight: normal; "><span>¨<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>wchar_t</h3><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">In C++ wchar_t is 16-bit wide character represented by&nbsp;<b>unsigned short</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">typedef wchar_t WCHAR;<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>// wc,<span>&nbsp;</span>16-bit UNICODE character</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">typedef unsigned short wchar_t;</span></p><h3 style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; text-indent: -14.2pt; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: navy; "><span style="font-family: Symbol; color: windowtext; font-weight: normal; "><span>¨<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>LPOLESTR</h3><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">In C++ LPOLESTR is a 16-bit unicode string represented by const&nbsp;<b>unsigned short *</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">typedef OLECHAR __RPC_FAR * LPOLESTR;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">typedef WCHAR OLECHAR;</span></p><h3 style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; text-indent: -14.2pt; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: navy; "><span style="font-family: Symbol; color: windowtext; font-weight: normal; "><span>¨<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>LPCOLESTR</h3><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">In C++ LPOLESTR is a constant 16-bit unicode string represented by&nbsp;<b>const</b>&nbsp;<b>unsigned short *</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">typedef const OLECHAR __RPC_FAR *LPCOLESTR;</span></p><h3 style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; text-indent: -14.2pt; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: navy; "><span style="font-family: Symbol; color: windowtext; font-weight: normal; "><span>¨<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>LPSTR</h3><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">In C++ LPSTR is 8-bit multi-byte/ANSI string represented by<b>&nbsp;char *</b></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">typedef CHAR *LPSTR, *PSTR;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">typedef char CHAR;</span></p><h3 style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; text-indent: -14.2pt; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: navy; "><span style="font-family: Symbol; color: windowtext; font-weight: normal; "><span>¨<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>LPCSTR</h3><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">In C++ LPCSTR is 8-bit multi-byte/ANSI string represented by<b>&nbsp;const char *</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">typedef CONST CHAR *LPCSTR, *PCSTR;</span></p><h3 style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; text-indent: -14.2pt; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: navy; "><span style="font-family: Symbol; color: windowtext; font-weight: normal; "><span>¨<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>TCHAR</h3><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">In C++ TCHAR is 8-bit character represented by<b>&nbsp;char</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">typedef char TCHAR, *PTCHAR;</span></p><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><a name="_Toc534441137"></a><a name="_Toc430074"></a><a name="_Toc43522141"></a><a name="_Toc43522777"><span><span><span><span><span>2.2.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>CString &lt;=&gt; Multibyte String</span></span></span></a><span><span></span></span></h2><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU">#define m(x) ::MessageBox(NULL, x, "Test", MB_OK | MB_TOPMOST)</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>CString cstr("Hello the world");</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU" style="color: maroon; "><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>// CString::GetBuffer returns a pointer to its underlying buffer.<o:p></o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>LPSTR lpsz = cstr.GetBuffer(cstr.GetLength());</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU" style="color: maroon; "><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>// Both lpsz and cstr can access the underlying buffer.<o:p></o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>m(lpsz);</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>m(cstr);</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU" style="color: maroon; "><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>// You can amend the buffer through cstr.<o:p></o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>cstr = "Hi Frank.";</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>m(lpsz);</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU" style="color: maroon; "><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>// You can also amend the buffer through lpsz, but you can't free it.<o:p></o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>lpsz[8] = '!';</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>m(cstr);</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>// free(lpsz);&nbsp;<span style="color: maroon; ">// Not allowed! Will cause run-time error!</span></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU" style="color: maroon; "><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>// After releasing the buffer, lpsz's content becomes undefined<o:p></o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>cstr.ReleaseBuffer();</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>m(cstr);</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU" style="color: maroon; "><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>// If you want to avoid amending the original content of the CString,<o:p></o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU" style="color: maroon; "><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>// make a copy.<o:p></o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>LPSTR lpszCopy = (LPSTR)malloc(strlen(lpsz));</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>memset(lpszCopy, 0, strlen(lpsz) + 1);</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;</span><span>&nbsp;</span>strcpy(lpszCopy, lpsz);</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>m(lpszCopy);</span></span></span></p><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><span><span><a name="_Toc43522142"></a><a name="_Toc43522778"><span><span><span>2.3.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>CString &lt;=&gt; Wide Character String</span></a></span></span></h2><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU">void CICPLoginDlg::CStringToWideChar(CString cstr, wchar_t * pwchar, int size)</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU">{</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>int cstrLen = cstr.GetLength();</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>ASSERT(cstrLen &lt; MAX_LENGTH);</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><b><span style="color: red; ">MultiByteToWideChar</span></b>(CP_ACP, MB_PRECOMPOSED, cstr.GetBuffer(cstrLen),</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>cstrLen, pwchar, size);</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU"><span></span>cstr.ReleaseBuffer();</span></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span><span lang="EN-AU">}</span></span></span></p><span></span><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><span><a name="_Toc43522143"></a><a name="_Toc43522779"><span><span><span>2.4.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>Allocating and Freeing BSTRs with API Functions</span></a></span></h2><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">BSTR stands for basic string. It is a 16-bit Unicode with a prefix telling the count of the bytes in this string, therefore do not need NULL at the end.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">When a server creates and passes out a BSTR, the server allocates memory space for the BSTR, while the client should deallocate the memory with a call to API function&nbsp;<b>SysFreeString</b>.</p><h3 style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; text-indent: -14.2pt; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: navy; "><span style="font-family: Symbol; color: windowtext; font-weight: normal; "><span>¨<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>Creating a new BSTR</h3><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">BSTR bstr1 =&nbsp;<b><span style="color: red; ">SysAllocString</span></b>(<b><span style="color: red; ">L</span></b>"Hello world!");</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><b><span lang="EN-AU" style="color: red; ">OLECHAR</span></b><span lang="EN-AU">&nbsp;* pOleStr = OLESTR("Good morning!");</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">BSTR bstr2 =&nbsp;<b><span style="color: red; ">SysAllocString</span></b>(pOleStr);</span></p><h3 style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; text-indent: -14.2pt; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: navy; "><span style="font-family: Symbol; color: windowtext; font-weight: normal; "><span>¨<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>Modifying a BSTR</h3><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><b><span lang="EN-AU" style="color: red; ">SysReAllocString</span></b><span lang="EN-AU">(&amp;bstr1,&nbsp;<b><span style="color: red; ">L</span></b>"Good morning!");</span></p><h3 style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; text-indent: -14.2pt; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: navy; "><span style="font-family: Symbol; color: windowtext; font-weight: normal; "><span>¨<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>Freeing a BSTR</h3><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><b><span lang="EN-AU" style="color: red; ">SysFreeString</span></b><span lang="EN-AU">(bstr1);</span></p><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><a name="_Toc43522144"></a><a name="_Toc534441138"></a><a name="_Toc43522780"><span><span><span><span>2.5.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>BSTR &lt;=&gt; CString</span></span></a></h2><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CString cstr(“Hello!”);</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">BSTR bstr = cstr.<b><span style="color: red; ">AllocSysString</span></b>();</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">BSTR bstr = SysAllocString(L"Hello Frank!");</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CString cstr(bstr);</span></p><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><a name="_Toc43522145"></a><a name="_Toc534441139"></a><a name="_Toc43522781"><span><span><span><span>2.6.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>BSTR &lt;=&gt; Multibyte String</span></span></a></h2><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">Second, use function&nbsp;<b>wcstombs</b>&nbsp;(wide character string to multibyte string) and&nbsp;<b>mbstowcs</b>&nbsp;(multibyte string to wide character string):</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">BSTR bstr1 = SysAllocString(L"Hellow world!");</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">char * buf[80];</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><b><span lang="EN-AU" style="color: red; ">wcstombs</span></b><span lang="EN-AU">(buf, bstr1, 80);</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">SysFreeString(bstr1);</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">sprintf(buf, "Good morning!");</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">BSTR bstr2;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><b><span lang="EN-AU" style="color: red; ">mbstowcs</span></b><span lang="EN-AU">(bstr2, buf, 80);</span></p><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><a name="_Toc534441140"></a><a name="_Toc43522146"></a><a name="_Toc43522782"><span><span><span><span>2.7.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>Multibyte String &lt;=&gt; Wide Character String</span></span></a><span></span></h2><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU">char * mbstr = "Hello world!";</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU">int len1 =&nbsp;<b><span style="color: red; ">strlen</span></b>(mbstr);</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU">wchar_t wcbuf[80];</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU">int len2 =&nbsp;<b><span style="color: red; ">sizeof</span></b>(wcbuf) /&nbsp;<b><span style="color: red; ">sizeof</span></b>(wchar_t);</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><b><span lang="EN-AU" style="color: red; ">::memset</span></b><span lang="EN-AU">(wcbuf, 0, sizeof(wcbuf));</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><a name="_Toc43522783"><b><span lang="EN-AU" style="color: red; ">MultiByteToWideChar</span></b><span lang="EN-AU">(</span></a></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>CP_ACP,</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>MB_PRECOMPOSED,</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>mbstr,</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>len1,</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>wcbuf,</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>len2);</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU">char buf[300];</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU">sprintf(buf, "wcbuf = %S", wcbuf);</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU">::MessageBox(NULL, buf, NULL, MB_OK);</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU">wchar_t * wcstr = L"Hello world!";</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU">int len3 =&nbsp;<b><span style="color: red; ">wcslen</span></b>(wcstr);</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU">char mbbuf[300];</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU">int len4 =&nbsp;<b><span style="color: red; ">sizeof</span></b>(mbbuf);</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><b><span lang="EN-AU" style="color: red; ">::memset</span></b><span lang="EN-AU">(mbbuf, 0, len4);</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><a name="_Toc43522784"><b><span lang="EN-AU" style="color: red; ">WideCharToMultiByte</span></b><span lang="EN-AU">(</span></a></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>CP_ACP,</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;</span><span>&nbsp;&nbsp;</span>WC_COMPOSITECHECK,</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>wcstr,</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>len3,</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>mbbuf,</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>len4,</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>NULL,</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>NULL);</span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU"><o:p>&nbsp;</o:p></span></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span><span lang="EN-AU">::MessageBox(NULL, mbbuf, NULL, MB_OK);</span></span></p><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><span><a name="_Toc43522147"></a><a name="_Toc43522785"><span><span><span>2.8.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>Converting with ATL Macros</span></a></span></h2><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">ATL provides a group of macros to convert between different types. Because one convertion involves a series of temporary variables to hold and swap the string buffers, the space is prepared by macro<b>USES_CONVERSION</b>, which should be called before any conversion. They are defined in&nbsp;<b>&lt;atlconv.h&gt;</b>.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; "><o:p>&nbsp;</o:p></p><table class="MsoNormalTable" border="1" cellspacing="0" cellpadding="0" style="margin-left: 33.75pt; border-collapse: collapse; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; "><tbody><tr><td width="164" valign="top" style="width: 123.2pt; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: windowtext; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; "><b>ANSI to ...<o:p></o:p></b></p></td><td width="164" valign="top" style="width: 123.2pt; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: windowtext; border-right-color: windowtext; border-bottom-color: windowtext; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-style: none; border-left-width: initial; border-left-color: initial; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; "><b>OLE to ...<o:p></o:p></b></p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: windowtext; border-right-color: windowtext; border-bottom-color: windowtext; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-style: none; border-left-width: initial; border-left-color: initial; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; "><b>TCHAR to ...<o:p></o:p></b></p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: windowtext; border-right-color: windowtext; border-bottom-color: windowtext; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-style: none; border-left-width: initial; border-left-color: initial; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; "><b>wchar_t to ...<o:p></o:p></b></p></td></tr><tr><td width="164" valign="top" style="width: 123.2pt; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-top-style: none; border-top-width: initial; border-top-color: initial; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">A2BSTR</p></td><td width="164" valign="top" style="width: 123.2pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">OLE2A</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">T2A</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">W2A</p></td></tr><tr><td width="164" valign="top" style="width: 123.2pt; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-top-style: none; border-top-width: initial; border-top-color: initial; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">A2COLE</p></td><td width="164" valign="top" style="width: 123.2pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">OLE2BSTR</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">T2BSTR</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">W2BSTR</p></td></tr><tr><td width="164" valign="top" style="width: 123.2pt; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-top-style: none; border-top-width: initial; border-top-color: initial; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">A2CT</p></td><td width="164" valign="top" style="width: 123.2pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">OLE2CA</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">T2CA</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">W2CA</p></td></tr><tr><td width="164" valign="top" style="width: 123.2pt; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-top-style: none; border-top-width: initial; border-top-color: initial; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">A2CW</p></td><td width="164" valign="top" style="width: 123.2pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">OLE2CT</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">T2COLE</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">W2COLE</p></td></tr><tr><td width="164" valign="top" style="width: 123.2pt; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-top-style: none; border-top-width: initial; border-top-color: initial; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">A2OLE</p></td><td width="164" valign="top" style="width: 123.2pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">OLE2CW</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">T2CW</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">W2CT</p></td></tr><tr><td width="164" valign="top" style="width: 123.2pt; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-top-style: none; border-top-width: initial; border-top-color: initial; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">A2T</p></td><td width="164" valign="top" style="width: 123.2pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">OLE2T</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">T2OLE</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">W2OLE</p></td></tr><tr><td width="164" valign="top" style="width: 123.2pt; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-top-style: none; border-top-width: initial; border-top-color: initial; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">A2W</p></td><td width="164" valign="top" style="width: 123.2pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">OLE2W</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">T2W</p></td><td width="164" valign="top" style="width: 123.15pt; border-top-style: none; border-top-width: initial; border-top-color: initial; border-left-style: none; border-left-width: initial; border-left-color: initial; border-bottom-style: solid; border-bottom-color: windowtext; border-bottom-width: 1pt; border-right-style: solid; border-right-color: windowtext; border-right-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; "><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 10pt; font-family: Arial; ">W2T</p></td></tr></tbody></table><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><a name="_Toc43522786"><span lang="EN-AU">USES_CONVERSION;</span></a></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">MessageBox(NULL,&nbsp;<b><span style="color: red; ">W2A</span></b>(bstr), NULL, MB_OK);</span></p><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><a name="_Toc43522148"></a><a name="_Toc534441141"></a><a name="_Toc43522787"><span><span><span><span>2.9.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>MFC's BSTR Helper Class _bstr_t</span></span></a></h2><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">MFC provides class&nbsp;<b>_bstr_t</b>&nbsp;to wrap BSTR.<b>&nbsp;_bstr_t</b>'s constructor can take many types as input:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">_bstr_t( ) throw( );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">_bstr_t( const<b><span style="color: red; ">&nbsp;_bstr_t &amp;</span></b>&nbsp;s1 ) throw( );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">_bstr_t( const<b><span style="color: red; ">&nbsp;char *</span></b>&nbsp;s2 ) throw( _com_error );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">_bstr_t( const<b><span style="color: red; ">&nbsp;wchar_t *</span></b>&nbsp;s3 ) throw( _com_error );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">_bstr_t( const<b><span style="color: red; ">&nbsp;_variant_t &amp;</span></b>&nbsp;var ) throw ( _com_error );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">_bstr_t(&nbsp;<b><span style="color: red; ">BSTR</span></b>&nbsp;bstr,&nbsp;<b><span style="color: red; ">bool</span></b>&nbsp;fCopy ) throw ( _com_error );</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">Its assignment operator = is also overloaded for many types:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">_bstr_t&amp; operator=( const _<b><span style="color: red; ">bstr_t &amp;</span></b>&nbsp;s1 ) throw ( );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">_bstr_t&amp; operator=( const&nbsp;<b><span style="color: red; ">char *</span></b>&nbsp;s2 ) throw( _com_error );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">_bstr_t&amp; operator=( const&nbsp;<b><span style="color: red; ">wchar_t *</span></b>&nbsp;s3 ) throw( _com_error );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">_bstr_t&amp; operator=( const&nbsp;<b><span style="color: red; ">_variant_t &amp;</span></b>&nbsp;var ) throw( _com_error );</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">It has also overloaded +=, +, ! and all comparison operators.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">To get a&nbsp;<b>LPTSTR</b>&nbsp;from<b>&nbsp;_bstr_t</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><span>&nbsp;&nbsp;</span>_bstr_t bstrt("Hello!");</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><span>&nbsp;&nbsp;</span>LPTSTR lp1 =&nbsp;<b><span style="color: red; ">(LPTSTR)</span></b>bstrt;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><span>&nbsp;&nbsp;</span>LPTSTR lp2 = bstrt.<b><span style="color: red; ">operator char *()</span></b>;</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">You can use&nbsp;<b>_bstr_t</b>&nbsp;anywhere expecting BSTR. If you like, you can also explicitly cast&nbsp;<b>_bstr_t</b>&nbsp;to&nbsp;<b>BSTR</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">_bstr_t bstrt("Hello!");</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">BSTR bstr =&nbsp;<b><span style="color: red; ">(BSTR)</span></b>bstrt;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">SysFreeString(bstr1);</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; "><b>_bstr_t</b>&nbsp;object does not need to be deallocated. It is deallocated automatically when it leaves scope.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">Class&nbsp;<b>_bstr_t</b>&nbsp;is contained in header file &lt;<b>comdef.h</b>&gt;.</p><h2 style="margin-top: 12pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; text-indent: -1cm; page-break-after: avoid; font-size: 10pt; font-family: Arial; color: blue; font-style: italic; "><a name="_Toc43522149"></a><a name="_Toc534441142"></a><a name="_Toc43522788"><span><span><span><span>2.10.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span>ATL's BSTR Helper Class CComBSTR</span></span></a></h2><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">ATL also provides a wrapper class<b>&nbsp;CComBSTR</b>, which is more light than&nbsp;<b>_bstr_t</b>. CComBSTR wraps a BSTR data member&nbsp;<b>m_str</b>. Space for&nbsp;<b>BSTR</b>&nbsp;is allocated in its constructor and deallocated in the destructor.</p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">Its constructor can take&nbsp;<b>LPCOLESTR</b>&nbsp;or&nbsp;<b>LPCSTR</b>&nbsp;as input. It can also designate the size of the buffer.</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CComBSTR( int nSize );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CComBSTR( int nSize,&nbsp;<b><span style="color: red; ">LPCOLESTR</span></b>&nbsp;sz );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CComBSTR( int nSize,&nbsp;<b><span style="color: red; ">LPCSTR</span></b>&nbsp;sz );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CComBSTR(&nbsp;<b><span style="color: red; ">LPCOLESTR</span></b>&nbsp;pSrc );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CComBSTR(&nbsp;<b><span style="color: red; ">LPCSTR</span></b>&nbsp;pSrc );</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CComBSTR( const CComBSTR&amp; src );</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">Therefore you can say:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><b><span lang="EN-AU" style="color: red; "><o:p>&nbsp;</o:p></span></b></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CComBSTR comBstr(“Hello!”);</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">To detach&nbsp;<b>m_str</b>&nbsp;from&nbsp;<b>CComBSTR</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">BSTR bstr = comBstr.<b><span style="color: red; ">Detach</span></b>();</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">To attach a&nbsp;<b>BSTR</b>&nbsp;to a&nbsp;<b>CComBSTR</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">BSTR bstr = SysAllocString(L"Hello!");</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CComBSTR comBstr;</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">comBstr.<b><span style="color: red; ">Attach</span></b>(bstr);</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">To get a copy of&nbsp;<b>m_str</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">BSTR bstr = comBstr.<b><span style="color: red; ">Copy</span></b>();</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">To get the address of&nbsp;<b>m_str</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">BSTR * pBstr = &amp;comBstr.</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">To free&nbsp;<b>m_str</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">comBstr.<b><span style="color: red; ">Empty</span></b>();</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; ">The overloaded assignment operator takes&nbsp;<b>LPCOLESTR</b>&nbsp;or&nbsp;<b>LPCSTR</b>&nbsp;as parameter. Therefore, to change the value of&nbsp;<b>CComBSTR</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">CComBSTR comBstr();</span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">comBstr = L"Good morning!";</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; "><b>CComBSTR</b>&nbsp;can only be casted to CString, which can be than casted to&nbsp;<b>LPCSTR</b>&nbsp;or&nbsp;<b>LPCTSTR</b>:</p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU"><o:p>&nbsp;</o:p></span></p><p class="Program" style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 1cm; font-size: 10pt; font-family: 'Courier New'; "><span lang="EN-AU">cstr = (CString)comBstr;</span></p><p class="MsoNormal" style="margin-top: 6pt; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 21.3pt; font-size: 10pt; font-family: Arial; "><b>CComBSTR</b>&nbsp;is contained in header file &lt;<b>atlbase.h</b>&gt;, which also contains other wrapper classes.</p></span>			 ]]> 
		</description>
		<category>┗▷▶▷ Pragma</category>

		<comments>http://studior.egloos.com/1562071#comments</comments>
		<pubDate>Tue, 03 Nov 2009 01:05:44 GMT</pubDate>
		<dc:creator>toRoad™</dc:creator>
	</item>
	<item>
		<title><![CDATA[ [Mind] 세상 ]]> </title>
		<link>http://studior.egloos.com/1558631</link>
		<guid>http://studior.egloos.com/1558631</guid>
		<description>
			<![CDATA[ 
  <div style="text-align: center;"><b><font class="Apple-style-span" color="#990000">보편적이고 타당하다 생각할 너의 논리는&nbsp;</font></b></div><div style="text-align: center;"><b><font class="Apple-style-span" color="#990000"><br />
</font></b></div><div style="text-align: center;"><b><font class="Apple-style-span" color="#990000">네 머릿속 세상에서만 유효하다.</font></b></div>			 ]]> 
		</description>
		<category>toRoad™ :: Life</category>

		<comments>http://studior.egloos.com/1558631#comments</comments>
		<pubDate>Fri, 30 Oct 2009 01:11:13 GMT</pubDate>
		<dc:creator>toRoad™</dc:creator>
	</item>
	<item>
		<title><![CDATA[ [Life] 도움 안되는 다이어트 충고 ]]> </title>
		<link>http://studior.egloos.com/1554992</link>
		<guid>http://studior.egloos.com/1554992</guid>
		<description>
			<![CDATA[ 
  <div><b><font class="Apple-style-span" color="#CC6600">+ &nbsp;Yahoo 에서 괜찮은 다이어트 정보를 찾았다.</font></b></div><div><br />
</div><div>Myth No. 1: 저녁 8시 이후에는 먹지 마라.</div><div><br />
</div><div>잘못된 충고: 낮시간에 섭취한 칼로리들은 모두 활동에 소모되는데 반해 밤에 섭취한 칼로리는 그대로 남아 지방으로 변한다는 논리로, 해가 진 뒤에는 음식물을 먹지 않는 다이어트법이다.</div><div><br />
</div><div>사실은: 칼로리는 시간별로 작용이 달라지지 않는다. 먹은 것을 소화하고 열량을 소모하는 과정은 아침이건 밤이건 동일하다. 밤에 먹은 음식이라고 모두 지방으로 변할 리 없다는 얘기다. 가급적 야식을 피해야 하는 이유는 소화기관에 부담을 줄 염려 때문이다. 먹는 시간보다는 총 섭취 칼로리를 조절하는 것이 적절하다.&nbsp;</div><div><br />
</div><div>도움이 되는 충고: 밤시간이라고해서 배고픔을 억지로 참을 필요는 없다. 단, 체중조절을 목표로 하고 있다면 야참으로 아이스크림이나 과자 대신 과일이나 씨리얼을 먹도록 하자. 야식하는 사람일수록 비만일 확률이 높은 이유는 '과식' 때문이다. 규칙적인 식사를 하지 않다보니 한번에 많이 먹게 되는 것.</div><div><br />
</div><div><br />
</div><div>Myth No. 2: 적은 양을 자주 먹는 것이 신진대사를 활성화한다.</div><div><br />
</div><div>잘못된 충고: 낮은 칼로리, 소량의 음식을 자주 섭취하면 배고픔을 느끼지 않게 되고 신진대사가 활성화되어 같은 양을 먹고도 더 많은 칼로리를 소모할 수 있게 된다는 이야기를 누구나 한번쯤 들어봤을 것이다.&nbsp;</div><div><br />
</div><div>사실은: 음식 섭취가 신진대사에 주는 영향은 미미하다. 간혹 카페인 섭취가 일시적으로 신진대사를 높이는 경우도 있지만, 체중감소에 도움이 될 정도는 아니다. 기초대사율(BMR)을 조절하는 것은 신체 구성과 사이즈. 근육이 많고 체격이 클수록 소모 칼로리가 늘어난다.&nbsp;</div><div><br />
</div><div>도움이 되는 충고: 신진대사를 높이고 싶다면, 근육을 만들어라. 1파운드의 지방이 하루에 2~3칼로리를 소모하는데 비해, 근육 1파운드는 하루 14칼로리를 소모한다. 따라서 근력운동 없이 다이어트만 하는 것은 신진대사를 낮추는 셈이 된다. 음식조절과 함께 필라테스나 파워 요가, 덤벨운동 등을 병행할 것을 추천한다.&nbsp;</div><div><br />
</div><div><br />
</div><div>Myth No. 3: 파스타와 같은 밀가루 음식을 먹으면 뚱뚱해진다.</div><div><br />
</div><div>잘못된 충고: 탄수화물을 섭취하면 몸에서 당분으로 바뀌고, 결국 지방으로 쌓이게 된다며 탄수화물 섭취를 극단적으로 줄이라는 조언을 한다.</div><div><br />
</div><div>사실은: 탄수화물 자체는 아무 죄가 없다. 살이 찌는 이유는 과도한 칼로리 섭취 때문이지 특정 영양성분 때문이 아니다. 탄수화물,지방,단백질 어떤 형태이건 적정 칼로리만 지킨다면 상관없다. 또한 탄수화물은 과일과 야채, 통곡물 등 건강에 좋은 음식에도 풍부한 성분이다.&nbsp;</div><div><br />
</div><div>도움이 되는 충고: 밀가루 음식을 즐기는 것은 좋지만, 적정량만 먹도록 조절할 것. 파스타에는 야채를 곁들이고 토마토 소스를 부어 먹는 것이 건강에 도움이 된다.&nbsp;</div><div><br />
</div><div><br />
</div><div>Myth No. 4: 커피가 체중조절을 돕는다.</div><div><br />
</div><div>잘못된 충고: 커피 속 카페인이 식욕을 줄이고 신진대사를 활성화시켜 살이 잘 빠지게 한다는 조언.</div><div><br />
</div><div>사실은: 커피를 마시면 일시적으로 식욕이 사라진 듯 느낄 수 있으나, 효과가 오래가지는 않는다. 하루 한두잔 정도의 커피는 체중을 줄이는데 전혀 도움이 되지 않는다. 그렇다고 하루 4~7잔씩 마시면 불면증, 고혈압, 심박수 증가, 불안증 등을 유발할 위험이 있으니 삼가하는 편이 좋다.</div><div><br />
</div><div>도움이 되는 충고: 커피 애호가라면 하루 한두잔을 크림이나 설탕 없이 즐기는 것이 다이어트를 방해하지 않는다. 모카나 카라멜 라떼같은 달짝지근한 커피들은 300칼로리가 넘어 다이어트에 도움이 되기는 커녕 칼로리 과다의 원인이 된다. 커피를 많이 마셔 불면증 증세가 오면, 식욕을 자극하는 호르몬이 분비되어 섭취 칼로리가 늘어나는 결과를 낳게 된다.&nbsp;</div><div><br />
</div><div><br />
</div><div><br />
</div><div>Myth No. 5: 우유를 많이 마시면 체중 감소에 도움이 된다.</div><div><br />
</div><div><br />
</div><div>잘못된 충고: 칼슘은 지방 분해를 돕기 때문에, 우유를 많이 마시면 살이 빠지게 된다는 조언.&nbsp;</div><div><br />
</div><div>사실은: 유제품은 결코 마법같은 효과를 가져올 수 없다. 오히려 유제품을 많이 섭취하는 사람일수록 섭취 칼로리가 높다는 연구 결과도 나온 바 있다. 일반적으로 전문가들은 유제품 섭취와 다이어트 사이에 별 상관관계가 없다고 설명한다.&nbsp;</div><div><br />
</div><div>도움이 되는 충고: 다이어트 중이라면 저지방 우유를 마시자. 지방도 줄이고 칼로리 섭취도 줄이면서 칼슘을 섭취할 수 있는 방법이다. 50세 이하 성인이라면 1,000밀리그램(우유 세 컵 분량), 50세 이상은 1,200밀리그램씩의 칼슘을 섭취하는 것이 좋다. 우유를 먹으면 소화가 잘 되지 않는다면 두유, 오렌지 주스, 푸른잎 채소, 생선 등으로 칼슘을 섭취하자.</div><div><br />
</div><div><br />
</div><div>Myth No. 6: 섭취 칼로리를 제한하는 것이 체중을 줄이는 최선의 방법이다.</div><div><br />
</div><div><br />
</div><div>잘못된 충고: 먹는 양을 줄이고 칼로리를 제한하는 것 이외에는 체중을 줄일 수 있는 별다른 방법은 없다고 단언하는 경우.</div><div><br />
</div><div>사실은: 먹는 양을 줄이면 물론 체중이 줄어든다. 하지만 그 효과는 일시적일 뿐, 다시 정상적인 식생활로 돌아오면 체중은 다시 늘어나기 마련이다. 체중을 줄이고 이를 계속 유지하고 싶다면 애초부터 무리하게 먹는 것을 제한하는 다이어트는 하지 않는 편이 낫다.&nbsp;</div><div><br />
</div><div>도움이 되는 충고: 일주일동안 사과만 먹는다거나 하는 식의 일시적 식이요법은 장기적으로 전혀 도움이 되지 않는다. 가장 현명한 방법은 먹는 습관을 바꾸는 것. 계속 지킬 수 있는 방식으로 식단을 바꾸고, 규칙적인 생활을 하고, 지속적으로 걷기 등 가벼운 운동을 하자.&nbsp;</div><div><br />
</div><div><br />
</div><div>1차 출처: diet myths busted</div><div><a href="http://shine.yahoo.com/event/yourbestsummerbody/4-diet-myths-busted-451364/">http://shine.yahoo.com/event/yourbestsummerbody/4-diet-myths-busted-451364/</a></div><div><br />
</div><div>2차 출처:</div><div><a href="http://kr.blog.yahoo.com/health_blog/9617">http://kr.blog.yahoo.com/health_blog/9617</a></div>			 ]]> 
		</description>
		<category>toRoad™ :: Life</category>

		<comments>http://studior.egloos.com/1554992#comments</comments>
		<pubDate>Sun, 25 Oct 2009 09:16:11 GMT</pubDate>
		<dc:creator>toRoad™</dc:creator>
	</item>
	<item>
		<title><![CDATA[ [Movie] 람보 ]]> </title>
		<link>http://studior.egloos.com/1521932</link>
		<guid>http://studior.egloos.com/1521932</guid>
		<description>
			<![CDATA[ 
  람보를 봤다.<br><br><div style="text-align:center"><img class="image_mid" border="0" onmouseover="this.style.cursor='pointer'" alt="" src="http://pds17.egloos.com/pds/200909/13/79/f0030079_4aac6d204ac69.jpg" width="400" height="574" onclick="Control.Modal.openDialog(this, event, 'http://pds17.egloos.com/pds/200909/13/79/f0030079_4aac6d204ac69.jpg');" /></div><br><br><strong><span style="COLOR: #33cc00">첫번째 감상은 무난하다 였다.</span></strong><br><br>요즘의 영화 추세에 비교해볼때 제법 자극적인 장면이 포함되어 있으면서도...<br>거기에 휘둘려 영화의 흐름을 끊거나 삼천포로 빠지는 일은 없었다.<br><br><span style="COLOR: #33cc00"><strong>두번째 감상은 안타까움이었다.</strong></span><br><br>비단 전쟁뿐이겠냐 만은...<br>어느 한가지에서 극단으로 치닫아 버린 인간은 그 이후에 무엇도 예전같지 않게 된다.<br>4편의 영화속에서 람보는... 들어서버린 길을 돌아설 수 없음에 고뇌하고 끝네 운명이려니 받아들여 버린다.<br><br>관심을 가져본적도 없지만 새삼 전쟁에서 입은 심적 상처에 괴로워하는 사람들이 더 없이 안되어 보였다<br><br><div style="text-align:center"><img class="image_mid" border="0" onmouseover="this.style.cursor='pointer'" alt="" src="http://pds16.egloos.com/pds/200909/13/79/f0030079_4aac6e38e82f8.jpg" width="304" height="450" onclick="Control.Modal.openDialog(this, event, 'http://pds16.egloos.com/pds/200909/13/79/f0030079_4aac6e38e82f8.jpg');" /></div><br><br><span style="COLOR: #33cc00"><strong>람보 5편이 나온다면...</strong></span><br><br>영화의 주제가 한결 같음에 따라 그 주제적 한계성이 영화의 발전을 허용할 수 없는 단계인 것으로 생각된다.<br>나와준다면 고맙겠지만... 무언가 바랄 수는 없으리라...<br><br>개인적으로는 스텔론 형님이 뭉클한 감동을 줄 수 있는 영화를 한편 제작해 주셨으면 한다.<br><br>그 정도 내공은 있다고 본다.<br><br><br>PS<br>-&gt; 4편 마지막 장면에 고향으로 돌아온 람보가 길을 걸어가는 장면이 있다.<br>-&gt; 적당히 걸어가다 끝나려니 했는데....<br>-&gt; 끝까지 걸어가 버렸다. 걸어가면서 무슨 생각을 했는지 관심이 있다. @_@			 ]]> 
		</description>
		<category> ┗▷▶▷ Cinema</category>

		<comments>http://studior.egloos.com/1521932#comments</comments>
		<pubDate>Sun, 13 Sep 2009 04:00:10 GMT</pubDate>
		<dc:creator>toRoad™</dc:creator>
	</item>
	<item>
		<title><![CDATA[ [ETC] Way of Capture ]]> </title>
		<link>http://studior.egloos.com/1483350</link>
		<guid>http://studior.egloos.com/1483350</guid>
		<description>
			<![CDATA[ 
  <strong><div style="TEXT-ALIGN: center"><a href="http://gpalem.web.officelive.com/screencap.html"><strong>http://gpalem.web.officelive.com/screencap.html</strong></a><br><br>Capture 를 하기 위한 3가지 방법에 대한 소개글...</div></strong>			 ]]> 
		</description>
		<category>┗▷▶▷ Pragma</category>

		<comments>http://studior.egloos.com/1483350#comments</comments>
		<pubDate>Fri, 31 Jul 2009 02:58:49 GMT</pubDate>
		<dc:creator>toRoad™</dc:creator>
	</item>
	<item>
		<title><![CDATA[ [N.O.T.I.C.E] Mind Icon 080611 12:52 ]]> </title>
		<link>http://studior.egloos.com/453822</link>
		<guid>http://studior.egloos.com/453822</guid>
		<description>
			<![CDATA[ 
  <div style="TEXT-ALIGN: center"><img class="image_mid" onmouseover="this.style.cursor='pointer'" style="CURSOR: pointer" onclick="Control.Modal.openDialog(this, event, 'http://pds8.egloos.com/pds/200806/08/79/f0030079_484beb7591572.png');" height="480" alt="" src="http://pds8.egloos.com/pds/200806/08/79/f0030079_484beb7591572.png" width="136" border="0"><br>...따위는 없다.</div>			 ]]> 
		</description>
		<category>N.O.T.I.C.E</category>

		<comments>http://studior.egloos.com/453822#comments</comments>
		<pubDate>Wed, 10 Jun 2009 15:53:00 GMT</pubDate>
		<dc:creator>toRoad™</dc:creator>
	</item>
	<item>
		<title><![CDATA[ Kuro™ 님의 블로그 ]]> </title>
		<link>http://studior.egloos.com/1408341</link>
		<guid>http://studior.egloos.com/1408341</guid>
		<description>
			<![CDATA[ 
  <div style="TEXT-ALIGN: center"><a href="http://kuros.textcube.com/"><strong>http://kuros.textcube.com/</strong></a><br><br><div style="text-align:center"><img class="image_mid" border="0" onmouseover="this.style.cursor='pointer'" alt="" src="http://pds15.egloos.com/pds/200905/19/79/f0030079_4a122220f386d.png" width="500" height="500" onclick="Control.Modal.openDialog(this, event, 'http://pds15.egloos.com/pds/200905/19/79/f0030079_4a122220f386d.png');" /></div></div>			 ]]> 
		</description>
		<category>┗▷▶▷ Dever</category>

		<comments>http://studior.egloos.com/1408341#comments</comments>
		<pubDate>Tue, 19 May 2009 03:06:17 GMT</pubDate>
		<dc:creator>toRoad™</dc:creator>
	</item>
	<item>
		<title><![CDATA[ [Blog] LegendFinger ]]> </title>
		<link>http://studior.egloos.com/1364049</link>
		<guid>http://studior.egloos.com/1364049</guid>
		<description>
			<![CDATA[ 
  <u><span style="COLOR: #0000ff"><div style="TEXT-ALIGN: center"><u><span style="COLOR: #0000ff"><a href="http://legendfinger.com/" target="_blank"><strong>http://legendfinger.com/</strong></a></span></u></div></span></u><a href="http://legendfinger.com/"></a>			 ]]> 
		</description>
		<category> ┗▷▶▷ Blogger</category>

		<comments>http://studior.egloos.com/1364049#comments</comments>
		<pubDate>Tue, 07 Apr 2009 05:00:42 GMT</pubDate>
		<dc:creator>toRoad™</dc:creator>
	</item>
	<item>
		<title><![CDATA[ [Comp] CAB ]]> </title>
		<link>http://studior.egloos.com/1363845</link>
		<guid>http://studior.egloos.com/1363845</guid>
		<description>
			<![CDATA[ 
  <div style="TEXT-ALIGN: center"><a href="http://www.codeproject.com/KB/files/CABCompressExtract.aspx"><strong>http://www.codeproject.com/KB/files/CABCompressExtract.aspx</strong></a><br><br><li><a href="http://www.codeproject.com/KB/files/CABCompressExtract/Cabinet_C___Project.zip">Download C++ project with demo - 439.17 KB </a><li><a href="http://www.codeproject.com/KB/files/CABCompressExtract/CabLib_.NET_Project.zip">Download .NET project with demo - 1.48 MB</a> </li></div><div style="TEXT-ALIGN: center"><h2>Introduction</h2><p>With this project, <strong>C++</strong> and <strong>.NET</strong> programmers get a <strong>very</strong> versatile library for compression and extraction of Microsoft <strong>CAB</strong> files.</p><p>.NET 1.1 does not offer compression functionality. .NET 2.0 offers the <code>System.IO.Compression.GZipStream</code> class. But this is awkward to use and very <strong>primitive</strong>; it can only compress a stream but it is not possible to compress folders containing files and subfolders. </p><p>If you search the internet for more comfortable compression libraries, you find, for example, <em>ICSharpCode.SharpZipLib.dll</em> which offers ZIP compression. But this library is awkward to use and <strong>buggy</strong>, and so is unusable. Although the bugs have been known for years, the author has not fixed them.</p><p>I asked myself why should I search for another open source library (which will again have other bugs) while Windows itself supports <strong>CAB</strong> archives since the first days? Microsoft's <em>Cabinet.dll</em> (in the <em>System32</em> directory) is not buggy. Many Microsoft installers (like the installer for Internet Explorer or Windows patches) use it. Additionally, CAB reaches a much <strong>better compression ratio</strong> than ZIP. Finally I found the project "<a href="http://www.codeproject.com/win32/cabinet.asp">Microsoft Cabinet Templates</a>" by Luuk Weltevreden on CodeProject. He created a very versatile wrapper around Microsoft's <em>Cabinet.dll</em>, consisting of C++ templates.</p><p>But he didn't even do half of the work. He wrote good extraction classes, but the compression class was completely missing. I worked on his code, fixed a serious bug, simplified some awkward code, removed the templates, and added the missing compression functionality, encryption, Unicode support, internet extraction and more. Additionally, I added all files you need to compile the project. There is no need to download anything from Microsoft anymore.</p><h2>Features</h2><ul><li>This library is VERY <strong>easy</strong> to use. <li>This library is lightweight and VERY <strong>fast</strong>. (pure C++ code) <li>This library can be <strong>extended</strong> very easily. <li>One project is for <strong>C++</strong> developers. <li>Another project is for <strong>.NET</strong> developers. <li>Both projects compile on <strong>Visual Studio</strong> .NET (7.0), .NET 2003 (7.1) and .NET 2005 (8.0). <li>The C++ project additionally compiles on <strong>Visual Studio </strong>6. <li>The C++ project runs on Windows 95, 98, ME, NT, 2000, XP, Vista and higher. <li>The .NET project runs on all platforms where the .NET framework is installed. <li>Optional<strong> Encryption</strong> / Decryption of CAB files. <li>CAB files can contain <strong>trees</strong> of subfolders and files. <li>File <strong>dates</strong> (in either <strong>UTC</strong> or <strong>local time</strong>) and file attributes are preserved when compressing / extracting. <li>Extraction of CAB files which are embedded in the <strong>resources</strong> of your Win32 project or .NET project. <li>In .NET, you can additionally extract CAB files from a <strong>stream</strong>. <li>The compression can <strong>split</strong> large CAB files into multiple pieces. (<em>Pack1.cab</em>, <em>Pack2.cab</em>, <em>Pack3.cab</em>, etc) <li>An event handler allows to display the compression / extraction <strong>progress</strong> in the GUI of your application. <li>A lot of <strong>event handlers</strong> are called during compression and extraction which allows to interact with the progress (for example, filtering specific files) <li>Both projects come with a <strong>demo</strong> application which shows how to compress and extract files and embedded CAB resources. Encryption and Decryption is also included in the demo. <li>This project makes use of Microsoft's <strong><em>Cabinet.dll</em></strong> in your <em>System(32)</em> directory, which is part of the operating system since Windows NT/98. <li><em>Cabinet.dll</em> will be loaded only when it is needed and <strong>unloaded</strong> afterwards. You can also link <strong>statically</strong> and the external DLL is not required. <li>No additional Microsoft downloads required to compile and run this project. <li>The C++ and the .NET projects support <strong>Unicode</strong> in paths and <strong>filenames</strong> (e.g. Japanese) independent if compiled as <strong>MBCS</strong> or <strong>UNICODE</strong>. <li>The .NET library is <strong>thread safe</strong>. <li>The .NET library is <strong>strong named</strong>, it can be installed into the GAC with <em>gacutil.exe</em>. </li></ul><h2>Version History</h2><ul><li>Since version Jan 2007, <strong><em>Msvcp70/71/80.DLL</em></strong> is not required anymore. <li>Since version Oct 2007, <strong><em>Msvcr70/71.DLL</em></strong> is not required anymore if CabLib is compiled on Visual Studio 2003. <li>Since version Apr 2008, you can extract CAB files <strong>directly from a server</strong>, (URL extraction from HTTP(S) / FTP). <li>You can even extract only specific files out of a CAB on a server without downloading the entire CAB file. (<strong>partial download</strong>) <li>You can also abuse this library to only <strong>download a file</strong> (MP3, AVI,..) from the internet to disk without CAB extraction. <li>Since version May 2008, the .NET library also extracts files with the extensions <strong>.URL</strong> or <strong>.LNK</strong>. <li>Since version Jun 2008, the encryption/decryption of CAB files uses the <strong>Blowfish</strong> algorithm. (see below) <li>Since version Aug 2008, the creation of CAB archives <strong>without compression</strong> is supported. <li>Since version Sep 2008, you can <strong>extract directly to memory</strong>. Additionally UTF7 was replaced with <strong>UTF8</strong>. <li>Since version Oct 2008, both projects can be compiled as 32 Bit or <strong>64 Bit version</strong>. <li>Since version Jan 2009, you can turn off <strong>UTF</strong>8 encoding. (See below!) <li>Since version Feb 2009, you can link <em>Cabinet.dll</em> <strong>statically</strong>. (See <em>Defines.h</em>) <li>Since version Mar 2009, <em>CabLib.dll</em> is <strong>strong named</strong>. <li>You can download <a href="http://www.codeproject.com/KB/install/Installer.aspx"><strong>Universal Installer</strong></a> (incl sourcecode) which uses the CabLib Library for software setups and updates. <br>This application demonstrates all the available CabLib features like URL extraction, extraction to memory, display the progress in a progressbar, etc.. </li></ul></div>			 ]]> 
		</description>
		<category> ┗▷▶▷ GameDev</category>

		<comments>http://studior.egloos.com/1363845#comments</comments>
		<pubDate>Tue, 07 Apr 2009 01:06:21 GMT</pubDate>
		<dc:creator>toRoad™</dc:creator>
	</item>
</channel>
</rss>
