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
- Size3DConverter.cs
- Logging.cs
- SimpleType.cs
- SqlProviderUtilities.cs
- DynamicRenderer.cs
- ExceptionValidationRule.cs
- KeyInfo.cs
- ScriptComponentDescriptor.cs
- SystemThemeKey.cs
- XdrBuilder.cs
- ListGeneralPage.cs
- Frame.cs
- RequestCachingSection.cs
- ZipIOExtraField.cs
- DetailsViewDeletedEventArgs.cs
- DataPointer.cs
- PropertyMapper.cs
- BevelBitmapEffect.cs
- BaseAddressElement.cs
- Rect.cs
- LocatorPart.cs
- SecurityTokenTypes.cs
- ImageClickEventArgs.cs
- TreeNodeBindingDepthConverter.cs
- EntityViewContainer.cs
- Transaction.cs
- WrappingXamlSchemaContext.cs
- IDQuery.cs
- SecurityDescriptor.cs
- _IPv4Address.cs
- Expander.cs
- ProfilePropertySettingsCollection.cs
- FileDialog_Vista.cs
- DesignerForm.cs
- Floater.cs
- XmlSchemas.cs
- SSmlParser.cs
- XmlDocumentFragment.cs
- SafeProcessHandle.cs
- DesignRelation.cs
- _emptywebproxy.cs
- SqlTopReducer.cs
- COM2PropertyBuilderUITypeEditor.cs
- CombinedGeometry.cs
- PropertySourceInfo.cs
- DomainUpDown.cs
- SystemIPGlobalStatistics.cs
- TraversalRequest.cs
- HyperLink.cs
- CreateParams.cs
- TrackBarRenderer.cs
- StructuredTypeEmitter.cs
- OuterGlowBitmapEffect.cs
- oledbmetadatacollectionnames.cs
- GridViewColumnCollectionChangedEventArgs.cs
- GeometryHitTestResult.cs
- AdornerLayer.cs
- KeyboardNavigation.cs
- CheckBoxAutomationPeer.cs
- OptimizerPatterns.cs
- ControlCachePolicy.cs
- WindowsTab.cs
- CatalogZone.cs
- Region.cs
- ToolStripActionList.cs
- FlowDocument.cs
- TemplateColumn.cs
- FunctionDescription.cs
- ListBoxItemWrapperAutomationPeer.cs
- BinaryMessageEncodingBindingElement.cs
- MsmqIntegrationReceiveParameters.cs
- HandledEventArgs.cs
- HttpWebRequest.cs
- Assert.cs
- UnsafeNativeMethods.cs
- PerformanceCounterPermission.cs
- ExpressionVisitorHelpers.cs
- SessionPageStatePersister.cs
- Literal.cs
- AuthenticatedStream.cs
- VirtualDirectoryMappingCollection.cs
- ReadWriteSpinLock.cs
- DataGridView.cs
- WebResponse.cs
- MultiView.cs
- DataGridViewComboBoxEditingControl.cs
- InvalidComObjectException.cs
- XmlCustomFormatter.cs
- MemberNameValidator.cs
- CodeExporter.cs
- TypeConverterAttribute.cs
- ConfigurationValidatorAttribute.cs
- Color.cs
- EventNotify.cs
- TreePrinter.cs
- EventLogger.cs
- DbException.cs
- WorkBatch.cs
- PageStatePersister.cs
- WsatTransactionInfo.cs