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
- Storyboard.cs
- DecoderFallback.cs
- DataComponentNameHandler.cs
- ResXResourceReader.cs
- BaseTemplateParser.cs
- ObjectTag.cs
- TriState.cs
- CodeNamespace.cs
- InstanceDataCollection.cs
- SqlPersonalizationProvider.cs
- FormViewRow.cs
- Compiler.cs
- PropertyChangingEventArgs.cs
- Property.cs
- ColumnResizeUndoUnit.cs
- ResponseBodyWriter.cs
- SafeNativeMethods.cs
- FontDifferentiator.cs
- Transform3D.cs
- UnsafeNativeMethods.cs
- Hyperlink.cs
- ClientSettingsSection.cs
- Label.cs
- ButtonBaseAutomationPeer.cs
- MultiPartWriter.cs
- MarkupWriter.cs
- PropertyNames.cs
- CompilerGeneratedAttribute.cs
- TransactionChannelFactory.cs
- Typography.cs
- EventLogEntry.cs
- DataGridViewSelectedColumnCollection.cs
- ContentHostHelper.cs
- OleDbStruct.cs
- SymmetricKey.cs
- FixedPageAutomationPeer.cs
- EditorServiceContext.cs
- DesignerInterfaces.cs
- ImpersonateTokenRef.cs
- MultiAsyncResult.cs
- PropertyCondition.cs
- EtwTrackingBehavior.cs
- DebugView.cs
- CounterSetInstance.cs
- invalidudtexception.cs
- COM2ExtendedBrowsingHandler.cs
- ToolStrip.cs
- WindowVisualStateTracker.cs
- securestring.cs
- EditorPartChrome.cs
- FeatureSupport.cs
- PathFigure.cs
- DataGridCheckBoxColumn.cs
- SocketInformation.cs
- RegexRunner.cs
- DebugView.cs
- MetadataItem_Static.cs
- VSDExceptions.cs
- RequestNavigateEventArgs.cs
- WizardSideBarListControlItem.cs
- ProgressBar.cs
- ForeignKeyConstraint.cs
- WindowsListViewGroup.cs
- AdRotatorDesigner.cs
- HelpProvider.cs
- MessageQuerySet.cs
- XPathExpr.cs
- RequiredAttributeAttribute.cs
- SqlInternalConnectionSmi.cs
- TreeNodeSelectionProcessor.cs
- InternalBufferManager.cs
- __Filters.cs
- GridViewCancelEditEventArgs.cs
- SystemColorTracker.cs
- MetadataItem_Static.cs
- CompilerLocalReference.cs
- ThreadPool.cs
- RelationshipConverter.cs
- EdmToObjectNamespaceMap.cs
- BufferCache.cs
- SizeFConverter.cs
- GenericRootAutomationPeer.cs
- ResXDataNode.cs
- Group.cs
- EncoderReplacementFallback.cs
- PropertyValue.cs
- Win32Native.cs
- SafeUserTokenHandle.cs
- SystemIPv4InterfaceProperties.cs
- BufferModesCollection.cs
- GridViewHeaderRowPresenter.cs
- InfoCardMasterKey.cs
- TextElementCollection.cs
- ChtmlLinkAdapter.cs
- TaiwanCalendar.cs
- TableLayoutColumnStyleCollection.cs
- TypeUtils.cs
- EventWaitHandle.cs
- TextLineBreak.cs
- DbProviderManifest.cs