コード例 #1
0
        string GetSpecialDirectory(CSIDL specialFolder)
        {
            var path = new StringBuilder(260);

            SHGetSpecialFolderPath(IntPtr.Zero, path, (int)specialFolder, false);
            return(path.ToString());
        }
コード例 #2
0
        public static string GetEnvironmentPath(CSIDL target)
        {
            var path = new StringBuilder(260);

            NativeMethods.SHGetSpecialFolderPath(IntPtr.Zero, path, (int)target, false);
            return(path.ToString());
        }
コード例 #3
0
ファイル: PathSanitizer.cs プロジェクト: jwg4/gtools
        private static string GetDirectory(CSIDL folder)
        {
            StringBuilder path = new StringBuilder(260);

            SHGetSpecialFolderPath(IntPtr.Zero, path, folder, false);
            return(path.ToString());
        }
コード例 #4
0
ファイル: NativeMethods.cs プロジェクト: dxc31202/ZXStudio
 public static extern Int32 SHGetFolderLocation(
     IntPtr hwndOwner,
     CSIDL nFolder,
     IntPtr hToken,
     UInt32 dwReserved,
     out IntPtr ppidl
     );
コード例 #5
0
ファイル: Win32.cs プロジェクト: nithinphilips/SMOz
        public static string GetFolderPath(CSIDL specialFolder)
        {
            StringBuilder resultPath = new StringBuilder(255);

            SHGetSpecialFolderPath((IntPtr)0, resultPath, (int)specialFolder, true);
            return(resultPath.ToString());
        }
コード例 #6
0
        /*
         *      [DllImport("shell32.dll")]
         *      public static extern int SHGetIDListFromObject([MarshalAs(UnmanagedType.IUnknown)] object punk, out IntPtr ppidl);
         */

        #region Register Functions


        /// <summary>
        /// Register a form handle
        /// This form will receive a WM_SHNOTIFY when a notification occures
        ///
        /// !!!!! Add this code to your registered form : !!!!!
        /// protected override void WndProc(ref Message m)
        /// {
        ///		switch(m.Msg)
        ///		{
        ///			case (int) ShellNotifications.WM_SHNOTIFY:
        ///			if(Notifications.NotificationReceipt(m.WParam, m.LParam))
        ///				NewOperation((NotifyInfos) Notifications.NotificationsReceived[Notifications.NotificationsReceived.Count-1]);
        ///			break;
        ///		}
        ///		base.WndProc(ref m);
        /// }
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="item">ID of the special folder</param>
        /// <param name="Recursively">Look recursively at modifications</param>
        /// <returns></returns>
        public ulong RegisterChangeNotify(IntPtr hWnd, CSIDL item, bool Recursively)
        {
            if (notifyid != 0)
            {
                return(0);
            }
            SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry()
            {
                pIdl = GetPidlFromFolderID(hWnd, item), Recursively = Recursively
            };

            SHChangeNotifyEntry[] changenetrys = new SHChangeNotifyEntry[1] {
                changeentry
            };
            //changenetrys[0] = changeentry;
            notifyid = SHChangeNotifyRegister(
                hWnd,
                //SHCNF.SHCNF_TYPE | SHCNF.SHCNF_IDLIST,
                (SHCNRF)0x00FF | (SHCNRF)0x0000 | SHCNRF.NewDelivery,
                SHCNE.SHCNE_ALLEVENTS | SHCNE.SHCNE_INTERRUPT,
                WM_SHNOTIFY,
                1,
                changenetrys);
            return(notifyid);
        }
コード例 #7
0
        public static string GetSpecialFolderPath(CSIDL id)
        {
            string path = string.Empty;

            SHGetSpecialFolderPath((IntPtr)0, ref path, id, false);
            return(path);
        }
コード例 #8
0
ファイル: Shell32.Helpers.cs プロジェクト: jmelosegui/pinvoke
        public static unsafe string SHGetFolderPath(CSIDL folder, IntPtr hToken = default(IntPtr), SHGetFolderPathFlags flags = SHGetFolderPathFlags.SHGFP_TYPE_CURRENT)
        {
            char* pszPath = stackalloc char[Kernel32.MAX_PATH + 1];
#pragma warning disable CS0618 // Type or member is obsolete
            SHGetFolderPath(IntPtr.Zero, folder, hToken, flags, pszPath).ThrowOnFailure();
#pragma warning restore CS0618 // Type or member is obsolete

            return new string(pszPath);
        }
