Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / AccessibleTech / longhorn / Automation / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HMACSHA1.cs
- SoapSchemaExporter.cs
- CrossSiteScriptingValidation.cs
- EntryPointNotFoundException.cs
- storepermissionattribute.cs
- Range.cs
- CanExecuteRoutedEventArgs.cs
- ItemCollection.cs
- XPathMultyIterator.cs
- PerfCounters.cs
- ElapsedEventArgs.cs
- DataBinding.cs
- DataSysAttribute.cs
- controlskin.cs
- HtmlControlAdapter.cs
- XPathNode.cs
- Globals.cs
- SspiNegotiationTokenProvider.cs
- DataSourceViewSchemaConverter.cs
- FirstMatchCodeGroup.cs
- RayMeshGeometry3DHitTestResult.cs
- GridViewColumn.cs
- XhtmlConformanceSection.cs
- IODescriptionAttribute.cs
- CodeNamespaceCollection.cs
- TextBoxRenderer.cs
- FakeModelPropertyImpl.cs
- EntityDataSourceDataSelectionPanel.designer.cs
- Error.cs
- StreamGeometry.cs
- StorageInfo.cs
- NavigationPropertyAccessor.cs
- RangeBase.cs
- RequestUriProcessor.cs
- PriorityQueue.cs
- MultiPageTextView.cs
- XmlnsDictionary.cs
- IISUnsafeMethods.cs
- WinCategoryAttribute.cs
- CacheChildrenQuery.cs
- ClientRuntimeConfig.cs
- FileNotFoundException.cs
- RestHandlerFactory.cs
- SchemaTableColumn.cs
- FocusWithinProperty.cs
- OptimalTextSource.cs
- XmlConverter.cs
- TextBlockAutomationPeer.cs
- BaseTemplateBuildProvider.cs
- XpsFontSerializationService.cs
- PolyBezierSegmentFigureLogic.cs
- TypographyProperties.cs
- CellParagraph.cs
- WmfPlaceableFileHeader.cs
- AdapterDictionary.cs
- MessageSmuggler.cs
- FormViewInsertEventArgs.cs
- PolicyReader.cs
- SqlMethods.cs
- WebAdminConfigurationHelper.cs
- documentsequencetextcontainer.cs
- LingerOption.cs
- DropDownHolder.cs
- SharedPerformanceCounter.cs
- KeyConstraint.cs
- WebPartConnectVerb.cs
- UrlMappingsSection.cs
- ZipIOLocalFileHeader.cs
- Base64Decoder.cs
- CompositeControl.cs
- EntityViewGenerator.cs
- SizeValueSerializer.cs
- _Semaphore.cs
- DocumentOutline.cs
- SHA512CryptoServiceProvider.cs
- JsonSerializer.cs
- AuthorizationSection.cs
- TextBlockAutomationPeer.cs
- SerTrace.cs
- LineBreakRecord.cs
- SafeNativeMethodsOther.cs
- SerTrace.cs
- MailMessage.cs
- SafeRegistryHandle.cs
- PermissionToken.cs
- CodeIdentifiers.cs
- Size3DValueSerializer.cs
- DesignBindingPropertyDescriptor.cs
- ClientBuildManagerCallback.cs
- MissingMemberException.cs
- DataGridViewCellMouseEventArgs.cs
- Timeline.cs
- JsonQNameDataContract.cs
- AssemblyBuilder.cs
- RootBrowserWindow.cs
- TextAutomationPeer.cs
- SchemaTableOptionalColumn.cs
- Adorner.cs
- wgx_commands.cs
- X509KeyIdentifierClauseType.cs