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
- DuplexChannelFactory.cs
- AttachmentService.cs
- FieldToken.cs
- SeekStoryboard.cs
- PopupRootAutomationPeer.cs
- StrokeNodeOperations.cs
- Int32CollectionValueSerializer.cs
- DataServiceQueryProvider.cs
- HierarchicalDataSourceControl.cs
- ListControlConvertEventArgs.cs
- PreProcessor.cs
- SimpleHandlerBuildProvider.cs
- HtmlPhoneCallAdapter.cs
- PersonalizationDictionary.cs
- ProfileService.cs
- FastEncoderStatics.cs
- SqlAliaser.cs
- DriveInfo.cs
- TraceFilter.cs
- EventListenerClientSide.cs
- VariableBinder.cs
- ChangeTracker.cs
- OverflowException.cs
- Span.cs
- TypeLibConverter.cs
- ConnectionInterfaceCollection.cs
- FlatButtonAppearance.cs
- ModuleBuilder.cs
- ChannelReliableSession.cs
- SafeHandle.cs
- SafePEFileHandle.cs
- ScanQueryOperator.cs
- XPathDocumentNavigator.cs
- CopyNamespacesAction.cs
- FieldBuilder.cs
- SQLMoney.cs
- LoginDesignerUtil.cs
- CodeTypeConstructor.cs
- DocumentGridPage.cs
- MarginCollapsingState.cs
- ListViewGroupItemCollection.cs
- XsltLoader.cs
- PackagingUtilities.cs
- DrawingAttributes.cs
- CachedBitmap.cs
- ConfigurationStrings.cs
- XmlWriter.cs
- ColorComboBox.cs
- WindowsToolbarItemAsMenuItem.cs
- LinkArea.cs
- SpotLight.cs
- _AcceptOverlappedAsyncResult.cs
- Transform3D.cs
- DockPattern.cs
- WeakReferenceList.cs
- GroupByExpressionRewriter.cs
- State.cs
- TextEditorContextMenu.cs
- HtmlLinkAdapter.cs
- PassportPrincipal.cs
- SiteMembershipCondition.cs
- DataListDesigner.cs
- CfgRule.cs
- DbMetaDataCollectionNames.cs
- WindowsClaimSet.cs
- ListView.cs
- HtmlToClrEventProxy.cs
- ControlPaint.cs
- EpmSyndicationContentSerializer.cs
- CommonDialog.cs
- PeerInvitationResponse.cs
- UnsafeCollabNativeMethods.cs
- FormViewDeletedEventArgs.cs
- WebPartCloseVerb.cs
- DbConnectionPool.cs
- ZoneIdentityPermission.cs
- HtmlInputImage.cs
- BamlRecordHelper.cs
- XappLauncher.cs
- MediaCommands.cs
- SourceFileBuildProvider.cs
- ResourceDisplayNameAttribute.cs
- MultiBindingExpression.cs
- ConfigXmlReader.cs
- StrokeCollection2.cs
- PropertyValueUIItem.cs
- OutputWindow.cs
- TextDecorationCollection.cs
- PageVisual.cs
- XmlElement.cs
- SamlAssertionKeyIdentifierClause.cs
- QuotedStringFormatReader.cs
- StickyNoteAnnotations.cs
- ExtendedProperty.cs
- TaskFactory.cs
- ScrollChrome.cs
- TemplateBuilder.cs
- TypedRowHandler.cs
- COM2ExtendedBrowsingHandler.cs
- AutomationPatternInfo.cs