Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- Set.cs
- EdmComplexPropertyAttribute.cs
- GlyphingCache.cs
- SqlDataAdapter.cs
- OdbcEnvironment.cs
- PersianCalendar.cs
- XamlPathDataSerializer.cs
- DetailsViewRowCollection.cs
- RuntimeHelpers.cs
- SqlRetyper.cs
- UIServiceHelper.cs
- ResourceManager.cs
- CLSCompliantAttribute.cs
- XamlStyleSerializer.cs
- TableLayoutColumnStyleCollection.cs
- WSSecurityOneDotOneReceiveSecurityHeader.cs
- SupportingTokenDuplexChannel.cs
- ProfileParameter.cs
- OdbcFactory.cs
- SQLInt16.cs
- ExpressionBinding.cs
- ReturnEventArgs.cs
- RuleSettings.cs
- Int32CAMarshaler.cs
- RequestCachePolicy.cs
- DependencyObjectPropertyDescriptor.cs
- EpmAttributeNameBuilder.cs
- PieceNameHelper.cs
- ResourceReferenceExpressionConverter.cs
- ToolStripDropDownClosedEventArgs.cs
- CommandBinding.cs
- AnimationClock.cs
- ToolStripEditorManager.cs
- UnsafeNativeMethods.cs
- WebPartDisplayMode.cs
- ScriptingJsonSerializationSection.cs
- Knowncolors.cs
- WorkBatch.cs
- DateTimeFormatInfo.cs
- InstalledFontCollection.cs
- ISCIIEncoding.cs
- RMEnrollmentPage2.cs
- WebServiceTypeData.cs
- GlyphCache.cs
- SecurityTokenException.cs
- SafeSecurityHandles.cs
- NullRuntimeConfig.cs
- ThreadInterruptedException.cs
- JsonQNameDataContract.cs
- EventListener.cs
- CommunicationException.cs
- DataServiceRequest.cs
- InvalidComObjectException.cs
- StorageConditionPropertyMapping.cs
- MatrixTransform.cs
- GridViewCancelEditEventArgs.cs
- PolicyReader.cs
- BuildProvider.cs
- MessageBox.cs
- StringExpressionSet.cs
- SQLMoney.cs
- AdvancedBindingPropertyDescriptor.cs
- TypedDatasetGenerator.cs
- WebPartVerb.cs
- PseudoWebRequest.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- TableStyle.cs
- SubMenuStyleCollection.cs
- DataChangedEventManager.cs
- QuotedPrintableStream.cs
- BaseCodePageEncoding.cs
- DataGridViewRowPrePaintEventArgs.cs
- PointF.cs
- SmiTypedGetterSetter.cs
- CodeAttributeDeclaration.cs
- TrimSurroundingWhitespaceAttribute.cs
- ExtensionWindow.cs
- OutputScopeManager.cs
- UmAlQuraCalendar.cs
- SystemTcpStatistics.cs
- CollectionBuilder.cs
- ContractComponent.cs
- PasswordDeriveBytes.cs
- WebPartHelpVerb.cs
- DataGridState.cs
- MeasureData.cs
- OracleInfoMessageEventArgs.cs
- DocumentGridContextMenu.cs
- ArraySubsetEnumerator.cs
- HandleCollector.cs
- ObjectDataSourceFilteringEventArgs.cs
- XmlAttributes.cs
- StyleConverter.cs
- HtmlInputText.cs
- Size3DValueSerializer.cs
- BulletedListDesigner.cs
- ButtonRenderer.cs
- XmlSchemaValidationException.cs
- ThreadExceptionDialog.cs
- HtmlProps.cs