winapi_ui_automation/um/
shellapi.rs

1// Licensed under the Apache License, Version 2.0
2// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4// All files in the project carrying such notice may not be copied, modified, or distributed
5// except according to those terms
6//! SHELL.DLL functions, types, and definitions
7use ctypes::{__int64, c_int, c_void};
8use shared::basetsd::{DWORD_PTR, UINT_PTR};
9use shared::guiddef::{GUID, REFIID};
10use shared::minwindef::{
11    BOOL, DWORD, FILETIME, HINSTANCE, HKEY, INT, LPARAM, LPVOID, MAX_PATH, UINT, ULONG, WORD,
12};
13use shared::windef::{HICON, HWND, POINT, RECT};
14use um::minwinbase::LPSECURITY_ATTRIBUTES;
15use um::processthreadsapi::{LPPROCESS_INFORMATION, LPSTARTUPINFOW};
16use um::winnt::{
17    CHAR, HANDLE, HRESULT, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PCSTR, PCWSTR, PCZZSTR, PCZZWSTR, PWSTR,
18    PZZSTR, PZZWSTR, ULARGE_INTEGER, WCHAR,
19};
20use um::winuser::WM_USER;
21DECLARE_HANDLE!{HDROP, HDROP__}
22extern "system" {
23    pub fn DragQueryFileA(
24        hDrop: HDROP,
25        iFile: UINT,
26        lpszFile: LPSTR,
27        cch: UINT,
28    ) -> UINT;
29    pub fn DragQueryFileW(
30        hDrop: HDROP,
31        iFile: UINT,
32        lpszFile: LPWSTR,
33        cch: UINT,
34    ) -> UINT;
35    pub fn DragQueryPoint(
36        hDrop: HDROP,
37        lppt: *mut POINT,
38    ) -> BOOL;
39    pub fn DragFinish(
40        hDrop: HDROP,
41    );
42    pub fn DragAcceptFiles(
43        hWnd: HWND,
44        fAccept: BOOL,
45    );
46    pub fn ShellExecuteA(
47        hwnd: HWND,
48        lpOperation: LPCSTR,
49        lpFile: LPCSTR,
50        lpParameters: LPCSTR,
51        lpDirectory: LPCSTR,
52        nShowCmd: c_int,
53    ) -> HINSTANCE;
54    pub fn ShellExecuteW(
55        hwnd: HWND,
56        lpOperation: LPCWSTR,
57        lpFile: LPCWSTR,
58        lpParameters: LPCWSTR,
59        lpDirectory: LPCWSTR,
60        nShowCmd: c_int,
61    ) -> HINSTANCE;
62    pub fn FindExecutableA(
63        lpFile: LPCSTR,
64        lpDirectory: LPCSTR,
65        lpResult: LPSTR,
66    ) -> HINSTANCE;
67    pub fn FindExecutableW(
68        lpFile: LPCWSTR,
69        lpDirectory: LPCWSTR,
70        lpResult: LPWSTR,
71    ) -> HINSTANCE;
72    pub fn CommandLineToArgvW(
73        lpCmdLine: LPCWSTR,
74        pNumArgs: *mut c_int,
75    ) -> *mut LPWSTR;
76    pub fn ShellAboutA(
77        hWnd: HWND,
78        szApp: LPCSTR,
79        szOtherStuff: LPCSTR,
80        hIcon: HICON,
81    ) -> INT;
82    pub fn ShellAboutW(
83        hWnd: HWND,
84        szApp: LPCWSTR,
85        szOtherStuff: LPCWSTR,
86        hIcon: HICON,
87    ) -> INT;
88    pub fn DuplicateIcon(
89        hInst: HINSTANCE,
90        hIcon: HICON,
91    ) -> HICON;
92    pub fn ExtractAssociatedIconA(
93        hInst: HINSTANCE,
94        pszIconPath: LPSTR,
95        piIcon: *mut WORD,
96    ) -> HICON;
97    pub fn ExtractAssociatedIconW(
98        hInst: HINSTANCE,
99        pszIconPath: LPWSTR,
100        piIcon: *mut WORD,
101    ) -> HICON;
102    pub fn ExtractAssociatedIconExA(
103        hInst: HINSTANCE,
104        pszIconPath: LPSTR,
105        piIconIndex: *mut WORD,
106        piIconId: *mut WORD,
107    ) -> HICON;
108    pub fn ExtractAssociatedIconExW(
109        hInst: HINSTANCE,
110        pszIconPath: LPWSTR,
111        piIconIndex: *mut WORD,
112        piIconId: *mut WORD,
113    ) -> HICON;
114    pub fn ExtractIconA(
115        hInst: HINSTANCE,
116        pszExeFileName: LPCSTR,
117        nIconIndex: UINT,
118    ) -> HICON;
119    pub fn ExtractIconW(
120        hInst: HINSTANCE,
121        pszExeFileName: LPCWSTR,
122        nIconIndex: UINT,
123    ) -> HICON;
124}
125STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct DRAGINFOA {
126    uSize: UINT,
127    pt: POINT,
128    fNC: BOOL,
129    lpFileList: PZZSTR,
130    grfKeyState: DWORD,
131}}
132pub type LPDRAGINFOA = *mut DRAGINFOA;
133STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct DRAGINFOW {
134    uSize: UINT,
135    pt: POINT,
136    fNC: BOOL,
137    lpFileList: PZZWSTR,
138    grfKeyState: DWORD,
139}}
140pub type LPDRAGINFOW = *mut DRAGINFOW;
141pub const ABM_NEW: DWORD = 0x00000000;
142pub const ABM_REMOVE: DWORD = 0x00000001;
143pub const ABM_QUERYPOS: DWORD = 0x00000002;
144pub const ABM_SETPOS: DWORD = 0x00000003;
145pub const ABM_GETSTATE: DWORD = 0x00000004;
146pub const ABM_GETTASKBARPOS: DWORD = 0x00000005;
147pub const ABM_ACTIVATE: DWORD = 0x00000006;
148pub const ABM_GETAUTOHIDEBAR: DWORD = 0x00000007;
149pub const ABM_SETAUTOHIDEBAR: DWORD = 0x00000008;
150pub const ABM_WINDOWPOSCHANGED: DWORD = 0x0000009;
151pub const ABM_SETSTATE: DWORD = 0x0000000a;
152pub const ABM_GETAUTOHIDEBAREX: DWORD = 0x0000000b;
153pub const ABM_SETAUTOHIDEBAREX: DWORD = 0x0000000c;
154pub const ABN_STATECHANGE: DWORD = 0x0000000;
155pub const ABN_POSCHANGED: DWORD = 0x0000001;
156pub const ABN_FULLSCREENAPP: DWORD = 0x0000002;
157pub const ABN_WINDOWARRANGE: DWORD = 0x0000003;
158pub const ABS_AUTOHIDE: UINT = 0x0000001;
159pub const ABS_ALWAYSONTOP: UINT = 0x0000002;
160pub const ABE_LEFT: UINT = 0;
161pub const ABE_TOP: UINT = 1;
162pub const ABE_RIGHT: UINT = 2;
163pub const ABE_BOTTOM: UINT = 3;
164STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct APPBARDATA {
165    cbSize: DWORD,
166    hWnd: HWND,
167    uCallbackMessage: UINT,
168    uEdge: UINT,
169    rc: RECT,
170    lParam: LPARAM,
171}}
172pub type PAPPBARDATA = *mut APPBARDATA;
173extern "system" {
174    pub fn SHAppBarMessage(
175        dwMessage: DWORD,
176        pData: PAPPBARDATA,
177    ) -> UINT_PTR;
178    pub fn DoEnvironmentSubstA(
179        pszSrc: LPSTR,
180        cchSrc: UINT,
181    ) -> DWORD;
182    pub fn DoEnvironmentSubstW(
183        pszSrc: LPWSTR,
184        cchSrc: UINT,
185    ) -> DWORD;
186    pub fn ExtractIconExA(
187        lpszFile: LPCSTR,
188        nIconIndex: c_int,
189        phiconLarge: *mut HICON,
190        phiconSmall: *mut HICON,
191        nIcons: UINT,
192    ) -> UINT;
193    pub fn ExtractIconExW(
194        lpszFile: LPCWSTR,
195        nIconIndex: c_int,
196        phiconLarge: *mut HICON,
197        phiconSmall: *mut HICON,
198        nIcons: UINT,
199    ) -> UINT;
200}
201pub const FO_MOVE: WORD = 0x0001;
202pub const FO_COPY: WORD = 0x0002;
203pub const FO_DELETE: WORD = 0x0003;
204pub const FO_RENAME: WORD = 0x0004;
205pub const FOF_MULTIDESTFILES: WORD = 0x0001;
206pub const FOF_CONFIRMMOUSE: WORD = 0x0002;
207pub const FOF_SILENT: WORD = 0x0004;
208pub const FOF_RENAMEONCOLLISION: WORD = 0x0008;
209pub const FOF_NOCONFIRMATION: WORD = 0x0010;
210pub const FOF_WANTMAPPINGHANDLE: WORD = 0x0020;
211pub const FOF_ALLOWUNDO: WORD = 0x0040;
212pub const FOF_FILESONLY: WORD = 0x0080;
213pub const FOF_SIMPLEPROGRESS: WORD = 0x0100;
214pub const FOF_NOCONFIRMMKDIR: WORD = 0x0200;
215pub const FOF_NOERRORUI: WORD = 0x0400;
216pub const FOF_NOCOPYSECURITYATTRIBS: WORD = 0x0800;
217pub const FOF_NORECURSION: WORD = 0x1000;
218pub const FOF_NO_CONNECTED_ELEMENTS: WORD = 0x2000;
219pub const FOF_WANTNUKEWARNING: WORD = 0x4000;
220pub const FOF_NORECURSEREPARSE: WORD = 0x8000;
221pub const FOF_NO_UI: WORD = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR;
222pub type FILEOP_FLAGS = WORD;
223pub const PO_DELETE: WORD = 0x0013;
224pub const PO_RENAME: WORD = 0x0014;
225pub const PO_PORTCHANGE: WORD = 0x0020;
226pub const PO_REN_PORT: WORD = 0x0034;
227pub type PRINTEROP_FLAGS = WORD;
228STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHFILEOPSTRUCTA {
229    hwnd: HWND,
230    wFunc: UINT,
231    pFrom: PCZZSTR,
232    pTo: PCZZSTR,
233    fFlags: FILEOP_FLAGS,
234    fAnyOperationsAborted: BOOL,
235    hNameMappings: LPVOID,
236    lpszProgressTitle: PCSTR,
237}}
238pub type LPSHFILEOPSTRUCTA = *mut SHFILEOPSTRUCTA;
239STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHFILEOPSTRUCTW {
240    hwnd: HWND,
241    wFunc: UINT,
242    pFrom: PCZZWSTR,
243    pTo: PCZZWSTR,
244    fFlags: FILEOP_FLAGS,
245    fAnyOperationsAborted: BOOL,
246    hNameMappings: LPVOID,
247    lpszProgressTitle: PCWSTR,
248}}
249pub type LPSHFILEOPSTRUCTW = *mut SHFILEOPSTRUCTW;
250extern "system" {
251    pub fn SHFileOperationA(
252        lpFileOp: LPSHFILEOPSTRUCTA,
253    ) -> c_int;
254    pub fn SHFileOperationW(
255        lpFileOp: LPSHFILEOPSTRUCTW,
256    ) -> c_int;
257    pub fn SHFreeNameMappings(
258        hNameMappings: HANDLE,
259    );
260}
261STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHNAMEMAPPINGA {
262    pszOldPath: LPSTR,
263    pszNewPath: LPSTR,
264    cchOldPath: c_int,
265    cchNewPath: c_int,
266}}
267pub type LPSHNAMEMAPPINGA = *mut SHNAMEMAPPINGA;
268STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHNAMEMAPPINGW {
269    pszOldPath: LPWSTR,
270    pszNewPath: LPWSTR,
271    cchOldPath: c_int,
272    cchNewPath: c_int,
273}}
274pub type LPSHNAMEMAPPINGW = *mut SHNAMEMAPPINGW;
275pub const SE_ERR_FNF: DWORD = 2;
276pub const SE_ERR_PNF: DWORD = 3;
277pub const SE_ERR_ACCESSDENIED: DWORD = 5;
278pub const SE_ERR_OOM: DWORD = 8;
279pub const SE_ERR_DLLNOTFOUND: DWORD = 32;
280pub const SE_ERR_SHARE: DWORD = 26;
281pub const SE_ERR_ASSOCINCOMPLETE: DWORD = 27;
282pub const SE_ERR_DDETIMEOUT: DWORD = 28;
283pub const SE_ERR_DDEFAIL: DWORD = 29;
284pub const SE_ERR_DDEBUSY: DWORD = 30;
285pub const SE_ERR_NOASSOC: DWORD = 31;
286pub const SEE_MASK_DEFAULT: DWORD = 0x00000000;
287pub const SEE_MASK_CLASSNAME: DWORD = 0x00000001;
288pub const SEE_MASK_CLASSKEY: DWORD = 0x00000003;
289pub const SEE_MASK_IDLIST: DWORD = 0x00000004;
290pub const SEE_MASK_INVOKEIDLIST: DWORD = 0x0000000c;
291pub const SEE_MASK_ICON: DWORD = 0x00000010;
292pub const SEE_MASK_HOTKEY: DWORD = 0x00000020;
293pub const SEE_MASK_NOCLOSEPROCESS: DWORD = 0x00000040;
294pub const SEE_MASK_CONNECTNETDRV: DWORD = 0x00000080;
295pub const SEE_MASK_NOASYNC: DWORD = 0x00000100;
296pub const SEE_MASK_FLAG_DDEWAIT: DWORD = SEE_MASK_NOASYNC;
297pub const SEE_MASK_DOENVSUBST: DWORD = 0x00000200;
298pub const SEE_MASK_FLAG_NO_UI: DWORD = 0x00000400;
299pub const SEE_MASK_UNICODE: DWORD = 0x00004000;
300pub const SEE_MASK_NO_CONSOLE: DWORD = 0x00008000;
301pub const SEE_MASK_ASYNCOK: DWORD = 0x00100000;
302pub const SEE_MASK_HMONITOR: DWORD = 0x00200000;
303pub const SEE_MASK_NOZONECHECKS: DWORD = 0x00800000;
304pub const SEE_MASK_NOQUERYCLASSSTORE: DWORD = 0x01000000;
305pub const SEE_MASK_WAITFORINPUTIDLE: DWORD = 0x02000000;
306pub const SEE_MASK_FLAG_LOG_USAGE: DWORD = 0x04000000;
307pub const SEE_MASK_FLAG_HINST_IS_SITE: DWORD = 0x08000000;
308STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHELLEXECUTEINFOA {
309    cbSize: DWORD,
310    fMask: ULONG,
311    hwnd: HWND,
312    lpVerb: LPCSTR,
313    lpFile: LPCSTR,
314    lpParameters: LPCSTR,
315    lpDirectory: LPCSTR,
316    nShow: c_int,
317    hInstApp: HINSTANCE,
318    lpIDList: *mut c_void,
319    lpClass: LPCSTR,
320    hkeyClass: HKEY,
321    dwHotKey: DWORD,
322    hMonitor: HANDLE,
323    hProcess: HANDLE,
324}}
325pub type LPSHELLEXECUTEINFOA = *mut SHELLEXECUTEINFOA;
326STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHELLEXECUTEINFOW {
327    cbSize: DWORD,
328    fMask: ULONG,
329    hwnd: HWND,
330    lpVerb: LPCWSTR,
331    lpFile: LPCWSTR,
332    lpParameters: LPCWSTR,
333    lpDirectory: LPCWSTR,
334    nShow: c_int,
335    hInstApp: HINSTANCE,
336    lpIDList: *mut c_void,
337    lpClass: LPCWSTR,
338    hkeyClass: HKEY,
339    dwHotKey: DWORD,
340    hMonitor: HANDLE,
341    hProcess: HANDLE,
342}}
343pub type LPSHELLEXECUTEINFOW = *mut SHELLEXECUTEINFOW;
344extern "system" {
345    pub fn ShellExecuteExA(
346        pExecInfo: *mut SHELLEXECUTEINFOA,
347    ) -> BOOL;
348    pub fn ShellExecuteExW(
349        pExecInfo: *mut SHELLEXECUTEINFOW,
350    ) -> BOOL;
351}
352STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHCREATEPROCESSINFOW {
353    cbSize: DWORD,
354    fMask: ULONG,
355    hwnd: HWND,
356    pszFile: LPCWSTR,
357    pszParameters: LPCWSTR,
358    pszCurrentDirectory: LPCWSTR,
359    hUserToken: HANDLE,
360    lpProcessAttributes: LPSECURITY_ATTRIBUTES,
361    lpThreadAttributes: LPSECURITY_ATTRIBUTES,
362    bInheritHandles: BOOL,
363    dwCreationFlags: DWORD,
364    lpStartupInfo: LPSTARTUPINFOW,
365    lpProcessInformation: LPPROCESS_INFORMATION,
366}}
367pub type PSHCREATEPROCESSINFOW = *mut SHCREATEPROCESSINFOW;
368extern "system" {
369    pub fn SHCreateProcessAsUserW(
370        pscpi: PSHCREATEPROCESSINFOW,
371    ) -> BOOL;
372    pub fn SHEvaluateSystemCommandTemplate(
373        pszCmdTemplate: PCWSTR,
374        ppszApplication: *mut PWSTR,
375        ppszCommandLine: *mut PWSTR,
376        ppszParameters: *mut PWSTR,
377    ) -> HRESULT;
378}
379ENUM!{enum ASSOCCLASS {
380    ASSOCCLASS_SHELL_KEY = 0,
381    ASSOCCLASS_PROGID_KEY,
382    ASSOCCLASS_PROGID_STR,
383    ASSOCCLASS_CLSID_KEY,
384    ASSOCCLASS_CLSID_STR,
385    ASSOCCLASS_APP_KEY,
386    ASSOCCLASS_APP_STR,
387    ASSOCCLASS_SYSTEM_STR,
388    ASSOCCLASS_FOLDER,
389    ASSOCCLASS_STAR,
390    ASSOCCLASS_FIXED_PROGID_STR,
391    ASSOCCLASS_PROTOCOL_STR,
392}}
393STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct ASSOCIATIONELEMENT {
394    ac: ASSOCCLASS,
395    hkClass: HKEY,
396    pszClass: PCWSTR,
397}}
398extern "system" {
399    pub fn AssocCreateForClasses(
400        rgClasses: *const ASSOCIATIONELEMENT,
401        cClasses: ULONG,
402        riid: REFIID,
403        ppv: *mut *mut c_void,
404    ) -> HRESULT;
405}
406STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHQUERYRBINFO {
407    cbSize: DWORD,
408    i64Size: __int64,
409    i64NumItems: __int64,
410}}
411pub type LPSHQUERYRBINFO = *mut SHQUERYRBINFO;
412pub const SHERB_NOCONFIRMATION: DWORD = 0x00000001;
413pub const SHERB_NOPROGRESSUI: DWORD = 0x00000002;
414pub const SHERB_NOSOUND: DWORD = 0x00000004;
415extern "system" {
416    pub fn SHQueryRecycleBinA(
417        pszRootPath: LPCSTR,
418        pSHQueryRBInfo: LPSHQUERYRBINFO,
419    ) -> HRESULT;
420    pub fn SHQueryRecycleBinW(
421        pszRootPath: LPCWSTR,
422        pSHQueryRBInfo: LPSHQUERYRBINFO,
423    ) -> HRESULT;
424    pub fn SHEmptyRecycleBinA(
425        hwnd: HWND,
426        pszRootPath: LPCSTR,
427        dwFlags: DWORD,
428    ) -> HRESULT;
429    pub fn SHEmptyRecycleBinW(
430        hwnd: HWND,
431        pszRootPath: LPCWSTR,
432        dwFlags: DWORD,
433    ) -> HRESULT;
434}
435ENUM!{enum QUERY_USER_NOTIFICATION_STATE {
436    QUNS_NOT_PRESENT = 1,
437    QUNS_BUSY = 2,
438    QUNS_RUNNING_D3D_FULL_SCREEN = 3,
439    QUNS_PRESENTATION_MODE = 4,
440    QUNS_ACCEPTS_NOTIFICATIONS = 5,
441    QUNS_QUIET_TIME = 6,
442    QUNS_APP = 7,
443}}
444extern "system" {
445    pub fn SHQueryUserNotificationState(
446        pquns: *mut QUERY_USER_NOTIFICATION_STATE,
447    ) -> HRESULT;
448    pub fn SHGetPropertyStoreForWindow(
449        hwnd: HWND,
450        riid: REFIID,
451        ppv: *mut *mut c_void,
452    ) -> HRESULT;
453}
454UNION!{#[cfg_attr(target_arch = "x86", repr(packed))] union NOTIFYICONDATAA_u {
455    [u32; 1],
456    uTimeout uTimeout_mut: UINT,
457    uVersion uVersion_mut: UINT,
458}}
459STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct NOTIFYICONDATAA {
460    cbSize: DWORD,
461    hWnd: HWND,
462    uID: UINT,
463    uFlags: UINT,
464    uCallbackMessage: UINT,
465    hIcon: HICON,
466    szTip: [CHAR; 128],
467    dwState: DWORD,
468    dwStateMask: DWORD,
469    szInfo: [CHAR; 256],
470    u: NOTIFYICONDATAA_u,
471    szInfoTitle: [CHAR; 64],
472    dwInfoFlags: DWORD,
473    guidItem: GUID,
474    hBalloonIcon: HICON,
475}}
476pub type PNOTIFYICONDATAA = *mut NOTIFYICONDATAA;
477UNION!{#[cfg_attr(target_arch = "x86", repr(packed))] union NOTIFYICONDATAW_u {
478    [u32; 1],
479    uTimeout uTimeout_mut: UINT,
480    uVersion uVersion_mut: UINT,
481}}
482STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct NOTIFYICONDATAW {
483    cbSize: DWORD,
484    hWnd: HWND,
485    uID: UINT,
486    uFlags: UINT,
487    uCallbackMessage: UINT,
488    hIcon: HICON,
489    szTip: [WCHAR; 128],
490    dwState: DWORD,
491    dwStateMask: DWORD,
492    szInfo: [WCHAR; 256],
493    u: NOTIFYICONDATAW_u,
494    szInfoTitle: [WCHAR; 64],
495    dwInfoFlags: DWORD,
496    guidItem: GUID,
497    hBalloonIcon: HICON,
498}}
499pub type PNOTIFYICONDATAW = *mut NOTIFYICONDATAW;
500pub const NIN_SELECT: DWORD = WM_USER + 0;
501pub const NINF_KEY: DWORD = 0x1;
502pub const NIN_KEYSELECT: DWORD = NIN_SELECT | NINF_KEY;
503pub const NIN_BALLOONSHOW: DWORD = WM_USER + 2;
504pub const NIN_BALLOONHIDE: DWORD = WM_USER + 3;
505pub const NIN_BALLOONTIMEOUT: DWORD = WM_USER + 4;
506pub const NIN_BALLOONUSERCLICK: DWORD = WM_USER + 5;
507pub const NIN_POPUPOPEN: DWORD = WM_USER + 6;
508pub const NIN_POPUPCLOSE: DWORD = WM_USER + 7;
509pub const NIM_ADD: DWORD = 0x00000000;
510pub const NIM_MODIFY: DWORD = 0x00000001;
511pub const NIM_DELETE: DWORD = 0x00000002;
512pub const NIM_SETFOCUS: DWORD = 0x00000003;
513pub const NIM_SETVERSION: DWORD = 0x00000004;
514pub const NOTIFYICON_VERSION: DWORD = 3;
515pub const NOTIFYICON_VERSION_4: DWORD = 4;
516pub const NIF_MESSAGE: DWORD = 0x00000001;
517pub const NIF_ICON: DWORD = 0x00000002;
518pub const NIF_TIP: DWORD = 0x00000004;
519pub const NIF_STATE: DWORD = 0x00000008;
520pub const NIF_INFO: DWORD = 0x00000010;
521pub const NIF_GUID: DWORD = 0x00000020;
522pub const NIF_REALTIME: DWORD = 0x00000040;
523pub const NIF_SHOWTIP: DWORD = 0x00000080;
524pub const NIS_HIDDEN: DWORD = 0x00000001;
525pub const NIS_SHAREDICON: DWORD = 0x00000002;
526pub const NIIF_NONE: DWORD = 0x00000000;
527pub const NIIF_INFO: DWORD = 0x00000001;
528pub const NIIF_WARNING: DWORD = 0x00000002;
529pub const NIIF_ERROR: DWORD = 0x00000003;
530pub const NIIF_USER: DWORD = 0x00000004;
531pub const NIIF_ICON_MASK: DWORD = 0x0000000F;
532pub const NIIF_NOSOUND: DWORD = 0x00000010;
533pub const NIIF_LARGE_ICON: DWORD = 0x00000020;
534pub const NIIF_RESPECT_QUIET_TIME: DWORD = 0x00000080;
535STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct NOTIFYICONIDENTIFIER {
536    cbSize: DWORD,
537    hWnd: HWND,
538    uID: UINT,
539    guidItem: GUID,
540}}
541pub type PNOTIFYICONIDENTIFIER = *mut NOTIFYICONIDENTIFIER;
542extern "system" {
543    pub fn Shell_NotifyIconA(
544        dwMessage: DWORD,
545        lpData: PNOTIFYICONDATAA,
546    ) -> BOOL;
547    pub fn Shell_NotifyIconW(
548        dwMessage: DWORD,
549        lpData: PNOTIFYICONDATAW,
550    ) -> BOOL;
551    pub fn Shell_NotifyIconGetRect(
552        identifier: *const NOTIFYICONIDENTIFIER,
553        iconLocation: *mut RECT,
554    ) -> HRESULT;
555}
556STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHFILEINFOA {
557    hIcon: HICON,
558    iIcon: c_int,
559    dwAttributes: DWORD,
560    szDisplayName: [CHAR; MAX_PATH],
561    szTypeName: [CHAR; 80],
562}}
563STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHFILEINFOW {
564    hIcon: HICON,
565    iIcon: c_int,
566    dwAttributes: DWORD,
567    szDisplayName: [WCHAR; MAX_PATH],
568    szTypeName: [WCHAR; 80],
569}}
570pub const SHGFI_ICON: DWORD = 0x000000100;
571pub const SHGFI_DISPLAYNAME: DWORD = 0x000000200;
572pub const SHGFI_TYPENAME: DWORD = 0x000000400;
573pub const SHGFI_ATTRIBUTES: DWORD = 0x000000800;
574pub const SHGFI_ICONLOCATION: DWORD = 0x000001000;
575pub const SHGFI_EXETYPE: DWORD = 0x000002000;
576pub const SHGFI_SYSICONINDEX: DWORD = 0x000004000;
577pub const SHGFI_LINKOVERLAY: DWORD = 0x000008000;
578pub const SHGFI_SELECTED: DWORD = 0x000010000;
579pub const SHGFI_ATTR_SPECIFIED: DWORD = 0x000020000;
580pub const SHGFI_LARGEICON: DWORD = 0x000000000;
581pub const SHGFI_SMALLICON: DWORD = 0x000000001;
582pub const SHGFI_OPENICON: DWORD = 0x000000002;
583pub const SHGFI_SHELLICONSIZE: DWORD = 0x000000004;
584pub const SHGFI_PIDL: DWORD = 0x000000008;
585pub const SHGFI_USEFILEATTRIBUTES: DWORD = 0x000000010;
586pub const SHGFI_ADDOVERLAYS: DWORD = 0x000000020;
587pub const SHGFI_OVERLAYINDEX: DWORD = 0x000000040;
588extern "system" {
589    pub fn SHGetFileInfoA(
590        pszPath: LPCSTR,
591        dwFileAttributes: DWORD,
592        psfi: *mut SHFILEINFOA,
593        cbFileInfo: UINT,
594        uFlags: UINT,
595    ) -> DWORD_PTR;
596    pub fn SHGetFileInfoW(
597        pszPath: LPCWSTR,
598        dwFileAttributes: DWORD,
599        psfi: *mut SHFILEINFOW,
600        cbFileInfo: UINT,
601        uFlags: UINT,
602    ) -> DWORD_PTR;
603}
604STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct SHSTOCKICONINFO {
605    cbSize: DWORD,
606    hIcon: HICON,
607    iSysImageIndex: c_int,
608    iIcon: c_int,
609    szPath: [WCHAR; MAX_PATH],
610}}
611pub const SHGSI_ICONLOCATION: DWORD = 0;
612pub const SHGSI_ICON: DWORD = SHGFI_ICON;
613pub const SHGSI_SYSICONINDEX: DWORD = SHGFI_SYSICONINDEX;
614pub const SHGSI_LINKOVERLAY: DWORD = SHGFI_LINKOVERLAY;
615pub const SHGSI_SELECTED: DWORD = SHGFI_SELECTED;
616pub const SHGSI_LARGEICON: DWORD = SHGFI_LARGEICON;
617pub const SHGSI_SMALLICON: DWORD = SHGFI_SMALLICON;
618pub const SHGSI_SHELLICONSIZE: DWORD = SHGFI_SHELLICONSIZE;
619ENUM!{enum SHSTOCKICONID {
620    SIID_DOCNOASSOC = 0,
621    SIID_DOCASSOC = 1,
622    SIID_APPLICATION = 2,
623    SIID_FOLDER = 3,
624    SIID_FOLDEROPEN = 4,
625    SIID_DRIVE525 = 5,
626    SIID_DRIVE35 = 6,
627    SIID_DRIVEREMOVE = 7,
628    SIID_DRIVEFIXED = 8,
629    SIID_DRIVENET = 9,
630    SIID_DRIVENETDISABLED = 10,
631    SIID_DRIVECD = 11,
632    SIID_DRIVERAM = 12,
633    SIID_WORLD = 13,
634    SIID_SERVER = 15,
635    SIID_PRINTER = 16,
636    SIID_MYNETWORK = 17,
637    SIID_FIND = 22,
638    SIID_HELP = 23,
639    SIID_SHARE = 28,
640    SIID_LINK = 29,
641    SIID_SLOWFILE = 30,
642    SIID_RECYCLER = 31,
643    SIID_RECYCLERFULL = 32,
644    SIID_MEDIACDAUDIO = 40,
645    SIID_LOCK = 47,
646    SIID_AUTOLIST = 49,
647    SIID_PRINTERNET = 50,
648    SIID_SERVERSHARE = 51,
649    SIID_PRINTERFAX = 52,
650    SIID_PRINTERFAXNET = 53,
651    SIID_PRINTERFILE = 54,
652    SIID_STACK = 55,
653    SIID_MEDIASVCD = 56,
654    SIID_STUFFEDFOLDER = 57,
655    SIID_DRIVEUNKNOWN = 58,
656    SIID_DRIVEDVD = 59,
657    SIID_MEDIADVD = 60,
658    SIID_MEDIADVDRAM = 61,
659    SIID_MEDIADVDRW = 62,
660    SIID_MEDIADVDR = 63,
661    SIID_MEDIADVDROM = 64,
662    SIID_MEDIACDAUDIOPLUS = 65,
663    SIID_MEDIACDRW = 66,
664    SIID_MEDIACDR = 67,
665    SIID_MEDIACDBURN = 68,
666    SIID_MEDIABLANKCD = 69,
667    SIID_MEDIACDROM = 70,
668    SIID_AUDIOFILES = 71,
669    SIID_IMAGEFILES = 72,
670    SIID_VIDEOFILES = 73,
671    SIID_MIXEDFILES = 74,
672    SIID_FOLDERBACK = 75,
673    SIID_FOLDERFRONT = 76,
674    SIID_SHIELD = 77,
675    SIID_WARNING = 78,
676    SIID_INFO = 79,
677    SIID_ERROR = 80,
678    SIID_KEY = 81,
679    SIID_SOFTWARE = 82,
680    SIID_RENAME = 83,
681    SIID_DELETE = 84,
682    SIID_MEDIAAUDIODVD = 85,
683    SIID_MEDIAMOVIEDVD = 86,
684    SIID_MEDIAENHANCEDCD = 87,
685    SIID_MEDIAENHANCEDDVD = 88,
686    SIID_MEDIAHDDVD = 89,
687    SIID_MEDIABLURAY = 90,
688    SIID_MEDIAVCD = 91,
689    SIID_MEDIADVDPLUSR = 92,
690    SIID_MEDIADVDPLUSRW = 93,
691    SIID_DESKTOPPC = 94,
692    SIID_MOBILEPC = 95,
693    SIID_USERS = 96,
694    SIID_MEDIASMARTMEDIA = 97,
695    SIID_MEDIACOMPACTFLASH = 98,
696    SIID_DEVICECELLPHONE = 99,
697    SIID_DEVICECAMERA = 100,
698    SIID_DEVICEVIDEOCAMERA = 101,
699    SIID_DEVICEAUDIOPLAYER = 102,
700    SIID_NETWORKCONNECT = 103,
701    SIID_INTERNET = 104,
702    SIID_ZIPFILE = 105,
703    SIID_SETTINGS = 106,
704    SIID_DRIVEHDDVD = 132,
705    SIID_DRIVEBD = 133,
706    SIID_MEDIAHDDVDROM = 134,
707    SIID_MEDIAHDDVDR = 135,
708    SIID_MEDIAHDDVDRAM = 136,
709    SIID_MEDIABDROM = 137,
710    SIID_MEDIABDR = 138,
711    SIID_MEDIABDRE = 139,
712    SIID_CLUSTEREDDRIVE = 140,
713    SIID_MAX_ICONS = 181,
714}}
715pub const SIID_INVALID: SHSTOCKICONID = -1i32 as u32;
716extern "system" {
717    pub fn SHGetStockIconInfo(
718        siid: SHSTOCKICONID,
719        uFlags: UINT,
720        psii: *mut SHSTOCKICONINFO,
721    ) -> HRESULT;
722    pub fn SHGetDiskFreeSpaceExA(
723        pszDirectoryName: LPCSTR,
724        pulFreeBytesAvailableToCaller: *mut ULARGE_INTEGER,
725        pulTotalNumberOfBytes: *mut ULARGE_INTEGER,
726        pulTotalNumberOfFreeBytes: *mut ULARGE_INTEGER,
727    ) -> BOOL;
728    pub fn SHGetDiskFreeSpaceExW(
729        pszDirectoryName: LPCWSTR,
730        pulFreeBytesAvailableToCaller: *mut ULARGE_INTEGER,
731        pulTotalNumberOfBytes: *mut ULARGE_INTEGER,
732        pulTotalNumberOfFreeBytes: *mut ULARGE_INTEGER,
733    ) -> BOOL;
734    pub fn SHGetNewLinkInfoA(
735        pszLinkTo: LPCSTR,
736        pszDir: LPCSTR,
737        pszName: LPSTR,
738        pfMustCopy: *mut BOOL,
739        uFlags: UINT,
740    ) -> BOOL;
741    pub fn SHGetNewLinkInfoW(
742        pszLinkTo: LPCWSTR,
743        pszDir: LPCWSTR,
744        pszName: LPWSTR,
745        pfMustCopy: *mut BOOL,
746        uFlags: UINT,
747    ) -> BOOL;
748}
749pub const SHGNLI_PIDL: DWORD = 0x000000001;
750pub const SHGNLI_PREFIXNAME: DWORD = 0x000000002;
751pub const SHGNLI_NOUNIQUE: DWORD = 0x000000004;
752pub const SHGNLI_NOLNK: DWORD = 0x000000008;
753pub const SHGNLI_NOLOCNAME: DWORD = 0x000000010;
754pub const SHGNLI_USEURLEXT: DWORD = 0x000000020;
755pub const PRINTACTION_OPEN: DWORD = 0;
756pub const PRINTACTION_PROPERTIES: DWORD = 1;
757pub const PRINTACTION_NETINSTALL: DWORD = 2;
758pub const PRINTACTION_NETINSTALLLINK: DWORD = 3;
759pub const PRINTACTION_TESTPAGE: DWORD = 4;
760pub const PRINTACTION_OPENNETPRN: DWORD = 5;
761pub const PRINTACTION_DOCUMENTDEFAULTS: DWORD = 6;
762pub const PRINTACTION_SERVERPROPERTIES: DWORD = 7;
763extern "system" {
764    pub fn SHInvokePrinterCommandA(
765        hwnd: HWND,
766        uAction: UINT,
767        lpBuf1: LPCSTR,
768        lpBuf2: LPCSTR,
769        fModal: BOOL,
770    ) -> BOOL;
771    pub fn SHInvokePrinterCommandW(
772        hwnd: HWND,
773        uAction: UINT,
774        lpBuf1: LPCWSTR,
775        lpBuf2: LPCWSTR,
776        fModal: BOOL,
777    ) -> BOOL;
778}
779STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct OPEN_PRINTER_PROPS_INFOA {
780    dwSize: DWORD,
781    pszSheetName: LPSTR,
782    uSheetIndex: UINT,
783    dwFlags: DWORD,
784    bModal: BOOL,
785}}
786pub type POPEN_PRINTER_PROPS_INFOA = *mut OPEN_PRINTER_PROPS_INFOA;
787STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct OPEN_PRINTER_PROPS_INFOW {
788    dwSize: DWORD,
789    pszSheetName: LPWSTR,
790    uSheetIndex: UINT,
791    dwFlags: DWORD,
792    bModal: BOOL,
793}}
794pub type POPEN_PRINTER_PROPS_INFOW = *mut OPEN_PRINTER_PROPS_INFOW;
795pub const PRINT_PROP_FORCE_NAME: DWORD = 0x01;
796extern "system" {
797    pub fn SHLoadNonloadedIconOverlayIdentifiers() -> HRESULT;
798    pub fn SHIsFileAvailableOffline(
799        pwszPath: PCWSTR,
800        pdwStatus: *mut DWORD,
801    ) -> HRESULT;
802}
803pub const OFFLINE_STATUS_LOCAL: DWORD = 0x0001;
804pub const OFFLINE_STATUS_REMOTE: DWORD = 0x0002;
805pub const OFFLINE_STATUS_INCOMPLETE: DWORD = 0x0004;
806extern "system" {
807    pub fn SHSetLocalizedName(
808        pszPath: PCWSTR,
809        pszResModule: PCWSTR,
810        idsRes: c_int,
811    ) -> HRESULT;
812    pub fn SHRemoveLocalizedName(
813        pszPath: PCWSTR,
814    ) -> HRESULT;
815    pub fn SHGetLocalizedName(
816        pszPath: PCWSTR,
817        pszResModule: PWSTR,
818        cch: UINT,
819        pidsRes: *mut c_int,
820    ) -> HRESULT;
821}
822extern "C" {
823    pub fn ShellMessageBoxA(
824        hAppInst: HINSTANCE,
825        hWnd: HWND,
826        lpcText: LPCSTR,
827        lpcTitle: LPCSTR,
828        fuStyle: UINT,
829        ...
830    ) -> c_int;
831    pub fn ShellMessageBoxW(
832        hAppInst: HINSTANCE,
833        hWnd: HWND,
834        lpcText: LPCWSTR,
835        lpcTitle: LPCWSTR,
836        fuStyle: UINT,
837        ...
838    ) -> c_int;
839}
840extern "system" {
841    pub fn IsLFNDriveA(
842        pszPath: LPCSTR,
843    ) -> BOOL;
844    pub fn IsLFNDriveW(
845        pszPath: LPCWSTR,
846    ) -> BOOL;
847    pub fn SHEnumerateUnreadMailAccountsA(
848        hKeyUser: HKEY,
849        dwIndex: DWORD,
850        pszMailAddress: LPSTR,
851        cchMailAddress: c_int,
852    ) -> HRESULT;
853    pub fn SHEnumerateUnreadMailAccountsW(
854        hKeyUser: HKEY,
855        dwIndex: DWORD,
856        pszMailAddress: LPWSTR,
857        cchMailAddress: c_int,
858    ) -> HRESULT;
859    pub fn SHGetUnreadMailCountA(
860        hKeyUser: HKEY,
861        pszMailAddress: LPCSTR,
862        pdwCount: *mut DWORD,
863        pFileTime: *mut FILETIME,
864        pszShellExecuteCommand: LPSTR,
865        cchShellExecuteCommand: c_int,
866    ) -> HRESULT;
867    pub fn SHGetUnreadMailCountW(
868        hKeyUser: HKEY,
869        pszMailAddress: LPCWSTR,
870        pdwCount: *mut DWORD,
871        pFileTime: *mut FILETIME,
872        pszShellExecuteCommand: LPWSTR,
873        cchShellExecuteCommand: c_int,
874    ) -> HRESULT;
875    pub fn SHSetUnreadMailCountA(
876        pszMailAddress: LPCSTR,
877        dwCount: DWORD,
878        pszShellExecuteCommand: LPCSTR,
879    ) -> HRESULT;
880    pub fn SHSetUnreadMailCountW(
881        pszMailAddress: LPCWSTR,
882        dwCount: DWORD,
883        pszShellExecuteCommand: LPCWSTR,
884    ) -> HRESULT;
885    pub fn SHTestTokenMembership(
886        hToken: HANDLE,
887        ulRID: ULONG,
888    ) -> BOOL;
889    pub fn SHGetImageList(
890        iImageList: c_int,
891        riid: REFIID,
892        ppvObj: *mut *mut c_void,
893    ) -> HRESULT;
894}
895pub const SHIL_LARGE: DWORD = 0;
896pub const SHIL_SMALL: DWORD = 1;
897pub const SHIL_EXTRALARGE: DWORD = 2;
898pub const SHIL_SYSSMALL: DWORD = 3;
899pub const SHIL_JUMBO: DWORD = 4;
900pub const SHIL_LAST: DWORD = SHIL_JUMBO;
901FN!{stdcall PFNCANSHAREFOLDERW(
902    pszPath: PCWSTR,
903) -> HRESULT}
904FN!{stdcall PFNSHOWSHAREFOLDERUIW(
905    hwndParent: HWND,
906    pszPath: PCWSTR,
907) -> HRESULT}
908pub const WC_NETADDRESS: &'static str = "msctls_netaddress";
909extern "system" {
910    pub fn InitNetworkAddressControl() -> BOOL;
911}
912// STRUCT!{struct NC_ADDRESS {
913//     pAddrInfo: *mut NET_ADDRESS_INFO,
914//     PortNumber: USHORT,
915//     PrefixLength: BYTE,
916// }}
917// pub type PNC_ADDRESS = *mut NC_ADDRESS;
918extern "system" {
919    pub fn SHGetDriveMedia(
920        pszDrive: PCWSTR,
921        pdwMediaContent: *mut DWORD,
922    ) -> HRESULT;
923}