Code:
/ 4.0 / 4.0 / 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. //---------------------------------------------------------------------------- // //// 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
- ObjectViewListener.cs
- ResourceKey.cs
- SqlUtil.cs
- hebrewshape.cs
- BitmapVisualManager.cs
- PartitionResolver.cs
- CompoundFileStreamReference.cs
- ObjectQuery_EntitySqlExtensions.cs
- ValueSerializer.cs
- AliasGenerator.cs
- RichTextBox.cs
- Error.cs
- DesignTimeTemplateParser.cs
- SamlSerializer.cs
- Ppl.cs
- SqlConnectionFactory.cs
- TextBox.cs
- ToolStripSeparatorRenderEventArgs.cs
- InkCanvasAutomationPeer.cs
- GridViewColumnHeaderAutomationPeer.cs
- BindingFormattingDialog.cs
- Base64Encoder.cs
- RepeaterItemEventArgs.cs
- LeftCellWrapper.cs
- ItemChangedEventArgs.cs
- WinFormsUtils.cs
- LoadMessageLogger.cs
- SizeAnimationClockResource.cs
- FontDialog.cs
- PropertyAccessVisitor.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- XPathParser.cs
- EdmProperty.cs
- XmlConvert.cs
- WorkflowOwnerAsyncResult.cs
- RelationHandler.cs
- CompletedAsyncResult.cs
- _ListenerRequestStream.cs
- SelectionGlyphBase.cs
- TypeHelper.cs
- ObjectSet.cs
- CommonGetThemePartSize.cs
- TypeContext.cs
- LabelLiteral.cs
- PageAsyncTaskManager.cs
- Query.cs
- GraphicsContainer.cs
- ImageAutomationPeer.cs
- WindowsSolidBrush.cs
- MembershipSection.cs
- OutputCacheSettings.cs
- PeerContact.cs
- TypeHelper.cs
- StyleSheet.cs
- OdbcReferenceCollection.cs
- ResXFileRef.cs
- CardSpaceSelector.cs
- Int32Animation.cs
- Panel.cs
- SafeFindHandle.cs
- TransformerTypeCollection.cs
- ConfigurationSectionGroup.cs
- LinkConverter.cs
- _LazyAsyncResult.cs
- DataExpression.cs
- TextFormatterHost.cs
- HttpRuntimeSection.cs
- ServicePointManager.cs
- WebPartsSection.cs
- CustomValidator.cs
- Slider.cs
- ProfileSection.cs
- DbConnectionPool.cs
- SelectionHighlightInfo.cs
- TypeConverter.cs
- VariableExpressionConverter.cs
- DragDropManager.cs
- ServiceDescriptions.cs
- EntityDataSourceWrapper.cs
- AssemblyInfo.cs
- TypeDescriptor.cs
- XmlCodeExporter.cs
- HtmlContainerControl.cs
- dsa.cs
- IEnumerable.cs
- DataServiceProviderMethods.cs
- LinearKeyFrames.cs
- DeobfuscatingStream.cs
- InputBinding.cs
- DbProviderManifest.cs
- Binding.cs
- baseaxisquery.cs
- Calendar.cs
- Operand.cs
- MdImport.cs
- DbConnectionFactory.cs
- SQLResource.cs
- SchemaNotation.cs
- EventListener.cs
- SweepDirectionValidation.cs