Code:
                         / 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / BuildTasks / Microsoft / Build / Tasks / Windows / GetWinFXPath.cs / 1305600 / GetWinFXPath.cs
                        
                        
                             
//----------------------------------------------------------------------------
//
// 
//    Copyright (C) Microsoft Corporation.  All rights reserved. 
//  
// 
// Description: Return the path for current WinFX runtime. 
//
// 
// History:
//  11/16/2005 weibz   Created
//
//--------------------------------------------------------------------------- 
using System; 
using System.IO; 
using System.Collections;
 
using System.Globalization;
using System.Diagnostics;
using System.Reflection;
using System.Resources; 
using System.Runtime.InteropServices;
 
 
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities; 
using MS.Utility;
using MS.Internal.Tasks;
 
// Since we disable PreSharp warnings in this file, PreSharp warning is unknown to C# compiler.
// We first need to disable warnings about unknown message numbers and unknown pragmas. 
#pragma warning disable 1634, 1691 
namespace Microsoft.Build.Tasks.Windows 
{
    #region GetWinFXPath Task class
    ///  
    /// Return the directory of current WinFX run time.
    ///   
    public sealed class GetWinFXPath : Task 
    {
        //----------------------------------------------------- 
        //
        //  Constructors
        //
        //----------------------------------------------------- 
        #region Constructors 
 
        /// 
        /// Constrcutor 
        ///  
        public GetWinFXPath()
            : base(SR.ResourceManager)
        { 
        } 
 
        #endregion Constructors
 
        //------------------------------------------------------
        //
        //  Public Methods
        // 
        //-----------------------------------------------------
 
        #region Public Methods 
        ///  
        /// ITask Execute method
        ///  
        ///  
        /// The path for native WinFX runtime.
        ///  
        [Required]
        public string WinFXNativePath 
        {
            get { return _winFXNativePath; } 
            set { _winFXNativePath = value; } 
        }
 
        /// 
        /// The path for WoW WinFX run time.
        ///  
        [Required] 
        public string WinFXWowPath
        { 
            get { return _winFXWowPath; } 
            set { _winFXWowPath = value; }
        } 
        /// 
        /// The real path for the WinFX runtime
        ///   
        [Output]
        public string WinFXPath 
        { 
            get { return _winFXPath;  }
            set { _winFXPath = value; } 
        }
        #endregion Public Properties
 
        //----------------------------------------------------- 
        // 
        //  Private Methods
        // 
        //------------------------------------------------------
        #region Private Methods
 
        // PInvoke delegate for IsWow64Process
        [UnmanagedFunctionPointer(CallingConvention.Winapi)] 
        private delegate bool IsWow64ProcessDelegate([In] IntPtr hProcess, [Out] out bool Wow64Process); 
        [DllImport(Kernel32Dll, PreserveSig = true, CharSet = CharSet.Unicode)] 
        private static extern IntPtr LoadLibrary(string fileName);
        [DllImport(Kernel32Dll, PreserveSig = true)]
        private static extern bool FreeLibrary([In] IntPtr module); 
        [DllImport(Kernel32Dll, PreserveSig = true, CharSet = CharSet.Unicode)] 
        private static extern IntPtr GetProcAddress(IntPtr module, string procName); 
        [DllImport(Kernel32Dll, PreserveSig = true)] 
        private static extern IntPtr GetCurrentProcess();
        // 
        // Detect if the msbuild is running under WOW64 environment. 
        //  
        static private bool IsWow64CLRRun() 
        { 
            bool isWow64 = false;
            IntPtr NullIntPtr = new IntPtr(0); 
            IntPtr kernel32Dll = LoadLibrary(Kernel32Dll);
            if (kernel32Dll != NullIntPtr) 
            {
                try 
                { 
                    IntPtr isWow64ProcessHandle = GetProcAddress(kernel32Dll, IsWow64ProcessMethodName);
 
                    // if the entry point is missing, it cannot be Wow64
                    if (isWow64ProcessHandle != NullIntPtr)
                    {
                        // entry point present, check if running in WOW64 
                        IsWow64ProcessDelegate isWow64Process = (IsWow64ProcessDelegate)Marshal.GetDelegateForFunctionPointer(isWow64ProcessHandle, typeof(IsWow64ProcessDelegate));
                        isWow64Process(GetCurrentProcess(), out isWow64); 
                    } 
                }
                finally 
                {
                    FreeLibrary(kernel32Dll);
                }
            } 
            return isWow64; 
        } 
 
