ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/AutomagicalMusicalSyncifier/AutomagicalMusicalSyncifier/Win32.cs
Revision: 461
Committed: 2005-05-30T05:22:53-07:00 (20 years ago) by douglas
File size: 2536 byte(s)
Log Message:
Guh!

File Contents

# Content
1 // Douglas Thrift
2 //
3 // Automagical Musical Syncifier
4 //
5 // $Id$
6
7 using System;
8 using System.Runtime.InteropServices;
9 using System.Text;
10
11 public static class Win32
12 {
13 [Flags]
14 public enum CSIDL : int { MYMUSIC = 0x000d }
15
16 [Flags]
17 public enum BIF : uint
18 {
19 RETURNONLYFSDIRS = 0x0001,
20 DONTGOBELOWDOMAIN = 0x0002,
21 STATUSTEXT = 0x0004,
22 RETURNFSANCESTORS = 0x0008,
23 EDITBOX = 0x0010,
24 VALIDATE = 0x0020,
25 NEWDIALOGSTYLE = 0x0040,
26 USENEWUI = VALIDATE | NEWDIALOGSTYLE,
27 BROWSEINCLUDEURLS = 0x0080,
28 UAHINT = 0x0100,
29 NONEWFOLDERBUTTON = 0x0200,
30 NOTRANSLATETARGETS = 0x0400,
31 BROWSEFORCOMPUTER = 0x1000,
32 BROWSEFORPRINTER = 0x2000,
33 BROWSEINCLUDEFILES = 0x4000,
34 SHAREABLE = 0x8000
35 }
36
37 [Flags]
38 public enum BFFM : uint
39 {
40 INITIALIZED = 1,
41 SELCHANGED = 2,
42 VALIDATEFAILED = 4,
43 IUNKNOWN = 5,
44 ENABLEOK = 0x0400 + 101,
45 SETSELECTION = 0x0400 + 103,
46 SETSTATUSTEXT = 0x0400 + 104,
47 SETOKTEXT = 0x0400 + 105,
48 SETEXPANDED = 0x0400 + 106
49 }
50
51 public delegate int BrowseCallbackProc(IntPtr hwnd, BFFM uMsg, IntPtr lParam, IntPtr lpData);
52
53 [StructLayout(LayoutKind.Sequential)]
54 public class BROWSEINFO
55 {
56 public IntPtr hwndOwner;
57 public IntPtr pidlRoot;
58 [MarshalAs(UnmanagedType.LPWStr)]
59 public string pszDisplayName = new String('\0', 260);
60 [MarshalAs(UnmanagedType.LPWStr)]
61 public string lpszTitle;
62 public BIF ulFlags;
63 public BrowseCallbackProc lpfn;
64 public int iImage;
65 }
66
67 [DllImport("user32.dll", CharSet = CharSet.Unicode, EntryPoint = "SendMessageW")]
68 public static extern int SendMessage(IntPtr hWnd, BFFM Msg, bool wParam, string lParam);
69 [DllImport("shfolder.dll", CharSet = CharSet.Unicode, EntryPoint = "SHGetFolderPathW")]
70 public static extern int SHGetFolderPath(IntPtr hwndOwner, CSIDL nFolder, IntPtr hToken, int dwFlags, [Out] StringBuilder pszPath);
71 [DllImport("shell32.dll", CharSet = CharSet.Unicode, EntryPoint = "SHBrowseForFolderW")]
72 public static extern IntPtr SHBrowseForFolder([In, Out] BROWSEINFO lpbi);
73
74 public static string GetFolderPath(IntPtr hwndOwner, CSIDL nFolder)
75 {
76 StringBuilder path = new StringBuilder(260);
77
78 SHGetFolderPath(hwndOwner, nFolder, IntPtr.Zero, 0, path);
79
80 return path.ToString();
81 }
82
83 public static string BrowseForFolder(IntPtr hwndOwner, BrowseCallbackProc lpfn)
84 {
85 BROWSEINFO info = new BROWSEINFO();
86
87 info.hwndOwner = hwndOwner;
88 info.pidlRoot = IntPtr.Zero;
89 info.lpszTitle = "Select a folder:";
90 info.ulFlags = BIF.RETURNONLYFSDIRS | BIF.SHAREABLE;
91 info.lpfn = lpfn;
92
93 SHBrowseForFolder(info);
94
95 return "";
96 }
97 }

Properties

Name Value
svn:eol-style native
svn:keywords Id