Code:
/ 4.0 / 4.0 / 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. //---------------------------------------------------------------------------- // //// 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
- PerformanceCounterPermissionAttribute.cs
- TextTreeRootTextBlock.cs
- ResourceAssociationSetEnd.cs
- SQLMembershipProvider.cs
- DateTimeParse.cs
- CommonRemoteMemoryBlock.cs
- AutomationProperties.cs
- ListViewDeletedEventArgs.cs
- SessionParameter.cs
- PaintEvent.cs
- ResolveNameEventArgs.cs
- WorkerRequest.cs
- BitStream.cs
- DragCompletedEventArgs.cs
- DataRowView.cs
- ExpressionNormalizer.cs
- DataGridViewTopRowAccessibleObject.cs
- InputLanguageManager.cs
- TaskExceptionHolder.cs
- MetadataCache.cs
- FormView.cs
- ApplicationException.cs
- CustomLineCap.cs
- WebPartsPersonalizationAuthorization.cs
- CodeCommentStatement.cs
- SoapElementAttribute.cs
- HasCopySemanticsAttribute.cs
- PeerNameRegistration.cs
- BounceEase.cs
- InternalSendMessage.cs
- SqlDataSourceView.cs
- ClearTypeHintValidation.cs
- DbParameterCollectionHelper.cs
- JournalEntryStack.cs
- CompensationTokenData.cs
- SoapHelper.cs
- HttpChannelBindingToken.cs
- ColumnWidthChangedEvent.cs
- SafeSecurityHandles.cs
- FileDataSourceCache.cs
- TemplateBindingExtensionConverter.cs
- WebPartEditorCancelVerb.cs
- ErrorStyle.cs
- SqlInternalConnectionTds.cs
- FocusWithinProperty.cs
- PersonalizablePropertyEntry.cs
- StateWorkerRequest.cs
- AbandonedMutexException.cs
- EventBuilder.cs
- HostingEnvironmentException.cs
- SortKey.cs
- EditorPartCollection.cs
- IEnumerable.cs
- InfoCardClaim.cs
- MSAAEventDispatcher.cs
- DurableInstanceProvider.cs
- ElementsClipboardData.cs
- RegexBoyerMoore.cs
- ChildTable.cs
- __Filters.cs
- DayRenderEvent.cs
- Interfaces.cs
- TextMarkerSource.cs
- PasswordRecoveryDesigner.cs
- XmlEntityReference.cs
- ContractMethodParameterInfo.cs
- ConnectionConsumerAttribute.cs
- TimeoutException.cs
- XPathExpr.cs
- CmsUtils.cs
- Scripts.cs
- XpsException.cs
- MailMessageEventArgs.cs
- SafeNativeMethodsOther.cs
- TabControlToolboxItem.cs
- UnknownBitmapEncoder.cs
- Axis.cs
- DescendantOverDescendantQuery.cs
- WebResourceUtil.cs
- XsdDateTime.cs
- WaitHandleCannotBeOpenedException.cs
- LeaseManager.cs
- QuaternionConverter.cs
- FocusTracker.cs
- EdmItemCollection.cs
- WebPartZone.cs
- DataBindingExpressionBuilder.cs
- PageCanvasSize.cs
- SequentialWorkflowRootDesigner.cs
- AppearanceEditorPart.cs
- OrthographicCamera.cs
- TypeUnloadedException.cs
- TableItemPattern.cs
- ISessionStateStore.cs
- ConfigXmlAttribute.cs
- FacetDescription.cs
- BaseCodeDomTreeGenerator.cs
- CompositeDataBoundControl.cs
- SqlPersistenceWorkflowInstanceDescription.cs
- SHA256CryptoServiceProvider.cs