Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- TableParaClient.cs
- GradientSpreadMethodValidation.cs
- ExtractedStateEntry.cs
- PointLight.cs
- DataControlButton.cs
- SplitterPanel.cs
- CustomErrorsSectionWrapper.cs
- SerializationSectionGroup.cs
- GridProviderWrapper.cs
- PagerSettings.cs
- CatalogPart.cs
- UIElement3DAutomationPeer.cs
- AutomationProperties.cs
- Image.cs
- Opcode.cs
- CryptoApi.cs
- PropertyCondition.cs
- versioninfo.cs
- ProcessInfo.cs
- TextServicesCompartmentEventSink.cs
- InternalCache.cs
- XmlSchemaAttributeGroup.cs
- IpcManager.cs
- MetadataArtifactLoader.cs
- UserThread.cs
- XsdDataContractExporter.cs
- ShaderEffect.cs
- MonthCalendarDesigner.cs
- TableLayoutCellPaintEventArgs.cs
- EventLogEntryCollection.cs
- OleDbMetaDataFactory.cs
- Line.cs
- DataKey.cs
- PropertyGridCommands.cs
- IgnoreFlushAndCloseStream.cs
- LoginName.cs
- CounterCreationData.cs
- DynamicResourceExtensionConverter.cs
- PartialList.cs
- Zone.cs
- DictionaryEntry.cs
- WebControlAdapter.cs
- AssertHelper.cs
- HttpFileCollection.cs
- RegexReplacement.cs
- SID.cs
- KeyedHashAlgorithm.cs
- JsonObjectDataContract.cs
- Int64Animation.cs
- AttributeInfo.cs
- SiteMapHierarchicalDataSourceView.cs
- PEFileReader.cs
- CqlParserHelpers.cs
- SrgsOneOf.cs
- BooleanStorage.cs
- TreeNodeStyleCollection.cs
- StdValidatorsAndConverters.cs
- TemplateColumn.cs
- HMACSHA1.cs
- CultureInfoConverter.cs
- figurelength.cs
- LineInfo.cs
- ComplexObject.cs
- ProcessModuleDesigner.cs
- HtmlContainerControl.cs
- BitmapEffectInputConnector.cs
- InteropAutomationProvider.cs
- DataGridItem.cs
- XmlNodeReader.cs
- HTMLTextWriter.cs
- CustomError.cs
- CallbackValidatorAttribute.cs
- BitmapEditor.cs
- TaiwanCalendar.cs
- SearchExpression.cs
- MailMessageEventArgs.cs
- FilteredReadOnlyMetadataCollection.cs
- WebErrorHandler.cs
- DesignerLabelAdapter.cs
- DataGridViewAdvancedBorderStyle.cs
- ImageIndexConverter.cs
- InstanceCreationEditor.cs
- BatchServiceHost.cs
- StrokeDescriptor.cs
- SafeFreeMibTable.cs
- XLinq.cs
- WorkflowMarkupElementEventArgs.cs
- SqlPersonalizationProvider.cs
- SubqueryRules.cs
- BooleanAnimationUsingKeyFrames.cs
- TypeDelegator.cs
- ConfigXmlSignificantWhitespace.cs
- SelectionRange.cs
- TreeNodeCollection.cs
- GregorianCalendarHelper.cs
- KeySpline.cs
- HandledEventArgs.cs
- SchemaAttDef.cs
- SettingsPropertyNotFoundException.cs
- KeyValuePair.cs