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
- WasHttpHandlersInstallComponent.cs
- SerialErrors.cs
- ListBoxItem.cs
- PolyLineSegmentFigureLogic.cs
- CodeIterationStatement.cs
- Transform3DGroup.cs
- StoreAnnotationsMap.cs
- WebServiceBindingAttribute.cs
- TriggerCollection.cs
- TextWriterTraceListener.cs
- DifferencingCollection.cs
- QilExpression.cs
- SspiSafeHandles.cs
- DataGridAddNewRow.cs
- SocketElement.cs
- ObjectDataSourceChooseTypePanel.cs
- SoapProtocolReflector.cs
- _HeaderInfoTable.cs
- XhtmlStyleClass.cs
- WebBrowserBase.cs
- IOThreadTimer.cs
- HyperLinkField.cs
- ListViewInsertedEventArgs.cs
- CreatingCookieEventArgs.cs
- HttpHandlerActionCollection.cs
- SoapSchemaExporter.cs
- AnonymousIdentificationModule.cs
- PointIndependentAnimationStorage.cs
- DBPropSet.cs
- StreamGeometry.cs
- ExceptionNotification.cs
- ControlTemplate.cs
- DropTarget.cs
- SafeLibraryHandle.cs
- BitmapSourceSafeMILHandle.cs
- DataKey.cs
- XmlSchemaComplexType.cs
- DictionaryCustomTypeDescriptor.cs
- DbProviderManifest.cs
- PropertyGeneratedEventArgs.cs
- XsltOutput.cs
- ErasingStroke.cs
- MetadataAssemblyHelper.cs
- HierarchicalDataBoundControl.cs
- MailHeaderInfo.cs
- CodeMethodReturnStatement.cs
- SqlMethodAttribute.cs
- UIElementIsland.cs
- ComponentDispatcher.cs
- DataList.cs
- MonitoringDescriptionAttribute.cs
- BindingOperations.cs
- DataServiceException.cs
- Geometry.cs
- BStrWrapper.cs
- CorrelationScope.cs
- XmlDocumentType.cs
- ValidationVisibilityAttribute.cs
- ReceiveDesigner.xaml.cs
- XmlSchemaExporter.cs
- BamlResourceContent.cs
- EntityWrapper.cs
- RowsCopiedEventArgs.cs
- DesignerCalendarAdapter.cs
- DispatcherProcessingDisabled.cs
- ExpressionReplacer.cs
- SectionXmlInfo.cs
- ContextMenuStrip.cs
- PackageRelationshipCollection.cs
- CngAlgorithm.cs
- ChameleonKey.cs
- SchemaCollectionCompiler.cs
- SrgsSemanticInterpretationTag.cs
- DocumentPage.cs
- ControlBuilderAttribute.cs
- Page.cs
- HotCommands.cs
- TagPrefixCollection.cs
- MediaPlayerState.cs
- FixedSOMTableRow.cs
- GeneralTransform.cs
- TableChangeProcessor.cs
- PolicyUnit.cs
- ListItem.cs
- EventMappingSettingsCollection.cs
- CallTemplateAction.cs
- SourceExpressionException.cs
- ListParaClient.cs
- Splitter.cs
- WebResourceUtil.cs
- SoapEnumAttribute.cs
- MissingFieldException.cs
- TextRangeEdit.cs
- TypeTypeConverter.cs
- RewritingPass.cs
- PolicyUnit.cs
- XmlMessageFormatter.cs
- XmlSchemaChoice.cs
- DataSourceView.cs
- sqlinternaltransaction.cs