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
- LogicalExpr.cs
- CompModSwitches.cs
- ControlPaint.cs
- XmlTypeMapping.cs
- WebPartPersonalization.cs
- COM2ColorConverter.cs
- ByeMessageCD1.cs
- StubHelpers.cs
- SafePEFileHandle.cs
- ConnectionsZone.cs
- ArrayTypeMismatchException.cs
- WebBrowserProgressChangedEventHandler.cs
- MeasureItemEvent.cs
- DefaultEvaluationContext.cs
- SecurityListenerSettingsLifetimeManager.cs
- HttpEncoderUtility.cs
- VersionPair.cs
- Models.cs
- PartialTrustVisibleAssembliesSection.cs
- DisposableCollectionWrapper.cs
- AnnotationAuthorChangedEventArgs.cs
- DataConnectionHelper.cs
- IndexObject.cs
- WindowInteropHelper.cs
- HyperlinkAutomationPeer.cs
- HashMembershipCondition.cs
- SqlConnectionStringBuilder.cs
- TransformCollection.cs
- VerificationAttribute.cs
- HttpModulesSection.cs
- SafeMILHandle.cs
- CodeNamespaceImport.cs
- PrintPreviewGraphics.cs
- SmiEventSink_DeferedProcessing.cs
- HashStream.cs
- TaiwanCalendar.cs
- WindowInteractionStateTracker.cs
- TrackingDataItemValue.cs
- SimpleTableProvider.cs
- NullExtension.cs
- RelatedCurrencyManager.cs
- SiteIdentityPermission.cs
- RadialGradientBrush.cs
- ExtensibleSyndicationObject.cs
- ApplicationId.cs
- HandlerFactoryCache.cs
- WmfPlaceableFileHeader.cs
- CorruptStoreException.cs
- ObjRef.cs
- MultipartContentParser.cs
- GorillaCodec.cs
- SendMessageRecord.cs
- HMACSHA1.cs
- XmlElementAttribute.cs
- Rotation3DAnimationBase.cs
- LoginView.cs
- DNS.cs
- DBCommandBuilder.cs
- EventMappingSettings.cs
- MaskedTextProvider.cs
- XmlBinaryReaderSession.cs
- InstanceLockedException.cs
- TransformerConfigurationWizardBase.cs
- WindowsIdentity.cs
- Compiler.cs
- ResourceExpressionBuilder.cs
- BamlTreeNode.cs
- TrustLevel.cs
- ViewStateChangedEventArgs.cs
- AuthenticationModuleElementCollection.cs
- StateChangeEvent.cs
- BasicBrowserDialog.designer.cs
- GradientStopCollection.cs
- X509SecurityTokenProvider.cs
- ControlDesigner.cs
- GradientStopCollection.cs
- MediaEntryAttribute.cs
- GlobalAllocSafeHandle.cs
- LongSumAggregationOperator.cs
- KeyConstraint.cs
- ReadOnlyDictionary.cs
- StreamUpdate.cs
- DateTimeFormat.cs
- TextParaClient.cs
- MatchingStyle.cs
- Constraint.cs
- Misc.cs
- OutputScopeManager.cs
- SmtpNegotiateAuthenticationModule.cs
- DocumentSequenceHighlightLayer.cs
- MonthCalendar.cs
- QilStrConcat.cs
- ParameterCollection.cs
- FlowDocumentPageViewerAutomationPeer.cs
- indexingfiltermarshaler.cs
- EdmFunctions.cs
- LocalServiceSecuritySettings.cs
- OuterGlowBitmapEffect.cs
- XmlSchemaGroupRef.cs
- ServiceObjectContainer.cs