Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / UIAutomation / Win32Providers / MS / Internal / AutomationProxies / SafeCoTaskMem.cs / 1305600 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EntityDataSource.cs
- ReadOnlyDictionary.cs
- CommonRemoteMemoryBlock.cs
- PassportAuthentication.cs
- HttpModuleCollection.cs
- DecoderReplacementFallback.cs
- WinFormsUtils.cs
- SourceInterpreter.cs
- DiscoveryInnerClientAdhocCD1.cs
- ObjectListComponentEditor.cs
- CodeChecksumPragma.cs
- TypeSystem.cs
- CodeArgumentReferenceExpression.cs
- SourceLocationProvider.cs
- Visual.cs
- LinqDataView.cs
- SafeLibraryHandle.cs
- RichTextBox.cs
- TextSpanModifier.cs
- Mapping.cs
- _FixedSizeReader.cs
- NumericUpDownAcceleration.cs
- ModelUIElement3D.cs
- PaperSource.cs
- XmlnsDefinitionAttribute.cs
- Random.cs
- ToolboxControl.cs
- RotateTransform3D.cs
- Positioning.cs
- DynamicPropertyReader.cs
- ConfigurationManagerInternalFactory.cs
- TemplateInstanceAttribute.cs
- AddInActivator.cs
- Label.cs
- ImageListUtils.cs
- Convert.cs
- AttachmentCollection.cs
- SurrogateChar.cs
- NetworkStream.cs
- VerificationAttribute.cs
- VisualTreeHelper.cs
- ProviderConnectionPointCollection.cs
- xmlfixedPageInfo.cs
- TraceListener.cs
- Point3DAnimation.cs
- InputScopeManager.cs
- followingsibling.cs
- TimelineClockCollection.cs
- Highlights.cs
- WorkflowInstanceExtensionCollection.cs
- ByteRangeDownloader.cs
- DataTableTypeConverter.cs
- CuspData.cs
- StringAnimationUsingKeyFrames.cs
- WorkflowTimerService.cs
- InfoCardBaseException.cs
- Vector3D.cs
- HttpDebugHandler.cs
- _DisconnectOverlappedAsyncResult.cs
- KeyedPriorityQueue.cs
- SspiNegotiationTokenAuthenticatorState.cs
- EventHandlerList.cs
- xmlsaver.cs
- EventLogInternal.cs
- IdnMapping.cs
- _SSPISessionCache.cs
- ECDiffieHellmanCngPublicKey.cs
- QilDataSource.cs
- FormViewDesigner.cs
- Keywords.cs
- ClientFactory.cs
- ItemDragEvent.cs
- SkipStoryboardToFill.cs
- FrameworkElement.cs
- DatagridviewDisplayedBandsData.cs
- CommandConverter.cs
- TypeEnumerableViewSchema.cs
- VariableBinder.cs
- SystemIPv6InterfaceProperties.cs
- ProviderCommandInfoUtils.cs
- SHA1Cng.cs
- Page.cs
- RemoteWebConfigurationHost.cs
- Closure.cs
- SQLBytesStorage.cs
- LabelLiteral.cs
- Exception.cs
- SizeValueSerializer.cs
- HttpPostedFile.cs
- Trace.cs
- MD5CryptoServiceProvider.cs
- XmlAttributes.cs
- Pipe.cs
- ObjectDataProvider.cs
- _HTTPDateParse.cs
- SafeNativeMethods.cs
- ZipIOLocalFileDataDescriptor.cs
- entitydatasourceentitysetnameconverter.cs
- TransportChannelListener.cs
- IntegrationExceptionEventArgs.cs