コード例 #9
0
        private static KnownFolder CreateFolder(CSIDL csidl, string name)
        {
            var path = new StringBuilder(512);

            if (Shell32.SHGetFolderPath(IntPtr.Zero, csidl, IntPtr.Zero, 0, path) == HResult.S_OK)
            {
                return(new KnownFolder(csidl, name, path.ToString()));
            }
            return(new KnownFolder(csidl, name, string.Empty));
        }
コード例 #10
0
        public static unsafe string SHGetFolderPath(CSIDL folder, IntPtr hToken = default(IntPtr), SHGetFolderPathFlags flags = SHGetFolderPathFlags.SHGFP_TYPE_CURRENT)
        {
            char *pszPath = stackalloc char[Kernel32.MAX_PATH + 1];

#pragma warning disable CS0618 // Type or member is obsolete
            SHGetFolderPath(IntPtr.Zero, folder, hToken, flags, pszPath).ThrowOnFailure();
#pragma warning restore CS0618 // Type or member is obsolete

            return(new string(pszPath));
        }
コード例 #11
0
#pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
        public static unsafe string SHGetFolderPath(CSIDL folder, IntPtr hToken = default(IntPtr), SHGetFolderPathFlags flags = SHGetFolderPathFlags.SHGFP_TYPE_CURRENT)
#pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
        {
            char *pszPath = stackalloc char[Kernel32.MAX_PATH + 1];

#pragma warning disable CS0618 // Type or member is obsolete
            SHGetFolderPath(IntPtr.Zero, folder, hToken, flags, pszPath).ThrowOnFailure();
#pragma warning restore CS0618 // Type or member is obsolete

            return(new string(pszPath));
        }
コード例 #12
0
ファイル: ShNotifyManager.cs プロジェクト: Suzumebati/RecMove
        /// <summary>
        /// 該当フォルダのpIdlを取得する
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        private static IntPtr GetPidlFromFolderID(IntPtr hWnd, CSIDL id)
        {
            IntPtr pIdl = IntPtr.Zero;
            SHGetFolderLocationReturnValues res = (SHGetFolderLocationReturnValues)
                                                  SHGetSpecialFolderLocation(
                hWnd,
                id,
                out pIdl);

            return(pIdl);
        }
コード例 #13
0
        void AddFolder(string name, CSIDL csidl)
        {
            KnownFolder folder = CreateFolder(csidl, name);

            m_NameIndex.Add(folder.Name, folder);

            if (folder.ParsingName != string.Empty)
            {
                m_PathIndex.Add(folder.ParsingName, folder);
            }
        }
コード例 #14
0
        private void AddFolder(string name, CSIDL csidl)
        {
            var folder = CreateFolder(csidl, name);

            _mNameIndex.Add(folder.Name, folder);

            if (folder.ParsingName != string.Empty)
            {
                _mPathIndex.Add(folder.ParsingName, folder);
            }
        }
コード例 #15
0
ファイル: sendto.cs プロジェクト: dahall/WinClassicSamplesCS
 /*****************************************************************************
 *
 * GetSpecialFolder
 *
 * Create an IShellFolder for the specified special folder.
 *
 * It is the responsibility of the caller to Release() the
 * IShellFolder that is returned.
 *
 *****************************************************************************/
 static IShellFolder GetSpecialFolder(HWND hwnd, CSIDL idFolder)
 {
     if (SHGetFolderLocation(hwnd, idFolder, ppidl: out var pidl).Succeeded)
     {
         using (pidl)
             if (g_psfDesktop.BindToObject(pidl, default, typeof(IShellFolder).GUID, out var ppv).Succeeded)
             {
                 return((IShellFolder)ppv);
             }
     }
     return(null);
 }