        #endregion Private Methods
        //-----------------------------------------------------
        // 
        //  Private Properties
        // 
        //----------------------------------------------------- 
 
        //-----------------------------------------------------
        //
        //  Private Fields
        // 
        //------------------------------------------------------
 
        #region Private Fields 
        private string _winFXNativePath = string.Empty; 
        private string _winFXWowPath = string.Empty;
        private string _winFXPath = string.Empty;
        private const string UnknownErrorID = "FX1000"; 
        private const string Kernel32Dll = "kernel32.dll"; 
        private const string IsWow64ProcessMethodName = "IsWow64Process"; 
        #endregion Private Fields 
    }
    #endregion GetWinFXPath Task class 
}
// 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
- NextPreviousPagerField.cs
- SHA256.cs
- BackgroundFormatInfo.cs
- RbTree.cs
- XhtmlStyleClass.cs
- SqlReferenceCollection.cs
- LicFileLicenseProvider.cs
- OdbcCommand.cs
- BaseTemplateCodeDomTreeGenerator.cs
- Visual3D.cs
- CngKey.cs
- JsonReader.cs
- XPathMessageContext.cs
- KernelTypeValidation.cs
- EntityDataSource.cs
- hebrewshape.cs
- TransportManager.cs
- FormsAuthenticationModule.cs
- InheritedPropertyChangedEventArgs.cs
- FormViewDeletedEventArgs.cs
- Attributes.cs
- SecurityElementBase.cs
- X509Chain.cs
- DialogDivider.cs
- FilterException.cs
- DataGridRelationshipRow.cs
- MouseDevice.cs
- ContainerParagraph.cs
- RegionData.cs
- ProfileInfo.cs
- CustomWebEventKey.cs
- OpCodes.cs
- Repeater.cs
- CfgParser.cs
- UserControlFileEditor.cs
- QueryCacheKey.cs
- ConditionalBranch.cs
- RectValueSerializer.cs
- TemplateControlCodeDomTreeGenerator.cs
- WebPartZoneCollection.cs
- HttpBufferlessInputStream.cs
- ResXResourceReader.cs
- cookiecontainer.cs
- SqlDataSourceSelectingEventArgs.cs
- EmptyCollection.cs
- DragStartedEventArgs.cs
- ScrollContentPresenter.cs
- keycontainerpermission.cs
- TypeToken.cs
- EmptyReadOnlyDictionaryInternal.cs
- ClockGroup.cs
- DataServiceQueryProvider.cs
- StringToken.cs
- DeploymentSection.cs
- FamilyCollection.cs
- Rule.cs
- TextStore.cs
- X509SecurityToken.cs
- HttpCapabilitiesSectionHandler.cs
- CallTemplateAction.cs
- RelationshipEndMember.cs
- ClientRuntimeConfig.cs
- DynamicObject.cs
- TemplateBindingExtension.cs
- ImmutableCollection.cs
- UpdatePanel.cs
- NativeMethods.cs
- PropertyMetadata.cs
- CreateDataSourceDialog.cs
- MouseDevice.cs
- UTF32Encoding.cs
- TimeSpan.cs
- ITreeGenerator.cs
- ActivityDelegate.cs
- LogoValidationException.cs
- PropertyHelper.cs
- DataGridViewSortCompareEventArgs.cs
- DataGridViewDataErrorEventArgs.cs
- TrackingMemoryStream.cs
- Grid.cs
- WindowsRegion.cs
- TreeNodeEventArgs.cs
- HtmlUtf8RawTextWriter.cs
- ResourceCategoryAttribute.cs
- UserControlCodeDomTreeGenerator.cs
- XmlNodeReader.cs
- RangeBaseAutomationPeer.cs
- BridgeDataReader.cs
- TextEndOfParagraph.cs
- DocumentPageTextView.cs
- AtomContentProperty.cs
- ExportException.cs
- SinglePhaseEnlistment.cs
- DataGridState.cs
- Compress.cs
- Command.cs
- ProcessModuleCollection.cs
- SessionEndingCancelEventArgs.cs
- ListDictionary.cs
- ClientSection.cs