Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / UIAutomation / Win32Providers / MS / Internal / AutomationProxies / SafeCoTaskMem.cs / 1305600 / SafeCoTaskMem.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // // History: // 10/04/2003 : [....] Created //--------------------------------------------------------------------------- using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; using MS.Win32; namespace MS.Internal.AutomationProxies { internal sealed class SafeCoTaskMem : SafeHandleZeroOrMinusOneIsInvalid { // This constructor is used by the P/Invoke marshaling layer // to allocate a SafeHandle instance. P/Invoke then does the // appropriate method call, storing the handle in this class. private SafeCoTaskMem() : base(true) {} internal SafeCoTaskMem(int length) : base(true) { SetHandle(Marshal.AllocCoTaskMem(length * sizeof (char))); } internal string GetStringAuto() { return Marshal.PtrToStringAuto(handle); } internal string GetStringUni(int length) { // Convert the local unmanaged buffer in to a string object return Marshal.PtrToStringUni(handle, length); } // protected override bool ReleaseHandle() { Marshal.FreeCoTaskMem(handle); return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpCapabilitiesEvaluator.cs
- columnmapkeybuilder.cs
- XmlnsPrefixAttribute.cs
- DataRowChangeEvent.cs
- RemoteCryptoTokenProvider.cs
- RubberbandSelector.cs
- Repeater.cs
- CollectionMarkupSerializer.cs
- HttpCacheParams.cs
- StateWorkerRequest.cs
- GCHandleCookieTable.cs
- CollectionAdapters.cs
- Evaluator.cs
- VScrollProperties.cs
- PackageRelationshipCollection.cs
- SqlConnectionStringBuilder.cs
- MetadataWorkspace.cs
- IISUnsafeMethods.cs
- MimeParameter.cs
- InputLanguageEventArgs.cs
- JavaScriptString.cs
- List.cs
- SHA1.cs
- GregorianCalendar.cs
- CacheRequest.cs
- IdentityHolder.cs
- TransformConverter.cs
- BitmapEffect.cs
- SendMailErrorEventArgs.cs
- DrawingGroup.cs
- PluggableProtocol.cs
- NonDualMessageSecurityOverHttp.cs
- NumericExpr.cs
- HostedBindingBehavior.cs
- HealthMonitoringSection.cs
- DataTableMappingCollection.cs
- TextBoxRenderer.cs
- XMLUtil.cs
- WebAdminConfigurationHelper.cs
- ConcurrencyBehavior.cs
- FrameSecurityDescriptor.cs
- IProvider.cs
- KeyEvent.cs
- StyleReferenceConverter.cs
- AvTrace.cs
- MethodImplAttribute.cs
- ValidationRule.cs
- HybridWebProxyFinder.cs
- Encoder.cs
- BinHexEncoder.cs
- FormsAuthenticationEventArgs.cs
- _CacheStreams.cs
- DeferredSelectedIndexReference.cs
- Msmq4SubqueuePoisonHandler.cs
- MissingMemberException.cs
- PageStatePersister.cs
- NeutralResourcesLanguageAttribute.cs
- XmlAttributeProperties.cs
- ExpressionNode.cs
- EncoderParameters.cs
- Switch.cs
- Form.cs
- MaterialGroup.cs
- DataViewSettingCollection.cs
- TemplatedEditableDesignerRegion.cs
- Rotation3D.cs
- XmlSchemaSimpleType.cs
- log.cs
- TabOrder.cs
- TcpChannelHelper.cs
- XmlNamespaceManager.cs
- RuntimeHandles.cs
- CollectionContainer.cs
- CollectionType.cs
- AttributeSetAction.cs
- AttributeEmitter.cs
- RIPEMD160.cs
- DBConnectionString.cs
- ConfigurationPermission.cs
- SupportsEventValidationAttribute.cs
- ComPersistableTypeElement.cs
- TableColumnCollectionInternal.cs
- PingReply.cs
- SqlConnection.cs
- ManagedIStream.cs
- DefaultBindingPropertyAttribute.cs
- Point4DConverter.cs
- GZipDecoder.cs
- FontEmbeddingManager.cs
- PathGeometry.cs
- SetIterators.cs
- WrapPanel.cs
- SkewTransform.cs
- ListItem.cs
- CodeTypeReferenceCollection.cs
- ADMembershipUser.cs
- DbgUtil.cs
- GifBitmapDecoder.cs
- DbParameterHelper.cs
- CharAnimationUsingKeyFrames.cs