コード例 #16
0
 private static IEnumerable <string> GetLnkFilesSafe(CSIDL directory, SearchOption option)
 {
     try
     {
         return(Directory.GetFiles(WindowsTools.GetEnvironmentPath(directory), "*.lnk", option));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         Debug.Fail(ex.ToString());
     }
     return(Enumerable.Empty <string>());
 }
コード例 #17
0
        public static string GetSpecialFolderLocation(CSIDL folderCode)
        {
            IntPtr pidl = Marshal.AllocHGlobal(1024);

            SHGetSpecialFolderLocation(pidl, folderCode, ref pidl);
            System.Text.StringBuilder path = new System.Text.StringBuilder(260);
            bool result = SHGetPathFromIDListW(pidl, path);

            Marshal.FreeHGlobal(pidl);
            if (result == false)
            {
                throw new ArgumentException();
            }
            return(path.ToString().TrimEnd(char.MinValue));
        }
コード例 #18
0
    public static string SHGetFolderPath(CSIDL folder)
    {
        string result = null;

        System.IntPtr p = Marshal.AllocHGlobal(2 * (MAX_PATH + 1));
        try {
            if (0 == Win32.SHGetFolderPath(System.IntPtr.Zero, (int)folder, 0, 0, p))
            {
                result = Marshal.PtrToStringUni(p);
            }
        } finally {
            Marshal.FreeHGlobal(p);
        }
        return(result);
    }
コード例 #19
0
ファイル: Win32API.cs プロジェクト: uxDesign/AtmoLight
        public static string GetSpecialFolder(CSIDL nFolder)
        {
            IntPtr ptrAppData = IntPtr.Zero;

            SHGetSpecialFolderLocation(IntPtr.Zero, nFolder, ref ptrAppData);
            string        dirAppData = "";
            StringBuilder sbAppData  = new StringBuilder(MAX_PATH);

            if (true == SHGetPathFromIDListW(ptrAppData, sbAppData))
            {
                dirAppData = sbAppData.ToString();
            }

            sbAppData = null;
            Marshal.FreeCoTaskMem(ptrAppData);
            return(dirAppData);
        }
コード例 #20
0
ファイル: ShNotifyManager.cs プロジェクト: Suzumebati/RecMove
        /// <summary>
        /// シェルのチェンジイベント受付を登録する
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="folderID"></param>
        /// <param name="recursively"></param>
        /// <returns></returns>
        public ulong RegisterChangeNotify(IntPtr hWnd, CSIDL folderID, bool recursively)
        {
            if (notifyid != 0)
            {
                return(0);
            }
            SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry();

            changeentry.pIdl        = GetPidlFromFolderID(hWnd, folderID);
            changeentry.Recursively = recursively;
            notifyid = SHChangeNotifyRegister(
                hWnd,
                SHCNF.SHCNF_TYPE | SHCNF.SHCNF_IDLIST,
                SHCNE.SHCNE_ALLEVENTS | SHCNE.SHCNE_INTERRUPT,
                (int)WM.WM_SHNOTIFY,
                1,
                ref changeentry);
            return(notifyid);
        }
コード例 #21
0
        /// <summary>
        /// Register a form handle
        /// This form will receive a WM_SHNOTIFY when a notification occures
        ///
        /// !!!!! Add this code to your registered form : !!!!!
        /// protected override void WndProc(ref Message m)
        /// {
        ///		switch(m.Msg)
        ///		{
        ///			case (int) ShellNotifications.WM_SHNOTIFY:
        ///			if(Notifications.NotificationReceipt(m.WParam, m.LParam))
        ///				NewOperation((NotifyInfos) Notifications.NotificationsReceived[Notifications.NotificationsReceived.Count-1]);
        ///			break;
        ///		}
        ///		base.WndProc(ref m);
        /// }
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="FolderID">Root folder of the 'spy' (CSIDL_DESKTOP vor example)</param>
        /// <param name="Recursively">Look recursively at modifications</param>
        /// <returns></returns>
        public ulong RegisterChangeNotify(IntPtr hWnd, CSIDL FolderID, bool Recursively)
        {
            if (notifyid != 0)
            {
                return(0);
            }
            SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry();
            IntPtr ppidl = IntPtr.Zero;

            ppidl                   = GetPidlFromFolderID(hWnd, FolderID);
            changeentry.pIdl        = ppidl;
            changeentry.Recursively = Recursively;
            notifyid                = SHChangeNotifyRegister(
                hWnd,
                SHCNRF.InterruptLevel | SHCNRF.ShellLevel,
                SHCNE.SHCNE_ALLEVENTS,
                WM_SHNOTIFY,
                1,
                ref changeentry);
            return(notifyid);
        }
