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
- InfoCardSymmetricCrypto.cs
- Formatter.cs
- FeatureAttribute.cs
- ListViewTableRow.cs
- BulletedList.cs
- AccessibilityHelperForVista.cs
- HttpResponseHeader.cs
- Image.cs
- SHA512CryptoServiceProvider.cs
- MaterialGroup.cs
- CollectionViewGroupRoot.cs
- IImplicitResourceProvider.cs
- CompensateDesigner.cs
- GroupAggregateExpr.cs
- EditingScopeUndoUnit.cs
- WindowsListViewScroll.cs
- BindingNavigatorDesigner.cs
- ArrayTypeMismatchException.cs
- XsltOutput.cs
- activationcontext.cs
- DataGridColumn.cs
- BoundConstants.cs
- ControlType.cs
- WebBrowserBase.cs
- FontStyle.cs
- _AuthenticationState.cs
- QueryableDataSourceEditData.cs
- DataTableExtensions.cs
- DataTemplateSelector.cs
- ScrollChangedEventArgs.cs
- HtmlTitle.cs
- coordinatorscratchpad.cs
- UrlMappingsModule.cs
- AsyncCompletedEventArgs.cs
- TrustSection.cs
- TraceProvider.cs
- WebPartEditorOkVerb.cs
- PrintDialog.cs
- ChildTable.cs
- Environment.cs
- assemblycache.cs
- NotSupportedException.cs
- FixedPage.cs
- EventHandlers.cs
- SqlBuilder.cs
- ConfigXmlAttribute.cs
- FontInfo.cs
- WindowsListViewGroupSubsetLink.cs
- HwndHost.cs
- OdbcParameterCollection.cs
- DataGridViewCellValidatingEventArgs.cs
- AdCreatedEventArgs.cs
- ZipFileInfo.cs
- MemberInitExpression.cs
- LogLogRecordEnumerator.cs
- TypeExtension.cs
- TransformPatternIdentifiers.cs
- WorkflowValidationFailedException.cs
- IDReferencePropertyAttribute.cs
- MimeFormatter.cs
- Rectangle.cs
- TagNameToTypeMapper.cs
- ObjectDataSourceStatusEventArgs.cs
- CompoundFileStreamReference.cs
- DataGridViewCellCollection.cs
- XmlSchemaGroupRef.cs
- MailAddress.cs
- HuffCodec.cs
- Function.cs
- InputScope.cs
- XsdBuildProvider.cs
- ExpressionBuilder.cs
- TypeSystem.cs
- WebPartAddingEventArgs.cs
- SqlDataSourceWizardForm.cs
- StandardTransformFactory.cs
- MouseWheelEventArgs.cs
- MetadataUtil.cs
- User.cs
- SizeIndependentAnimationStorage.cs
- GetWinFXPath.cs
- UrlAuthorizationModule.cs
- XmlWriterSettings.cs
- SqlBulkCopyColumnMappingCollection.cs
- ContentElement.cs
- BaseDataBoundControlDesigner.cs
- RightsManagementEncryptedStream.cs
- EtwTrace.cs
- TextModifier.cs
- PointAnimationClockResource.cs
- SqlDataSourceStatusEventArgs.cs
- ProfileService.cs
- XPathSingletonIterator.cs
- SpeechUI.cs
- SchemaTableOptionalColumn.cs
- Calendar.cs
- QilTypeChecker.cs
- PointAnimationUsingKeyFrames.cs
- SignerInfo.cs
- VideoDrawing.cs