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
- ProjectionNode.cs
- IsolatedStorageException.cs
- LinkUtilities.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- ExpressionBuilder.cs
- NonBatchDirectoryCompiler.cs
- SmiXetterAccessMap.cs
- ReadOnlyTernaryTree.cs
- HtmlContainerControl.cs
- CustomValidator.cs
- ReaderWriterLock.cs
- BitStack.cs
- CellTreeSimplifier.cs
- BypassElement.cs
- GridSplitter.cs
- ProxyHelper.cs
- Vector3D.cs
- TcpTransportElement.cs
- ColorTransform.cs
- login.cs
- NotificationContext.cs
- JulianCalendar.cs
- HtmlWindow.cs
- RadialGradientBrush.cs
- DictionaryBase.cs
- ReferenceConverter.cs
- Events.cs
- WebHttpSecurityElement.cs
- PropertyStore.cs
- XmlSchemaValidator.cs
- OracleException.cs
- DataGridViewDataErrorEventArgs.cs
- UnsafeNativeMethods.cs
- PropertyGridCommands.cs
- UrlPropertyAttribute.cs
- AttributedMetaModel.cs
- OperationAbortedException.cs
- Double.cs
- DesignRelation.cs
- SemaphoreFullException.cs
- PipeConnection.cs
- CodeArrayIndexerExpression.cs
- ScrollItemProviderWrapper.cs
- BasicExpandProvider.cs
- MatrixTransform.cs
- RtfControlWordInfo.cs
- EdmError.cs
- Int64.cs
- CustomTrackingRecord.cs
- RawTextInputReport.cs
- SynchronizationLockException.cs
- WindowsIPAddress.cs
- SoapSchemaMember.cs
- WebServiceErrorEvent.cs
- ServicePoint.cs
- StateMachineWorkflowDesigner.cs
- _ShellExpression.cs
- PassportAuthenticationModule.cs
- LogWriteRestartAreaState.cs
- Listener.cs
- XmlNavigatorStack.cs
- KeyedHashAlgorithm.cs
- KerberosSecurityTokenProvider.cs
- FrameworkContentElement.cs
- AddInController.cs
- Int32CAMarshaler.cs
- WindowsIPAddress.cs
- DecimalKeyFrameCollection.cs
- FamilyTypeface.cs
- StatusStrip.cs
- DataGridCaption.cs
- XsdDuration.cs
- XPathArrayIterator.cs
- BamlRecordHelper.cs
- TableCellCollection.cs
- LogWriteRestartAreaState.cs
- PointKeyFrameCollection.cs
- XmlSchemaParticle.cs
- WebPartConnectionsCancelEventArgs.cs
- HtmlTextArea.cs
- Bitmap.cs
- AttributeAction.cs
- ButtonField.cs
- CodePrimitiveExpression.cs
- SimpleFileLog.cs
- LockingPersistenceProvider.cs
- DockPatternIdentifiers.cs
- TextTreeInsertElementUndoUnit.cs
- OleDbDataAdapter.cs
- ToolboxItemFilterAttribute.cs
- FlowDocument.cs
- ErrorLog.cs
- AvTrace.cs
- wgx_sdk_version.cs
- VisualTarget.cs
- IntegerValidator.cs
- Pkcs7Signer.cs
- MenuStrip.cs
- ModelProperty.cs
- Timeline.cs