コード例 #22
0
        /// <summary>
        /// Register a form handle
        /// This form will receive a WM_SHNOTIFY when a notification occures
        ///
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="folderID">Root folder of the 'spy' (CSIDL_DESKTOP vor example)</param>
        /// <param name="recursively">Look recursively at modifications</param>
        /// <returns></returns>
        public ulong RegisterChangeNotify(IntPtr hWnd, CSIDL folderID, bool recursively)
        {
            if (_notifyid != 0)
            {
                return(0);
            }

            SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry();

            changeentry.pIdl        = GetPidlFromFolderID(hWnd, folderID);
            changeentry.Recursively = recursively;

            _notifyid = SHChangeNotifyRegister(
                hWnd,
                SHCNF.SHCNF_TYPE | SHCNF.SHCNF_IDLIST,
                //SHCNE.SHCNE_ALLEVENTS | SHCNE.SHCNE_INTERRUPT,
                SHCNE.SHCNE_MEDIAINSERTED | SHCNE.SHCNE_MEDIAREMOVED,
                WmShnotify,
                1,
                ref changeentry);
            return(_notifyid);
        }
コード例 #23
0
        /// <summary>
        /// Register a form handle
        /// This form will receive a WM_SHNOTIFY when a notification occures
        ///
        /// !!!!! Add this code to your registered form : !!!!!
        /// protected override void WndProc(ref Message m)
        /// {
        ///		switch(m.Msg)
        ///		{
        ///			case (int) ShellNotifications.WM_SHNOTIFY:
        ///			if(Notifications.NotificationReceipt(m.WParam, m.LParam))
        ///				NewOperation((NotifyInfos) Notifications.NotificationsReceived[Notifications.NotificationsReceived.Count-1]);
        ///			break;
        ///		}
        ///		base.WndProc(ref m);
        /// }
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="item">ID of the special folder</param>
        /// <param name="recursively">Look recursively at modifications</param>
        /// <returns></returns>
        public ulong RegisterChangeNotify(IntPtr hWnd, CSIDL item, bool recursively)
        {
            if (this.notifyid != 0)
            {
                return(0);
            }

            SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry()
            {
                pIdl = GetPidlFromFolderID(hWnd, item), Recursively = recursively
            };

            SHChangeNotifyEntry[] changenetrys = new SHChangeNotifyEntry[1] {
                changeentry
            };
            this.notifyid = SHChangeNotifyRegister(
                hWnd,
                SHCNRF.ShellLevel | SHCNRF.InterruptLevel | SHCNRF.NewDelivery,
                SHCNE.SHCNE_ALLEVENTS | SHCNE.SHCNE_INTERRUPT,
                WM_SHNOTIFY,
                1,
                changenetrys);
            return(this.notifyid);
        }
コード例 #24
0
ファイル: Shell32.cs プロジェクト: vatsan-madhavan/pinvoke
 public static extern unsafe HResult SHGetFolderLocation(
     IntPtr hwndOwner,
     CSIDL nFolder,
     IntPtr hToken,
     int dwReserved,
     out ITEMIDLIST *pidl);
コード例 #25
0
ファイル: Shell32.cs プロジェクト: vatsan-madhavan/pinvoke
 public static extern unsafe HResult SHGetFolderPath(
     IntPtr hwndOwner,
     CSIDL nFolder,
     IntPtr hToken,
     SHGetFolderPathFlags dwFlags,
     [Friendly(FriendlyFlags.Array)] char *pszPath);
コード例 #26
0
 public static extern Int32 SHGetFolderPath(IntPtr hwndOwner, CSIDL nFolder, IntPtr hToken, SHGFP dwFlags, StringBuilder pszPath);
