Repository navigation
VariantUse
Directory actions
More options
Directory actions
More options
VariantUse
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
<!--TO READ THIS HELP FILE, RIGHT-CLICK ON THE FILE NAME IN THE
SOLUTION EXPLORER PANE AND SELECT "VIEW IN BROWSER"-->
<html><head><title>VariantUse Sample: Demonstrates the Use of Variants</title></head><body><h1>VariantUse Sample: Demonstrates the Use of Variants</h1><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()"></div><p /><p>The VariantUse sample demonstrates changing existing data into a variant, and changing a variant into other types of data. Many COM objects accept variants as function parameters. The goal of this sample is to help you change standard C data types into variants.</p><p>This sample covers the use of currency, dates, SAFEARRAYs, multidimensional arrays, strings, chars, shorts, and longs.</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Security Note </th></tr><tr><td><p>This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.</p></td></tr></table></div><h1 class="heading">Building and Running the Sample</h1><div id="sectionSection0" class="seeAlsoNoToggleSection"><h4 class="subHeading">To build and run the VariantUse sample</h4><div class="subSection"><ol><li><p>Open the solution VariantUse.sln. </p></li><li><p>On the <b>Build</b> menu, click <b>Build</b>. </p></li></ol></div><p>Run VariantUse.exe in the debugger. Place breakpoints in the code dealing with the type of data you are trying to understand. For example, if you want to see the use of variants with strings, place breakpoints in the <b>OnString</b> function. Run the sample in the debugger and click the <b>Strings</b> button. Clicking the buttons on the main dialog box will have no apparent effect unless there are breakpoints in the associated code. Once a breakpoint is reached, use the debugger's single-step feature to step through the code that transforms data into and out of a variant.</p></div><h1 class="heading">Keywords</h1><div id="sectionSection1" class="seeAlsoNoToggleSection"><p>This sample uses the following keywords:</p><p>_bstr_t; CComBSTR; CComBSTR::Append; COleSafeArray; COeSafeArray::AccessData; COleSafeArray::CreateOneDim; COleSafeArray::UnaccessData; CString; CURRENCY; SAFEARRAY; SafeArrayAccessData; SAFEARRAYBOUND; SafeArrayCreate; SafeArrayCreateVector; SafeArrayDestroy; SafeArrayGetElement; SafeArrayUnaccessData; SysAllocString; SysFreeString; T2COLE; USES_CONVERSION; VARIANT; VariantChangeType; VariantCopy</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note </th></tr><tr><td><p>Some samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task. </p></td></tr></table></div></div></div><div id="footer"><div class="footerLine"></div>
© Microsoft Corporation. All rights reserved. Send <a href="mailto:DevDocs@microsoft.com?subject=Documentation Feedback :VariantUse Sample: Demonstrates the Use of Variants">comments</a> about this topic to Microsoft.
</div></div></body></html>