Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / ComponentModel / COM2Interop / OleStrCAMarshaler.cs / 1305376 / OleStrCAMarshaler.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms.ComponentModel.Com2Interop {
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Diagnostics;
using System;
///
///
/// This class performs marshaling on a CALPOLESTR struct given
/// from native code.
///
internal class OleStrCAMarshaler: BaseCAMarshaler {
public OleStrCAMarshaler(NativeMethods.CA_STRUCT caAddr) : base(caAddr) {
}
///
///
/// Returns the type of item this marshaler will
/// return in the items array. In this case, the type is string.
///
public override Type ItemType {
get {
return typeof(string);
}
}
protected override Array CreateArray() {
return new string[Count];
}
///
///
/// Override this member to perform marshalling of a single item
/// given it's native address.
///
protected override object GetItemFromAddress(IntPtr addr) {
string item = Marshal.PtrToStringUni(addr);
// free the memory
Marshal.FreeCoTaskMem(addr);
return item;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms.ComponentModel.Com2Interop {
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Diagnostics;
using System;
///
///
/// This class performs marshaling on a CALPOLESTR struct given
/// from native code.
///
internal class OleStrCAMarshaler: BaseCAMarshaler {
public OleStrCAMarshaler(NativeMethods.CA_STRUCT caAddr) : base(caAddr) {
}
///
///
/// Returns the type of item this marshaler will
/// return in the items array. In this case, the type is string.
///
public override Type ItemType {
get {
return typeof(string);
}
}
protected override Array CreateArray() {
return new string[Count];
}
///
///
/// Override this member to perform marshalling of a single item
/// given it's native address.
///
protected override object GetItemFromAddress(IntPtr addr) {
string item = Marshal.PtrToStringUni(addr);
// free the memory
Marshal.FreeCoTaskMem(addr);
return item;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebServicesInteroperability.cs
- MessageBox.cs
- StackBuilderSink.cs
- FormViewUpdateEventArgs.cs
- DataGridViewHeaderCell.cs
- CurrencyWrapper.cs
- GregorianCalendar.cs
- ToolStripRenderer.cs
- Point3D.cs
- BitmapFrameDecode.cs
- Number.cs
- WebPartCatalogCloseVerb.cs
- coordinatorfactory.cs
- SettingsPropertyValueCollection.cs
- Events.cs
- WebPartTracker.cs
- ContravarianceAdapter.cs
- HashHelper.cs
- DataBinder.cs
- ImageBrush.cs
- XmlCharacterData.cs
- CodeDefaultValueExpression.cs
- ClientTarget.cs
- CheckBoxField.cs
- WindowHelperService.cs
- SerializationObjectManager.cs
- QilVisitor.cs
- AssemblyName.cs
- OutputCacheProfileCollection.cs
- NumericUpDownAccelerationCollection.cs
- WebPartMenuStyle.cs
- ClientCultureInfo.cs
- PolicyUnit.cs
- PropertyBuilder.cs
- SecurityUtils.cs
- DtdParser.cs
- FileLoadException.cs
- PointCollection.cs
- HotSpot.cs
- StreamReader.cs
- QilExpression.cs
- StandardRuntimeEnumValidatorAttribute.cs
- InputLangChangeRequestEvent.cs
- UserPersonalizationStateInfo.cs
- SqlCacheDependencySection.cs
- DesignTimeVisibleAttribute.cs
- DeadCharTextComposition.cs
- XmlNotation.cs
- SafeNativeMethods.cs
- TemplateContentLoader.cs
- NativeMethods.cs
- GlobalizationAssembly.cs
- NetworkStream.cs
- DataGridTextBoxColumn.cs
- ListParaClient.cs
- ListViewInsertionMark.cs
- SqlCachedBuffer.cs
- SoapSchemaExporter.cs
- SQLUtility.cs
- ObjectContext.cs
- PersonalizationAdministration.cs
- SafeWaitHandle.cs
- EnvelopedPkcs7.cs
- WindowsToolbar.cs
- Operator.cs
- CheckBoxFlatAdapter.cs
- MachineKey.cs
- ProjectionPruner.cs
- TypeElement.cs
- SocketException.cs
- HybridDictionary.cs
- DoWorkEventArgs.cs
- HttpResponseWrapper.cs
- Latin1Encoding.cs
- Filter.cs
- OdbcException.cs
- XmlEventCache.cs
- OutputCacheProfile.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- MemberMaps.cs
- _CacheStreams.cs
- ConnectionsZone.cs
- CommandHelper.cs
- VisualCollection.cs
- CodePrimitiveExpression.cs
- XXXInfos.cs
- BoolExpression.cs
- TraceEventCache.cs
- ReadOnlyCollectionBase.cs
- EncryptedXml.cs
- PasswordTextNavigator.cs
- InputLanguageProfileNotifySink.cs
- WebServiceClientProxyGenerator.cs
- _BufferOffsetSize.cs
- UnSafeCharBuffer.cs
- AvTraceDetails.cs
- DataSourceControlBuilder.cs
- DataSourceXmlAttributeAttribute.cs
- BindingCollectionElement.cs
- PeerTransportListenAddressConverter.cs