コード例 #27
0
ファイル: Shell32.cs プロジェクト: huipengly/WGestures
 public static string GetSpecialFolderPath(CSIDL id)
 {
     string path = string.Empty;
     SHGetSpecialFolderPath((IntPtr)0, ref path, id, false);
     return path;
 }
コード例 #28
0
 public PathIndexEntry(string name, CSIDL csidl)
 {
     Name  = name;
     Csidl = csidl;
 }
コード例 #29
0
ファイル: ShellApi.cs プロジェクト: parhelia512/ikvm-1
 public static extern Int32 SHGetSpecialFolderLocation(IntPtr hwndOwner, CSIDL nFolder, ref IntPtr ppidl);
コード例 #30
0
    /// <summary>
    /// Register a form handle
    /// This form will receive a WM_SHNOTIFY when a notification occures
    /// 
    /// </summary>
    /// <param name="hWnd"></param>
    /// <param name="folderID">Root folder of the 'spy' (CSIDL_DESKTOP vor example)</param>
    /// <param name="recursively">Look recursively at modifications</param>
    /// <returns></returns>
    public ulong RegisterChangeNotify(IntPtr hWnd, CSIDL folderID, bool recursively)
    {
      if (_notifyid != 0)
      {
        return (0);
      }
      
      SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry();
      changeentry.pIdl = GetPidlFromFolderID(hWnd, folderID);
      changeentry.Recursively = recursively;

      _notifyid = SHChangeNotifyRegister(
        hWnd,
        SHCNF.SHCNF_TYPE | SHCNF.SHCNF_IDLIST,
        //SHCNE.SHCNE_ALLEVENTS | SHCNE.SHCNE_INTERRUPT,
        SHCNE.SHCNE_MEDIAINSERTED | SHCNE.SHCNE_MEDIAREMOVED,
        WmShnotify,
        1,
        ref changeentry);
      return (_notifyid);
    }
コード例 #31
0
 private static extern uint SHGetSpecialFolderLocation(
     IntPtr hWnd,
     CSIDL nFolder,
     out IntPtr Pidl);
コード例 #32
0
        /// <summary>
        /// Force explorer window to update a location
        /// </summary>
        /// <param name="specialItemID"></param>
        internal static void RefreshSpecialItem( CSIDL specialItemID )
        {
            try
            {

                IntPtr pidl = IntPtr.Zero;

                if ( SHGetSpecialFolderLocation( IntPtr.Zero, specialItemID, ref pidl ) == 0 )
                    SHChangeNotify( HChangeNotifyEventID.SHCNE_ALLEVENTS, HChangeNotifyFlags.SHCNF_IDLIST | HChangeNotifyFlags.SHCNF_FLUSH, pidl, IntPtr.Zero );

            }
            catch ( Exception )
            {
            }
        }
コード例 #33
0
 public static extern int SHGetSpecialFolderLocation( IntPtr hwndOwner, CSIDL nFolder, ref IntPtr ppidl );
コード例 #34
0
 //*
 //* Displays a dialog that allows the user select a file, starting from a specified CSIDL.
 //*
 public string BrowseForFiles( CSIDL StartLocation)
 {
     SHGetSpecialFolderLocation(stcBrowseInfo.hOwner, (int)StartLocation, ref stcBrowseInfo.pidlRoot);
     stcBrowseInfo.ulFlags = BIF_BROWSEINCLUDEFILES;
     return DoBrowse("");
 }
コード例 #35
0
        /// <summary>
        /// Gets the specified special folder. This includes folders not normally available within Environment.SpecialFolders.
        /// </summary>
        /// <param name="folder">The folder to get.</param>
        /// <returns>The file path.</returns>
        public static string GetSpecialFolder(CSIDL folder)
        {
            StringBuilder path = new StringBuilder(" ", 500);

            int ret = Win32Services.SHGetSpecialFolderPath(IntPtr.Zero, path, (int)folder, false);

            if (ret == 0)
            {
                Debug.WriteLine(Marshal.GetLastWin32Error());
                return String.Empty;
            }
            else
            {
                return path.ToString();
            }
        }
コード例 #36
0
ファイル: WinApi.cs プロジェクト: SayHalou/ospy
 public static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, StringBuilder lpszPath, CSIDL nFolder, bool fCreate);
