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
- TabControlCancelEvent.cs
- WhitespaceRuleLookup.cs
- ObjectIDGenerator.cs
- ExclusiveTcpTransportManager.cs
- _NestedSingleAsyncResult.cs
- SqlReorderer.cs
- UIAgentMonitorHandle.cs
- LabelAutomationPeer.cs
- ScriptResourceAttribute.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- DataGridViewImageColumn.cs
- TokenBasedSet.cs
- SqlClientWrapperSmiStream.cs
- ReceiveReply.cs
- UnsafeNativeMethodsCLR.cs
- DecoderNLS.cs
- WindowsStartMenu.cs
- Image.cs
- PeerTransportCredentialType.cs
- HierarchicalDataTemplate.cs
- CountdownEvent.cs
- IBuiltInEvidence.cs
- WindowsFormsSynchronizationContext.cs
- SystemIPInterfaceStatistics.cs
- BinaryCommonClasses.cs
- WindowsTooltip.cs
- ServiceModelEnhancedConfigurationElementCollection.cs
- SQLInt64.cs
- DefaultAsyncDataDispatcher.cs
- SqlReorderer.cs
- DataObjectCopyingEventArgs.cs
- TextEditorParagraphs.cs
- MessageSecurityOverMsmqElement.cs
- ComponentSerializationService.cs
- VSWCFServiceContractGenerator.cs
- ToolBarButton.cs
- XmlSchemaAnnotated.cs
- ToolStripComboBox.cs
- RefreshPropertiesAttribute.cs
- mediaclock.cs
- CollectionViewSource.cs
- FileLoadException.cs
- PanelStyle.cs
- TextTabProperties.cs
- NotImplementedException.cs
- Range.cs
- CollectionBuilder.cs
- SecuritySessionFilter.cs
- EventProviderWriter.cs
- XmlIncludeAttribute.cs
- MatrixConverter.cs
- CompositeDataBoundControl.cs
- CompiledIdentityConstraint.cs
- SiteMapDataSourceView.cs
- CellCreator.cs
- BitmapEffectOutputConnector.cs
- TableLayoutStyle.cs
- XmlName.cs
- Point.cs
- CaseStatementProjectedSlot.cs
- DetailsViewInsertedEventArgs.cs
- CapabilitiesState.cs
- TraceContext.cs
- NGCSerializationManager.cs
- MappingMetadataHelper.cs
- CellTreeNode.cs
- TextElement.cs
- HtmlFormWrapper.cs
- Converter.cs
- CodeVariableReferenceExpression.cs
- XmlEncodedRawTextWriter.cs
- ColorKeyFrameCollection.cs
- ModelPropertyImpl.cs
- ObjectCloneHelper.cs
- Point4DConverter.cs
- NameGenerator.cs
- ComponentEvent.cs
- DependencySource.cs
- Menu.cs
- StringUtil.cs
- DockPatternIdentifiers.cs
- ImageClickEventArgs.cs
- WinInetCache.cs
- HMAC.cs
- UIElementIsland.cs
- GenericNameHandler.cs
- UnsafeNativeMethods.cs
- MarkupExtensionParser.cs
- XamlVector3DCollectionSerializer.cs
- StateMachine.cs
- HttpSessionStateBase.cs
- RawStylusInputReport.cs
- NonSerializedAttribute.cs
- StorageBasedPackageProperties.cs
- RequestResizeEvent.cs
- HyperLink.cs
- PeerNodeAddress.cs
- DateBoldEvent.cs
- EdmFunction.cs
- baseaxisquery.cs