Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- InfoCardProofToken.cs
- ToolStripGripRenderEventArgs.cs
- ADMembershipUser.cs
- ImageSource.cs
- Accessors.cs
- PingReply.cs
- InputScopeAttribute.cs
- XsltInput.cs
- GeneralTransform2DTo3DTo2D.cs
- RemotingServices.cs
- MediaPlayer.cs
- ErrorFormatter.cs
- Image.cs
- FragmentQueryProcessor.cs
- StateRuntime.cs
- ResourceReferenceExpression.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- Schema.cs
- CompilerGlobalScopeAttribute.cs
- BooleanToSelectiveScrollingOrientationConverter.cs
- SecurityHeader.cs
- GZipDecoder.cs
- MobileControlPersister.cs
- EventlogProvider.cs
- XmlRawWriterWrapper.cs
- MembershipUser.cs
- PersonalizationProviderCollection.cs
- _CacheStreams.cs
- XmlSchemaSimpleTypeList.cs
- ModelPerspective.cs
- assertwrapper.cs
- RuntimeDelegateArgument.cs
- EditingMode.cs
- InvalidDataException.cs
- SerialErrors.cs
- ComPlusTypeValidator.cs
- PropertyChangedEventArgs.cs
- TransformPattern.cs
- CompressionTracing.cs
- CompressedStack.cs
- xsdvalidator.cs
- DesigntimeLicenseContextSerializer.cs
- AddingNewEventArgs.cs
- ManagedFilter.cs
- ToolStripPanelRow.cs
- AttachedPropertyMethodSelector.cs
- CapabilitiesSection.cs
- ReadOnlyPropertyMetadata.cs
- EventHandlingScope.cs
- ComponentRenameEvent.cs
- HttpRawResponse.cs
- PerformanceCounterPermissionAttribute.cs
- TCPClient.cs
- XmlQualifiedName.cs
- ListItem.cs
- URL.cs
- PageThemeParser.cs
- CutCopyPasteHelper.cs
- FormCollection.cs
- KnownBoxes.cs
- ErrorProvider.cs
- DataListItemEventArgs.cs
- _CacheStreams.cs
- TextContainer.cs
- AnimationStorage.cs
- RadioButton.cs
- RuntimeCompatibilityAttribute.cs
- MultiByteCodec.cs
- DataSetUtil.cs
- HttpProfileGroupBase.cs
- MimePart.cs
- UrlMappingCollection.cs
- ListViewGroup.cs
- WebPartChrome.cs
- KeyValuePairs.cs
- DBDataPermissionAttribute.cs
- SHA1Managed.cs
- SEHException.cs
- DirectionalLight.cs
- KeyValuePairs.cs
- ExecutionEngineException.cs
- ExitEventArgs.cs
- DisplayMemberTemplateSelector.cs
- WindowsUserNameCachingSecurityTokenAuthenticator.cs
- TabControlEvent.cs
- XmlText.cs
- HtmlTitle.cs
- GPPOINT.cs
- WebPartEventArgs.cs
- Literal.cs
- VirtualPathData.cs
- ComponentResourceKey.cs
- CodeNamespaceImportCollection.cs
- StringWriter.cs
- ObjectNavigationPropertyMapping.cs
- CounterCreationDataCollection.cs
- UnmanagedHandle.cs
- NegotiationTokenProvider.cs
- EntityDataSourceWizardForm.cs
- QilPatternVisitor.cs