コード例 #37
0
        /*
		[DllImport("shell32.dll")]
		public static extern int SHGetIDListFromObject([MarshalAs(UnmanagedType.IUnknown)] object punk, out IntPtr ppidl);
		*/

        #region Register Functions


        /// <summary>
        /// Register a form handle
        /// This form will receive a WM_SHNOTIFY when a notification occures
        /// 
        /// !!!!! Add this code to your registered form : !!!!!
        /// protected override void WndProc(ref Message m)
        /// {
        ///		switch(m.Msg)
        ///		{
        ///			case (int) ShellNotifications.WM_SHNOTIFY:
        ///			if(Notifications.NotificationReceipt(m.WParam, m.LParam))
        ///				NewOperation((NotifyInfos) Notifications.NotificationsReceived[Notifications.NotificationsReceived.Count-1]);
        ///			break;
        ///		}
        ///		base.WndProc(ref m);
        /// }
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="item">ID of the special folder</param>
        /// <param name="Recursively">Look recursively at modifications</param>
        /// <returns></returns>
        public ulong RegisterChangeNotify(IntPtr hWnd, CSIDL item, bool Recursively)
        {
            if (notifyid != 0) return (0);
            SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry() { pIdl = GetPidlFromFolderID(hWnd, item), Recursively = Recursively };
            SHChangeNotifyEntry[] changenetrys = new SHChangeNotifyEntry[1] { changeentry };
            //changenetrys[0] = changeentry;
            notifyid = SHChangeNotifyRegister(
                hWnd,
        //SHCNF.SHCNF_TYPE | SHCNF.SHCNF_IDLIST,
        (SHCNRF)0x00FF | (SHCNRF)0x0000 | SHCNRF.NewDelivery,
        SHCNE.SHCNE_ALLEVENTS | SHCNE.SHCNE_INTERRUPT,
                WM_SHNOTIFY,
                1,
                changenetrys);
            return (notifyid);
        }
コード例 #38
0
ファイル: Shell32.cs プロジェクト: jmelosegui/pinvoke
 public static extern unsafe HResult SHGetFolderPath(
     IntPtr hwndOwner,
     CSIDL nFolder,
     IntPtr hToken,
     SHGetFolderPathFlags dwFlags,
     [Friendly(FriendlyFlags.Array)] char* pszPath);
コード例 #39
0
        ///// <summary>
        ///// Get the path from a Pidl value
        ///// </summary>
        ///// <param name="Pidl">Pidl of the path</param>
        ///// <returns>Path</returns>
        //public static string GetPathFromPidl(IntPtr Pidl) {
        //	string Path = new String('\0', MAX_PATH);
        //	return (SHGetPathFromIDList(Pidl, Path) ? Path.ToString().TrimEnd('\0') : "");
        //}

        ///// <summary>
        ///// Do not work
        ///// If someone has a solution please tell me ([email protected])
        ///// </summary>
        ///// <param name="Pidl"></param>
        ///// <returns></returns>
        //public static string GetDisplayNameFromPidl(IntPtr Pidl) {
        //	SHFILEINFO fileinfo = new SHFILEINFO(true);
        //	SHGetFileInfoA(
        //		(uint)Pidl,
        //		0,
        //		out fileinfo,
        //		(uint)Marshal.SizeOf(fileinfo),
        //		SHGFI.SHGFI_PIDL | SHGFI.SHGFI_DISPLAYNAME);
        //	return (fileinfo.szDisplayName);
        //}



        /// <summary>
        /// Get the Pidl from a special folder ID
        /// </summary>
        /// <param name="hWnd">Handle of the window</param>
        /// <param name="Id">ID of the special folder</param>
        /// <returns>Pidl of the special folder</returns>
        public static IntPtr GetPidlFromFolderID(IntPtr hWnd, CSIDL Id)
        {
            IntPtr pIdl = IntPtr.Zero;
            SHGetFolderLocationReturnValues res = (SHGetFolderLocationReturnValues)
                SHGetSpecialFolderLocation(
                hWnd,
                Id,
                out pIdl);
            return (pIdl);
        }
