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
- ImageFormat.cs
- ItemsChangedEventArgs.cs
- Resources.Designer.cs
- CapabilitiesUse.cs
- ConfigurationStrings.cs
- BufferedReadStream.cs
- EventMappingSettingsCollection.cs
- MaskInputRejectedEventArgs.cs
- WebRequestModulesSection.cs
- _HeaderInfo.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- XmlException.cs
- MaskedTextBox.cs
- EntityTransaction.cs
- ZipPackagePart.cs
- TransformProviderWrapper.cs
- TypeGeneratedEventArgs.cs
- DataComponentNameHandler.cs
- BaseComponentEditor.cs
- Stylus.cs
- AccessDataSourceDesigner.cs
- IList.cs
- TraceSection.cs
- SqlTypesSchemaImporter.cs
- AccessibleObject.cs
- XmlMtomWriter.cs
- CounterCreationDataCollection.cs
- RSAOAEPKeyExchangeDeformatter.cs
- Emitter.cs
- LayoutTable.cs
- DataGridViewBindingCompleteEventArgs.cs
- DeviceContext.cs
- Floater.cs
- JsonQNameDataContract.cs
- TaiwanCalendar.cs
- IPGlobalProperties.cs
- HtmlTextViewAdapter.cs
- XmlSchemaGroup.cs
- TypeBuilderInstantiation.cs
- QilInvokeLateBound.cs
- MatrixStack.cs
- CompModHelpers.cs
- CapiSafeHandles.cs
- GPRECT.cs
- XMLUtil.cs
- SoapObjectInfo.cs
- HttpDebugHandler.cs
- Matrix3DValueSerializer.cs
- XPathNodeList.cs
- BaseProcessor.cs
- BasePropertyDescriptor.cs
- TargetException.cs
- HttpWebRequest.cs
- WebPartTransformer.cs
- SupportingTokenBindingElement.cs
- ParallelTimeline.cs
- _StreamFramer.cs
- PropertyItemInternal.cs
- TextServicesHost.cs
- DataServiceQueryOfT.cs
- WebBaseEventKeyComparer.cs
- WebPartUserCapability.cs
- MemberRelationshipService.cs
- CollectionViewSource.cs
- CommandHelpers.cs
- CodeBinaryOperatorExpression.cs
- DataGridViewCell.cs
- sqlpipe.cs
- RawUIStateInputReport.cs
- FixedPageAutomationPeer.cs
- ModuleElement.cs
- ImmComposition.cs
- Geometry.cs
- SettingsContext.cs
- FormViewInsertedEventArgs.cs
- WebBrowserEvent.cs
- ToolstripProfessionalRenderer.cs
- QueryOperationResponseOfT.cs
- EndpointAddress10.cs
- TaskHelper.cs
- TypeTypeConverter.cs
- TargetParameterCountException.cs
- TreeViewBindingsEditorForm.cs
- GradientStop.cs
- MetadataUtil.cs
- HtmlTableRow.cs
- BulletChrome.cs
- LocalBuilder.cs
- XmlSerializableWriter.cs
- ExceptionUtility.cs
- Win32Exception.cs
- SecUtil.cs
- MaterialCollection.cs
- TimerEventSubscription.cs
- DragDrop.cs
- XmlDataSourceView.cs
- AnimationTimeline.cs
- EditorZoneBase.cs
- dbenumerator.cs
- CustomWebEventKey.cs