Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / UIAutomation / Win32Providers / MS / Internal / AutomationProxies / SafeCoTaskMem.cs / 1 / 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. //---------------------------------------------------------------------------- // //// 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
- PathSegmentCollection.cs
- RangeValidator.cs
- PrimitiveSchema.cs
- ServicePointManager.cs
- GreenMethods.cs
- LinqDataSourceView.cs
- TableMethodGenerator.cs
- EmptyElement.cs
- SqlServer2KCompatibilityCheck.cs
- HttpMethodConstraint.cs
- RoleManagerModule.cs
- HMACMD5.cs
- NameValueSectionHandler.cs
- Queue.cs
- GenericIdentity.cs
- DesignerRegion.cs
- UIPropertyMetadata.cs
- ObjectTokenCategory.cs
- CharEnumerator.cs
- RouteItem.cs
- SwitchLevelAttribute.cs
- DbSourceParameterCollection.cs
- WebPartEditVerb.cs
- WebPartRestoreVerb.cs
- PointAnimationBase.cs
- InternalConfigSettingsFactory.cs
- HttpVersion.cs
- OdbcHandle.cs
- HtmlShim.cs
- ParserHooks.cs
- ActivityPreviewDesigner.cs
- InvokeMethod.cs
- ConstraintConverter.cs
- WindowsScroll.cs
- TextCollapsingProperties.cs
- SpoolingTaskBase.cs
- HtmlEmptyTagControlBuilder.cs
- QueueAccessMode.cs
- ProfileSection.cs
- Crypto.cs
- ExpressionBinding.cs
- Wizard.cs
- TextTreeFixupNode.cs
- CallInfo.cs
- RichTextBoxAutomationPeer.cs
- SynchronizationContext.cs
- DependencyProperty.cs
- WebBaseEventKeyComparer.cs
- HashAlgorithm.cs
- _SslState.cs
- CollectionConverter.cs
- safelinkcollection.cs
- EventPrivateKey.cs
- RuntimeResourceSet.cs
- WizardPanelChangingEventArgs.cs
- X509Certificate.cs
- CodeTypeDeclarationCollection.cs
- ListDataHelper.cs
- JapaneseLunisolarCalendar.cs
- CommandHelper.cs
- GiveFeedbackEventArgs.cs
- BaseComponentEditor.cs
- LinkConverter.cs
- TimerTable.cs
- ClientType.cs
- UInt16.cs
- EqualityComparer.cs
- DockEditor.cs
- AttributeXamlType.cs
- StyleXamlTreeBuilder.cs
- StoreContentChangedEventArgs.cs
- InlineUIContainer.cs
- _NegoStream.cs
- DataGridItemEventArgs.cs
- SimpleMailWebEventProvider.cs
- OutputCacheProfile.cs
- StyleSelector.cs
- TextTreeInsertUndoUnit.cs
- ListViewHitTestInfo.cs
- VoiceSynthesis.cs
- Size3D.cs
- ConfigXmlComment.cs
- CodeDelegateCreateExpression.cs
- CodeGenerator.cs
- CacheOutputQuery.cs
- BaseDataListDesigner.cs
- XamlSerializer.cs
- IssuedTokenClientBehaviorsElement.cs
- CompoundFileIOPermission.cs
- Geometry.cs
- StoryFragments.cs
- MonthChangedEventArgs.cs
- BasicCellRelation.cs
- DetailsViewInsertEventArgs.cs
- TopClause.cs
- _ConnectionGroup.cs
- ObjectStorage.cs
- HttpProcessUtility.cs
- XmlProcessingInstruction.cs
- MulticastOption.cs