コード例 #40
0
ファイル: Win32.cs プロジェクト: nithinphilips/SMOz
	   public static string GetFolderPath(CSIDL specialFolder) {
		  StringBuilder resultPath = new StringBuilder(255);
		  SHGetSpecialFolderPath((IntPtr)0, resultPath, (int)specialFolder, true);
		  return resultPath.ToString();
	   }
コード例 #41
0
ファイル: PathSanitizer.cs プロジェクト: johnhk/pserv4
 private static string GetDirectory(CSIDL folder)
 {
     StringBuilder path = new StringBuilder(260);
     SHGetSpecialFolderPath(IntPtr.Zero, path, folder, false);
     return path.ToString();
 }
コード例 #42
0
ファイル: ShNotifyManager.cs プロジェクト: Suzumebati/RecMove
 private static extern uint SHGetSpecialFolderLocation(
     IntPtr hWnd,
     CSIDL nFolder,
     out IntPtr Pidl);
コード例 #43
0
 public KnownFolder(CSIDL csidl, string name, string parsingName)
 {
     m_Csidl       = csidl;
     m_Name        = name;
     m_ParsingName = parsingName;
 }
コード例 #44
0
 //*
 //* Displays a dialog that allows the user select a folder, starting from a specified CSIDL
 //*
 public string BrowseForFolder( CSIDL StartLocation)
 {
     SHGetSpecialFolderLocation(stcBrowseInfo.hOwner, (int)StartLocation, ref stcBrowseInfo.pidlRoot);
     stcBrowseInfo.ulFlags = BIF_RETURNONLYFSDIRS;
     return DoBrowse("");
 }
コード例 #45
0
 public static extern int SHGetSpecialFolderLocation(IntPtr handle, CSIDL nFolder, out IntPtr ppidl);
コード例 #46
0
ファイル: Win32API.cs プロジェクト: chli/AtmoLight
    public static string GetSpecialFolder(CSIDL nFolder)
    {
      IntPtr ptrAppData = IntPtr.Zero;
      SHGetSpecialFolderLocation(IntPtr.Zero, nFolder, ref ptrAppData);
      string dirAppData = "";
      StringBuilder sbAppData = new StringBuilder(MAX_PATH);

      if (true == SHGetPathFromIDListW(ptrAppData, sbAppData))
      {
        dirAppData = sbAppData.ToString();
      }

      sbAppData = null;
      Marshal.FreeCoTaskMem(ptrAppData);
      return dirAppData;
    }
コード例 #47
0
 public static extern Int32 SHGetSpecialFolderLocation(IntPtr hwndOwner, CSIDL nFolder, out IntPtr ppidl);
コード例 #48
0
ファイル: Shell32.cs プロジェクト: huipengly/WGestures
 public static extern int SHGetSpecialFolderPath(
     IntPtr hwndOwner, ref string lpszPath, CSIDL nFolder, bool fCreate);
コード例 #49
0
ファイル: Shell32.cs プロジェクト: jmelosegui/pinvoke
 public static extern unsafe HResult SHGetFolderLocation(
     IntPtr hwndOwner,
     CSIDL nFolder,
     IntPtr hToken,
     int dwReserved,
     out ITEMIDLIST* pidl);
コード例 #50
0
ファイル: ShellAPI.cs プロジェクト: renzhn/Wox
 public static extern int SHGetSpecialFolderLocation(IntPtr handle, CSIDL nFolder, out IntPtr ppidl);
コード例 #51
0
 public static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpszPath, CSIDL nFolder, [MarshalAs(UnmanagedType.Bool)] bool fCreate);
コード例 #52
0
ファイル: Shell32.cs プロジェクト: nhannd/Xian
		public static extern int SHGetFolderLocation(IntPtr hwndOwner, CSIDL nFolder, IntPtr hToken, uint dwReserved, out IntPtr ppidl);
コード例 #53
0
 public static extern int SHGetSpecialFolderLocation(IntPtr hWnd, CSIDL nFolder, out IntPtr Pidl);
コード例 #54
0
ファイル: WinApi.cs プロジェクト: wyrover/ospy
 public static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, StringBuilder lpszPath, CSIDL nFolder, bool fCreate);