' ########################################################################################
' Microsoft Windows
' File: ShellApi.inc
' Contents: SHELL.DLL functions, types, and definitions
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_ShellAPI_PBI)
#DEFINE PBX_ShellAPI_PBI
%EQUATE `SHELLAPI_INC = 1
#INCLUDE ONCE "Core/Windows.inc"
'#if !defined(_WIN64)
'#include <pshpack1.h>
'#endif
'DECLARE_HANDLE(HDROP);
DECLARE FUNCTION DragQueryFileA LIB "shell32.dll" ALIAS "DragQueryFileA" ( BYVAL hDrop AS QUAD , BYVAL uiFile AS QUAD , BYREF lpszFile AS ASCIIZ , BYVAL cch AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION DragQueryFileW LIB "shell32.dll" ALIAS "DragQueryFileW" ( BYVAL hDrop AS QUAD , BYVAL uiFile AS QUAD , BYREF lpszFile AS WSTRINGZ , BYVAL cch AS QUAD ) AS QUAD ' UINT
#IF %DEF(%UNICODE)
 MACRO DragQueryFile = DragQueryFileW
#ELSE
 MACRO DragQueryFile = DragQueryFileA
#ENDIF
DECLARE FUNCTION DragQueryPoint LIB "shell32.dll" ALIAS "DragQueryPoint" ( BYVAL hDrop AS QUAD , BYREF lppt AS POINT ) AS LONG
DECLARE SUB DragFinish LIB "shell32.dll" ALIAS "DragFinish" ( BYVAL hDrop AS QUAD
 ) ' void
DECLARE SUB DragAcceptFiles LIB "shell32.dll" ALIAS "DragAcceptFiles" ( BYVAL hWnd AS QUAD , BYVAL fAccept AS LONG ) ' void
DECLARE FUNCTION ShellExecuteA LIB "shell32.dll" ALIAS "ShellExecuteA" ( BYVAL hWnd AS QUAD , BYREF lpOperation AS ASCIIZ , BYREF lpFile AS ASCIIZ , BYREF lpParameters AS ASCIIZ , BYREF lpDirectory AS ASCIIZ , BYVAL nShowCmd AS LONG ) AS QUAD ' HINSTANCE
DECLARE FUNCTION ShellExecuteW LIB "shell32.dll" ALIAS "ShellExecuteW" ( BYVAL hWnd AS QUAD , BYREF lpOperation AS WSTRINGZ , BYREF lpFile AS WSTRINGZ , BYREF lpParameters AS WSTRINGZ , BYREF lpDirectory AS WSTRINGZ , BYVAL nShowCmd AS LONG ) AS QUAD ' HINSTANCE
#IF %DEF(%UNICODE)
 MACRO ShellExecute = ShellExecuteW
#ELSE
 MACRO ShellExecute = ShellExecuteA
#ENDIF
DECLARE FUNCTION FindExecutableA LIB "shell32.dll" ALIAS "FindExecutableA" ( BYREF lpFile AS ASCIIZ , BYREF lpDirectory AS ASCIIZ , BYREF lpResult AS ASCIIZ ) AS QUAD ' HINSTANCE
DECLARE FUNCTION FindExecutableW LIB "shell32.dll" ALIAS "FindExecutableW" ( BYREF lpFile AS WSTRINGZ , BYREF lpDirectory AS WSTRINGZ , BYREF lpResult AS WSTRINGZ ) AS QUAD ' HINSTANCE
#IF %DEF(%UNICODE)
 MACRO FindExecutable = FindExecutableW
#ELSE
 MACRO FindExecutable = FindExecutableA
#ENDIF
DECLARE FUNCTION CommandLineToArgvW LIB "shell32.dll" ALIAS "CommandLineToArgvW" ( BYREF lpCmdLine AS WSTRINGZ , BYREF pNumArgs AS LONG ) AS QUAD
MACRO CommandLineToArgv = CommandLineToArgvW
DECLARE FUNCTION ShellAboutA LIB "shell32.dll" ALIAS "ShellAboutA" ( BYVAL hWnd AS QUAD , BYREF szApp AS ASCIIZ , BYREF szOtherStuff AS ASCIIZ , OPTIONAL BYVAL hIcon AS QUAD ) AS LONG ' int
DECLARE FUNCTION ShellAboutW LIB "shell32.dll" ALIAS "ShellAboutW" ( BYVAL hWnd AS QUAD , BYREF szApp AS WSTRINGZ , BYREF szOtherStuff AS WSTRINGZ , OPTIONAL BYVAL hIcon AS QUAD ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO ShellAbout = ShellAboutW
#ELSE
 MACRO ShellAbout = ShellAboutA
#ENDIF
DECLARE FUNCTION DuplicateIcon LIB "shell32.dll" ALIAS "DuplicateIcon" ( BYVAL hInst AS QUAD , BYVAL hIcon AS QUAD ) AS QUAD ' HICON
DECLARE FUNCTION ExtractAssociatedIconA LIB "shell32.dll" ALIAS "ExtractAssociatedIconA" ( BYVAL hInst AS QUAD , BYREF lpIconPath AS ASCIIZ , BYREF lpiIcon AS WORD ) AS QUAD ' HICON
DECLARE FUNCTION ExtractAssociatedIconW LIB "shell32.dll" ALIAS "ExtractAssociatedIconW" ( BYVAL hInst AS QUAD , BYREF lpIconPath AS WSTRINGZ , BYREF lpiIcon AS WORD ) AS QUAD ' HICON
#IF %DEF(%UNICODE)
 MACRO ExtractAssociatedIcon = ExtractAssociatedIconW
#ELSE
 MACRO ExtractAssociatedIcon = ExtractAssociatedIconA
#ENDIF
DECLARE FUNCTION ExtractAssociatedIconExA LIB "shell32.dll" ALIAS "ExtractAssociatedIconExA" ( BYVAL hInst AS QUAD , BYREF lpIconPath AS ASCIIZ , BYREF lpiIconIndex AS WORD , BYREF lpiIconId AS WORD ) AS QUAD ' HICON
DECLARE FUNCTION ExtractAssociatedIconExW LIB "shell32.dll" ALIAS "ExtractAssociatedIconExW" ( BYVAL hInst AS QUAD , BYREF lpIconPath AS WSTRINGZ , BYREF lpiIconIndex AS WORD , BYREF lpiIconId AS WORD ) AS QUAD ' HICON
#IF %DEF(%UNICODE)
 MACRO ExtractAssociatedIconEx = ExtractAssociatedIconExW
#ELSE
 MACRO ExtractAssociatedIconEx = ExtractAssociatedIconExA
#ENDIF
DECLARE FUNCTION ExtractIconA LIB "shell32.dll" ALIAS "ExtractIconA" ( BYVAL hInst AS QUAD , BYREF lpszExeFileName AS ASCIIZ , BYVAL nIconIndex AS QUAD ) AS QUAD ' HICON
DECLARE FUNCTION ExtractIconW LIB "shell32.dll" ALIAS "ExtractIconW" ( BYVAL hInst AS QUAD , BYREF lpszExeFileName AS WSTRINGZ , BYVAL nIconIndex AS QUAD ) AS QUAD ' HICON
#IF %DEF(%UNICODE)
 MACRO ExtractIcon = ExtractIconW
#ELSE
 MACRO ExtractIcon = ExtractIconA
#ENDIF
'#if(WINVER >= 0x0400)
' // Size = 24 bytes
TYPE DRAGINFOA BYTE
 uSize AS DWORD ' UINT uSize /* init with sizeof(DRAGINFO) */
 pt AS POINT ' POINT pt
 fNC AS LONG ' BOOL fNC
 lpFileList AS ASCIIZ PTR ' LPSTR lpFileList
 grfKeyState AS DWORD ' DWORD grfKeyState
END TYPE
' // Size = 24 bytes
TYPE DRAGINFOW BYTE
 uSize AS DWORD ' UINT uSize /* init with sizeof(DRAGINFO) */
 pt AS POINT ' POINT pt
 fNC AS LONG ' BOOL fNC
 lpFileList AS WSTRINGZ PTR ' LPWSTR lpFileList
 grfKeyState AS DWORD ' DWORD grfKeyState
END TYPE
#IF %DEF(%UNICODE)
 MACRO DRAGINFO = DRAGINFOW
#ELSE
 MACRO DRAGINFO = DRAGINFOA
#ENDIF
'////
'//// AppBar stuff
'////
%EQUATE `ABM_NEW = &H00000000
%EQUATE `ABM_REMOVE = &H00000001
%EQUATE `ABM_QUERYPOS = &H00000002
%EQUATE `ABM_SETPOS = &H00000003
%EQUATE `ABM_GETSTATE = &H00000004
%EQUATE `ABM_GETTASKBARPOS = &H00000005
%EQUATE `ABM_ACTIVATE = &H00000006 ' // lParam == TRUE/FALSE means activate/deactivate
%EQUATE `ABM_GETAUTOHIDEBAR = &H00000007
%EQUATE `ABM_SETAUTOHIDEBAR = &H00000008 ' // this can fail at any time. MUST check the result
 ' // lParam = TRUE/FALSE Set/Unset
 ' // uEdge = what edge
%EQUATE `ABM_WINDOWPOSCHANGED = &H00000009
'#if (NTDDI_VERSION >= NTDDI_WINXP)
%EQUATE `ABM_SETSTATE = &H0000000A
'#endif // (NTDDI_VERSION >= NTDDI_WINXP)
'// these are put in the wparam of callback messages
%EQUATE `ABN_STATECHANGE = &H00000000
%EQUATE `ABN_POSCHANGED = &H00000001
%EQUATE `ABN_FULLSCREENAPP = &H00000002
%EQUATE `ABN_WINDOWARRANGE = &H00000003 ' // lParam == TRUE means hide
'// flags for get state
%EQUATE `ABS_AUTOHIDE = &H00000001
%EQUATE `ABS_ALWAYSONTOP = &H00000002
%EQUATE `ABE_LEFT = 0
%EQUATE `ABE_TOP = 1
%EQUATE `ABE_RIGHT = 2
%EQUATE `ABE_BOTTOM = 3
' // Size = 36 bytes
TYPE APPBARDATA BYTE
 cbSize AS DWORD
 hWnd AS DWORD
 uCallbackMessage AS DWORD
 uEdge AS DWORD
 rc AS RECT
 lParam AS LONG ' // message specific
END TYPE
DECLARE FUNCTION SHAppBarMessage LIB "shell32.dll" ALIAS "SHAppBarMessage" ( BYVAL dwMessage AS QUAD , BYREF pData AS APPBARDATA ) AS QUAD ' UINT_PTR
'////
'//// EndAppBar
'////
DECLARE FUNCTION DoEnvironmentSubstA LIB "shell32.dll" ALIAS "DoEnvironmentSubstA" ( BYREF pszString AS ASCIIZ , BYVAL cchString AS QUAD ) AS QUAD
DECLARE FUNCTION DoEnvironmentSubstW LIB "shell32.dll" ALIAS "DoEnvironmentSubstW" ( BYREF pszString AS WSTRINGZ
 , BYVAL cchString AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO DoEnvironmentSubst = DoEnvironmentSubstW
#ELSE
 MACRO DoEnvironmentSubst = DoEnvironmentSubstA
#ENDIF
'#define EIRESID(x) (-1 * (int)(x))
MACRO EIRESID(x) = (-1 * CLNG(x))
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ExtractIconExA LIB "Shell32.dll" ALIAS "ExtractIconExA" ( lpszFile AS ASCIIZ, BYVAL nIconIndex AS LONG, BYVAL phiconLarge AS QUAD PTR, BYVAL phiconSmall AS QUAD PTR, BYVAL nIcons AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION ExtractIconExA LIB "shell32.dll" ALIAS "ExtractIconExA" ( BYREF lpszFile AS ASCIIZ , BYVAL nIconIndex AS LONG , BYREF phiconLarge AS QUAD , BYREF phiconSmall AS QUAD , BYVAL nIcons AS QUAD ) AS QUAD ' UINT
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ExtractIconExW LIB "Shell32.dll" ALIAS "ExtractIconExW" ( lpszFile AS WSTRINGZ, BYVAL nIconIndex AS LONG, BYVAL phiconLarge AS QUAD PTR, BYVAL phiconSmall AS QUAD PTR, BYVAL nIcons AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION ExtractIconExW LIB "shell32.dll" ALIAS "ExtractIconExW" ( BYREF lpszFile AS WSTRINGZ , BYVAL nIconIndex AS LONG , BYREF phiconLarge AS QUAD , BYREF phiconSmall AS QUAD , BYVAL nIcons AS QUAD ) AS QUAD ' UINT
#ENDIF
#IF %DEF(%UNICODE)
 MACRO ExtractIconEx = ExtractIconExW
#ELSE
 MACRO ExtractIconEx = ExtractIconExA
#ENDIF
'////
'//// Shell File Operations
'////
#IF NOT %DEF(%FO_MOVE) ' //these need to be kept in sync with the ones in shlobj.h
%EQUATE `FO_MOVE = &H0001
%EQUATE `FO_COPY = &H0002
%EQUATE `FO_DELETE = &H0003
%EQUATE `FO_RENAME = &H0004
%EQUATE `FOF_MULTIDESTFILES = &H0001
%EQUATE `FOF_CONFIRMMOUSE = &H0002
%EQUATE `FOF_SILENT = &H0004 ' // don't create progress/report
%EQUATE `FOF_RENAMEONCOLLISION = &H0008
%EQUATE `FOF_NOCONFIRMATION = &H0010 ' // Don't prompt the user.
%EQUATE `FOF_WANTMAPPINGHANDLE = &H0020 ' // Fill in SHFILEOPSTRUCT.hNameMappings
 ' // Must be freed using SHFreeNameMappings
%EQUATE `FOF_ALLOWUNDO = &H0040
%EQUATE `FOF_FILESONLY = &H0080 ' // on *.*, do only files
%EQUATE `FOF_SIMPLEPROGRESS = &H0100 ' // means don't show names of files
%EQUATE `FOF_NOCONFIRMMKDIR = &H0200 ' // don't confirm making any needed dirs
%EQUATE `FOF_NOERRORUI = &H0400 ' // don't put up error UI
%EQUATE `FOF_NOCOPYSECURITYATTRIBS = &H0800 ' // dont copy NT file Security Attributes
%EQUATE `FOF_NORECURSION = &H1000 ' // don't recurse into directories.
'#if (_WIN32_IE >= &H0500)
%EQUATE `FOF_NO_CONNECTED_ELEMENTS = &H2000 ' // don't operate on connected elements.
%EQUATE `FOF_WANTNUKEWARNING = &H4000 ' // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
'#endif ' // (_WIN32_IE >= &H500)
'#if (_WIN32_WINNT >= &H0501)
%EQUATE `FOF_NORECURSEREPARSE = &H8000 ' // treat reparse points as objects, not containers
'#endif ' // (_WIN32_WINNT >= &H501)
%EQUATE `FOF_NO_UI = %FOF_SILENT OR %FOF_NOCONFIRMATION OR %FOF_NOERRORUI OR %FOF_NOCONFIRMMKDIR ' // don't display any UI at all
'typedef WORD FILEOP_FLAGS;
%EQUATE `PO_DELETE = &H0013 ' // printer is being deleted
%EQUATE `PO_RENAME = &H0014 ' // printer is being renamed
%EQUATE `PO_PORTCHANGE = &H0020 ' // port this printer connected to is being changed
 ' // if this id is set, the strings received by
 ' // the copyhook are a doubly-null terminated
 ' // list of strings. The first is the printer
 ' // name and the second is the printer port.
%EQUATE `PO_REN_PORT = &H0034 ' // PO_RENAME and PO_PORTCHANGE at same time.
'// no POF_ flags currently defined
'typedef WORD PRINTEROP_FLAGS;
#ENDIF ' // FO_MOVE
'// implicit parameters are:
'// if pFrom or pTo are unqualified names the current directories are
'// taken from the global current drive/directory settings managed
'// by Get/SetCurrentDrive/Directory
'//
'// the global confirmation settings
' // Size = 30 bytes
TYPE SHFILEOPSTRUCTA BYTE ' Must not be DWORD aligned
 hwnd AS DWORD ' HWND hwnd
 wFunc AS DWORD ' UINT wFunc
 pFrom AS ASCIIZ PTR ' LPCSTR pFrom
 pTo AS ASCIIZ PTR ' LPCSTR pTo
 fFlags AS WORD ' FILEOP_FLAGS fFlags
 fAnyOperationsAborted AS LONG ' BOOL fAnyOperationsAborted
 hNameMappings AS DWORD ' LPVOID hNameMappings
 lpszProgressTitle AS ASCIIZ PTR ' LPCSTR lpszProgressTitle // only used if FOF_SIMPLEPROGRESS
END TYPE
' // Size = 30 bytes
TYPE SHFILEOPSTRUCTW BYTE ' Must not be DWORD aligned
 hwnd AS DWORD ' HWND hwnd
 wFunc AS DWORD ' UINT wFunc
 pFrom AS WSTRINGZ PTR ' LPCWSTR pFrom
 pTo AS WSTRINGZ PTR ' LPCWSTR pTo
 fFlags AS WORD ' FILEOP_FLAGS fFlags
 fAnyOperationsAborted AS LONG ' BOOL fAnyOperationsAborted
 hNameMappings AS DWORD ' LPVOID hNameMappings
 lpszProgressTitle AS WSTRINGZ PTR ' LPCWSTR lpszProgressTitle // only used if FOF_SIMPLEPROGRESS
END TYPE
#IF %DEF(%UNICODE)
 MACRO SHFILEOPSTRUCT = SHFILEOPSTRUCTW
#ELSE
 MACRO SHFILEOPSTRUCT = SHFILEOPSTRUCTA
#ENDIF
DECLARE FUNCTION SHFileOperationA LIB "shell32.dll" ALIAS "SHFileOperationA" ( BYREF lpFileOp AS SHFILEOPSTRUCTA ) AS LONG ' int
DECLARE FUNCTION SHFileOperationW LIB "shell32.dll" ALIAS "SHFileOperationW" ( BYREF lpFileOp AS SHFILEOPSTRUCTW ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO SHFileOperation = SHFileOperationW
#ELSE
 MACRO SHFileOperation = SHFileOperationA
#ENDIF
DECLARE SUB SHFreeNameMappings LIB "shell32.dll" ALIAS "SHFreeNameMappings" ( BYVAL hNameMappings AS QUAD ' HANDLE hNameMappings ) ' void
' // Size = 16 bytes
TYPE SHNAMEMAPPINGA BYTE
 pszOldPath AS ASCIIZ PTR ' LPSTR pszOldPath
 pszNewPath AS ASCIIZ PTR ' LPSTR pszNewPath
 cchOldPath AS LONG ' int cchOldPath
 cchNewPath AS LONG ' int cchNewPath
END TYPE
' // Size = 16 bytes
TYPE SHNAMEMAPPINGW BYTE
 pszOldPath AS WSTRINGZ PTR ' LPWSTR pszOldPath
 pszNewPath AS WSTRINGZ PTR ' LPWSTR pszNewPath
 cchOldPath AS LONG ' int cchOldPath
 cchNewPath AS LONG ' int cchNewPath
END TYPE
#IF %DEF(%UNICODE)
 MACRO SHNAMEMAPPING = SHNAMEMAPPINGW
#ELSE
 MACRO SHNAMEMAPPING = SHNAMEMAPPINGA
#ENDIF
'////
'//// End Shell File Operations
'////
'////
'//// Begin ShellExecuteEx and family
'////
'/* ShellExecute() and ShellExecuteEx() error codes */
'/* regular WinExec() codes */
%EQUATE `SE_ERR_FNF = 2 ' // file not found
%EQUATE `SE_ERR_PNF = 3 ' // path not found
%EQUATE `SE_ERR_ACCESSDENIED = 5 ' // access denied
%EQUATE `SE_ERR_OOM = 8 ' // out of memory
%EQUATE `SE_ERR_DLLNOTFOUND = 32
'#endif /* WINVER >= 0x0400 */
'/* error values for ShellExecute() beyond the regular WinExec() codes */
%EQUATE `SE_ERR_SHARE = 26
%EQUATE `SE_ERR_ASSOCINCOMPLETE = 27
%EQUATE `SE_ERR_DDETIMEOUT = 28
%EQUATE `SE_ERR_DDEFAIL = 29
%EQUATE `SE_ERR_DDEBUSY = 30
%EQUATE `SE_ERR_NOASSOC = 31
'#if(WINVER >= 0x0400)
'// Note CLASSKEY overrides CLASSNAME
%EQUATE `SEE_MASK_DEFAULT = &H00000000
%EQUATE `SEE_MASK_CLASSNAME = &H00000001 ' // SHELLEXECUTEINFO.lpClass is valid
%EQUATE `SEE_MASK_CLASSKEY = &H00000003 ' // SHELLEXECUTEINFO.hkeyClass is valid
'// Note SEE_MASK_INVOKEIDLIST(0xC) implies SEE_MASK_IDLIST(0x04)
%EQUATE `SEE_MASK_IDLIST = &H00000004 ' // SHELLEXECUTEINFO.lpIDList is valid
%EQUATE `SEE_MASK_INVOKEIDLIST = &H0000000c ' // enable IContextMenu based verbs
'#if (NTDDI_VERSION < NTDDI_VISTA)
%EQUATE `SEE_MASK_ICON = &H00000010 ' // not used
'#endif // (NTDDI_VERSION < NTDDI_VISTA)
%EQUATE `SEE_MASK_HOTKEY = &H00000020 ' // SHELLEXECUTEINFO.dwHotKey is valid
%EQUATE `SEE_MASK_NOCLOSEPROCESS = &H00000040 ' // SHELLEXECUTEINFO.hProcess
%EQUATE `SEE_MASK_CONNECTNETDRV = &H00000080 ' // enables re-connecting disconnected network drives
%EQUATE `SEE_MASK_NOASYNC = &H00000100 ' // block on the call until the invoke has completed, use for callers that exit after calling ShellExecuteEx()
%EQUATE `SEE_MASK_FLAG_DDEWAIT = %SEE_MASK_NOASYNC ' // Use SEE_MASK_NOASYNC instead of SEE_MASK_FLAG_DDEWAIT as it more accuratly describes the behavior
%EQUATE `SEE_MASK_DOENVSUBST = &H00000200 ' // indicates that SHELLEXECUTEINFO.lpFile contains env vars that should be expanded
%EQUATE `SEE_MASK_FLAG_NO_UI = &H00000400 ' // disable UI including error messages
%EQUATE `SEE_MASK_UNICODE = &H00004000
%EQUATE `SEE_MASK_NO_CONSOLE = &H00008000
%EQUATE `SEE_MASK_ASYNCOK = &H00100000
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
%EQUATE `SEE_MASK_HMONITOR = &H00200000 ' // SHELLEXECUTEINFO.hMonitor
'#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
'#if (NTDDI_VERSION >= NTDDI_WINXPSP1)
%EQUATE `SEE_MASK_NOZONECHECKS = &H00800000
'#endif // (NTDDI_VERSION >= NTDDI_WINXPSP1)
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
%EQUATE `SEE_MASK_NOQUERYCLASSSTORE = &H01000000
%EQUATE `SEE_MASK_WAITFORINPUTIDLE = &H02000000
'#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
'#if (NTDDI_VERSION >= NTDDI_WINXP)
%EQUATE `SEE_MASK_FLAG_LOG_USAGE = &H04000000
'#endif // (NTDDI_VERSION >= NTDDI_WINXP)
' // Size = 4 bytes
UNION SHELLEXECUTEINFO_UNION BYTE
 hIcon AS DWORD ' HANDLE hIcon
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
 hMonitor AS DWORD ' HANDLE hMonitor
'#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
END UNION
' // Size = 60 bytes
TYPE SHELLEXECUTEINFOA BYTE
 cbSize AS DWORD ' DWORD // in, required, sizeof of this structure
 fMask AS DWORD ' ULONG // in, SEE_MASK_XXX values
 hwnd AS DWORD ' HWND // in, optional
 lpVerb AS ASCIIZ PTR ' LPCSTR // in, optional when unspecified the default verb is choosen
 lpFile AS ASCIIZ PTR ' LPCSTR // in, either this value or lpIDList must be specified
 lpParameters AS ASCIIZ PTR ' LPCSTR // in, optional
 lpDirectory AS ASCIIZ PTR ' LPCSTR // in, optional
 nShow AS LONG ' int // in, required
 hInstApp AS DWORD ' HINSTANCE // out when SEE_MASK_NOCLOSEPROCESS is specified
 lpIDList AS DWORD ' LPVOID // in, valid when SEE_MASK_IDLIST is specified, PCIDLIST_ABSOLUTE, for use with SEE_MASK_IDLIST & SEE_MASK_INVOKEIDLIST
 lpClass AS ASCIIZ PTR ' LPCSTR // in, valid when SEE_MASK_CLASSNAME is specified
 hkeyClass AS DWORD ' HKEY // in, valid when SEE_MASK_CLASSKEY is specified
 dwHotKey AS DWORD ' DWORD // in, valid when SEE_MASK_HOTKEY is specified
 SHELLEXECUTEINFO_UNION
 hProcess AS DWORD ' HANDLE // out, valid when SEE_MASK_NOCLOSEPROCESS specified
END TYPE
' // Size = 60 bytes
TYPE SHELLEXECUTEINFOW BYTE
 cbSize AS DWORD ' DWORD // in, required, sizeof of this structure
 fMask AS DWORD ' ULONG // in, SEE_MASK_XXX values
 hwnd AS DWORD ' HWND // in, optional
 lpVerb AS WSTRINGZ PTR ' LPCWSTR // in, optional when unspecified the default verb is choosen
 lpFile AS WSTRINGZ PTR ' LPCWSTR // in, either this value or lpIDList must be specified
 lpParameters AS WSTRINGZ PTR ' LPCWSTR // in, optional
 lpDirectory AS WSTRINGZ PTR ' LPCWSTR // in, optional
 nShow AS LONG ' int // in, required
 hInstApp AS DWORD ' HINSTANCE // out when SEE_MASK_NOCLOSEPROCESS is specified
 lpIDList AS DWORD ' LPVOID // in, valid when SEE_MASK_IDLIST is specified, PCIDLIST_ABSOLUTE, for use with SEE_MASK_IDLIST & SEE_MASK_INVOKEIDLIST
 lpClass AS WSTRINGZ PTR ' LPCWSTR // in, valid when SEE_MASK_CLASSNAME is specified
 hkeyClass AS DWORD ' HKEY // in, valid when SEE_MASK_CLASSKEY is specified
 dwHotKey AS DWORD ' DWORD // in, valid when SEE_MASK_HOTKEY is specified
 SHELLEXECUTEINFO_UNION
 hProcess AS DWORD ' HANDLE // out, valid when SEE_MASK_NOCLOSEPROCESS specified
END TYPE
#IF %DEF(%UNICODE)
 MACRO SHELLEXECUTEINFO = SHELLEXECUTEINFOW
#ELSE
 MACRO SHELLEXECUTEINFO = SHELLEXECUTEINFOA
#ENDIF
DECLARE FUNCTION ShellExecuteExA LIB "shell32.dll" ALIAS "ShellExecuteExA" ( BYREF lpExecInfo AS SHELLEXECUTEINFOA ) AS LONG
DECLARE FUNCTION ShellExecuteExW LIB "shell32.dll" ALIAS "ShellExecuteExW" ( BYREF lpExecInfo AS SHELLEXECUTEINFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO ShellExecuteEx = ShellExecuteExW
#ELSE
 MACRO ShellExecuteEx = ShellExecuteExA
#ENDIF
' Not implemented
'DECLARE SUB WinExecError LIB "shell32.dll" ALIAS "WinExecErrorA" ( ' BYVAL hWnd AS DWORD
' , BYVAL error AS LONG
' , BYREF lpstrFileName AS ASCIIZ
' , BYREF lpstrTitle AS ASCIIZ
' ) ' void
' Not implemented
'DECLARE SUB WinExecErrorW LIB "shell32.dll" ALIAS "WinExecErrorW" ( ' BYVAL hWnd AS DWORD
' , BYVAL error AS LONG
' , BYREF lpstrFileName AS WSTRINGZ
' , BYREF lpstrTitle AS WSTRINGZ
' ) ' void
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
'// deprecated, no longer implemented
'// SHCreateProcessAsUser()
' // Size = 52 bytes
TYPE SHCREATEPROCESSINFOW BYTE
 cbSize AS DWORD ' DWORD cbSize
 fMask AS DWORD ' ULONG fMask
 hwnd AS DWORD ' HWND hwnd
 pszFile AS WSTRINGZ PTR ' LPCWSTR pszFile
 pszParameters AS WSTRINGZ PTR ' LPCWSTR pszParameters
 pszCurrentDirectory AS WSTRINGZ PTR ' LPCWSTR pszCurrentDirectory
 hUserToken AS DWORD ' IN HANDLE hUserToken
 lpProcessAttributes AS SECURITY_ATTRIBUTES PTR ' IN LPSECURITY_ATTRIBUTES lpProcessAttributes
 lpThreadAttributes AS SECURITY_ATTRIBUTES PTR ' IN LPSECURITY_ATTRIBUTES lpThreadAttributes
 bInheritHandles AS LONG ' IN BOOL bInheritHandles
 dwCreationFlags AS DWORD ' IN DWORD dwCreationFlags
 lpStartupInfo AS STARTUPINFOW PTR ' IN LPSTARTUPINFOW lpStartupInfo
 lpProcessInformation AS PROCESS_INFORMATION PTR ' OUT LPPROCESS_INFORMATION lpProcessInformation
END TYPE
MACRO SHCREATEPROCESSINFO = SHCREATEPROCESSINFOW
DECLARE FUNCTION SHCreateProcessAsUserW LIB "shell32.dll" ALIAS "SHCreateProcessAsUserW" ( BYREF pscpi AS SHCREATEPROCESSINFOW ) AS LONG
MACRO SHCreateProcessAsUser = SHCreateProcessAsUserW
'#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
'#if (NTDDI_VERSION >= NTDDI_VISTA)
DECLARE FUNCTION SHEvaluateSystemCommandTemplate LIB "shell32.dll" ALIAS "SHEvaluateSystemCommandTemplate" ( BYREF pszCmdTemplate AS WSTRINGZ , BYREF ppszApplication AS ANY , OPTIONAL BYREF ppszCommandLine AS ANY , OPTIONAL BYREF ppszParameters AS ANY ) AS LONG
'// used for implementing IShellFolder::GetUIObject(IID_IQueryAssociations)
'// designed for namespace extensions with registered extensible types
'// SHCreateDefaultContextMenu() and others use IQueryAssociations to build up data sets
' enum ASSOCCLASS
%EQUATE `ASSOCCLASS_SHELL_KEY = 0 ' // hkeyClass
%EQUATE `ASSOCCLASS_PROGID_KEY = 1 ' // hkeyClass
%EQUATE `ASSOCCLASS_PROGID_STR = 2 ' // pszClass (HKCR\pszClass)
%EQUATE `ASSOCCLASS_CLSID_KEY = 3 ' // hkeyClass
%EQUATE `ASSOCCLASS_CLSID_STR = 4 ' // pszClass (HKCR\CLSID\pszClass)
%EQUATE `ASSOCCLASS_APP_KEY = 5 ' // hkeyClass
%EQUATE `ASSOCCLASS_APP_STR = 6 ' // pszClass (HKCR\Applications\PathFindFileName(pszClass))
%EQUATE `ASSOCCLASS_SYSTEM_STR = 7 ' // pszClass
%EQUATE `ASSOCCLASS_FOLDER = 8 ' // none
%EQUATE `ASSOCCLASS_STAR = 9 ' // none
' // Size = 12 bytes
TYPE ASSOCIATIONELEMENT BYTE
 ac AS LONG ' ASSOCCLASS // required
 hkClass AS DWORD ' HKEY // may be NULL
 pszClass AS WSTRINGZ PTR ' PCWSTR // may be NULL
END TYPE
'// the object returned from this API implements IQueryAssociations
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AssocCreateForClasses LIB "Shell32.dll" ALIAS "AssocCreateForClasses" (BYVAL rgClasses AS ASSOCIATIONELEMENT PTR, BYVAL cClasses AS QUAD, riid AS GUID, ppv AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION AssocCreateForClasses LIB "shell32.dll" ALIAS "AssocCreateForClasses" ( BYREF rgClasses AS ASSOCIATIONELEMENT , BYVAL cClasses AS QUAD , BYREF riid AS GUID , BYREF ppv AS ANY ) AS LONG
#ENDIF
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'////
'//// End ShellExecuteEx and family
'////
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
'//
'// RecycleBin
'//
'// struct for query recycle bin info
'typedef struct _SHQUERYRBINFO {
' DWORD cbSize;
'#if !defined(_MAC) || defined(_MAC_INT_64)
'#else
' DWORDLONG i64Size;
' DWORDLONG i64NumItems;
'#endif
'} SHQUERYRBINFO, *LPSHQUERYRBINFO;
' // Size = 20 bytes
TYPE SHQUERYRBINFO BYTE
 cbSize AS DWORD ' DWORD cbSize
 i64Size AS QUAD
 i64NumItems AS QUAD
END TYPE
'// flags for SHEmptyRecycleBin
'//
%EQUATE `SHERB_NOCONFIRMATION = &H00000001
%EQUATE `SHERB_NOPROGRESSUI = &H00000002
%EQUATE `SHERB_NOSOUND = &H00000004
DECLARE FUNCTION SHQueryRecycleBinA LIB "shell32.dll" ALIAS "SHQueryRecycleBinA" ( BYREF pszRootPath AS ASCIIZ , BYREF pSHQueryRBInfo AS SHQUERYRBINFO ) AS LONG
DECLARE FUNCTION SHQueryRecycleBinW LIB "shell32.dll" ALIAS "SHQueryRecycleBinW" ( BYREF pszRootPath AS WSTRINGZ
 , BYREF pSHQueryRBInfo AS SHQUERYRBINFO
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SHQueryRecycleBin = SHQueryRecycleBinW
#ELSE
 MACRO SHQueryRecycleBin = SHQueryRecycleBinA
#ENDIF
DECLARE FUNCTION SHEmptyRecycleBinA LIB "shell32.dll" ALIAS "SHEmptyRecycleBinA" ( BYVAL hWnd AS QUAD , BYREF pszRootPath AS ASCIIZ , BYVAL dwFlags AS QUAD ) AS LONG
DECLARE FUNCTION SHEmptyRecycleBinW LIB "shell32.dll" ALIAS "SHEmptyRecycleBinW" ( BYVAL hWnd AS QUAD
 , BYREF pszRootPath AS WSTRINGZ
 , BYVAL dwFlags AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SHEmptyRecycleBin = SHEmptyRecycleBinW
#ELSE
 MACRO SHEmptyRecycleBin = SHEmptyRecycleBinA
#ENDIF
'////
'//// end of RecycleBin
'#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
'////
'//// Taskbar notification definitions
'////
'#if (NTDDI_VERSION >= NTDDI_VISTA)
' enum QUERY_USER_NOTIFICATION_STATE
%EQUATE `QUNS_NOT_PRESENT = 1 ' // The user is not present. Heuristic check for modes like: screen saver, locked machine, non-active FUS session
%EQUATE `QUNS_BUSY = 2 ' // The user is busy. Heuristic check for modes like: full-screen app
%EQUATE `QUNS_RUNNING_D3D_FULL_SCREEN = 3 ' // full-screen (exlusive-mode) D3D app
%EQUATE `QUNS_PRESENTATION_MODE = 4 ' // Windows presentation mode (laptop feature) is turned on
%EQUATE `QUNS_ACCEPTS_NOTIFICATIONS = 5 ' // none of the above
'#if (NTDDI_VERSION >= NTDDI_WIN7)
%EQUATE `QUNS_QUIET_TIME = 6 ' // We are in OOBE quiet period
'#endif
DECLARE FUNCTION SHQueryUserNotificationState LIB "shell32.dll" ALIAS "SHQueryUserNotificationState" ( BYREF pquns AS LONG ) AS LONG
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'#if (NTDDI_VERSION >= NTDDI_WIN7)
'// This api retrieves an IPropertyStore that stores the window's properties.
DECLARE FUNCTION SHGetPropertyStoreForWindow LIB "shell32.dll" ALIAS "SHGetPropertyStoreForWindow" ( BYVAL hwnd AS QUAD , BYREF riid AS GUID , BYREF ppv AS ANY ) AS LONG
'#endif
' // Size = 4 bytes
UNION NOTIFYICONDATA5_UNION BYTE
 uTimeout AS DWORD ' UINT uTimeout
 uVersion AS DWORD ' UINT uVersion // used with NIM_SETVERSION, values 0, 3 and 4
END UNION
' // Size = 508 bytes
TYPE NOTIFYICONDATAA BYTE
 cbSize AS DWORD ' DWORD cbSize
 hwnd AS DWORD ' HWND hWnd
 uID AS DWORD ' UINT uID
 uFlags AS DWORD ' UINT uFlags
 uCallbackMessage AS DWORD ' UINT uCallbackMessage
 hIcon AS DWORD ' HICON hIcon
'#if (NTDDI_VERSION < NTDDI_WIN2K)
#IF %WINVER < &H0500
 szTip AS ASCIIZ * 64 ' CHAR szTip[64]
#ENDIF
'#endif
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
#IF %WINVER >= &H0500
 szTip AS ASCIIZ * 128 ' CHAR szTip[128]
 dwState AS DWORD ' DWORD dwState
 dwStateMask AS DWORD ' DWORD dwStateMask
 szInfo AS ASCIIZ * 256 ' CHAR szInfo[256]
 NOTIFYICONDATA5_UNION
 szInfoTitle AS ASCIIZ * 64 ' CHAR szInfoTitle[64]
 dwInfoFlags AS DWORD ' DWORD dwInfoFlags
#ENDIF
'#endif
'#if (NTDDI_VERSION >= NTDDI_WINXP)
#IF %WINVER >= &H0501
 guidItem AS GUID ' GUID guidItem
#ENDIF
'#endif
'#if (NTDDI_VERSION >= NTDDI_VISTA)
#IF %WINVER >= &H0600
 hBalloonIcon AS DWORD ' HICON
#ENDIF
'#endif
END TYPE
' // Size = 956 bytes
TYPE NOTIFYICONDATAW BYTE
 cbSize AS DWORD ' DWORD cbSize
 hwnd AS DWORD ' HWND hWnd
 uID AS DWORD ' UINT uID
 uFlags AS DWORD ' UINT uFlags
 uCallbackMessage AS DWORD ' UINT uCallbackMessage
 hIcon AS DWORD ' HICON hIcon
'#if (NTDDI_VERSION < NTDDI_WIN2K)
#IF %WINVER < &H0500
 szTip AS WSTRINGZ * 64 ' WCHAR szTip[64]
#ENDIF
'#endif
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
#IF %WINVER >= &H0500
 szTip AS WSTRINGZ * 128 ' WCHAR szTip[128]
 dwState AS DWORD ' DWORD dwState
 dwStateMask AS DWORD ' DWORD dwStateMask
 szInfo AS WSTRINGZ * 256 ' WCHAR szInfo[256]
 NOTIFYICONDATA5_UNION
 szInfoTitle AS WSTRINGZ * 64 ' WCHAR szInfoTitle[64]
 dwInfoFlags AS DWORD ' DWORD dwInfoFlags
#ENDIF
'#endif
'#if (NTDDI_VERSION >= NTDDI_WINXP)
#IF %WINVER >= &H0501
 guidItem AS GUID ' GUID guidItem
#ENDIF
'#endif
'#if (NTDDI_VERSION >= NTDDI_VISTA)
#IF %WINVER >= &H0600
 hBalloonIcon AS DWORD ' HICON
#ENDIF
'#endif
END TYPE
#IF %DEF(%UNICODE)
 MACRO NOTIFYICONDATA = NOTIFYICONDATAW
#ELSE
 MACRO NOTIFYICONDATA = NOTIFYICONDATAA
#ENDIF
%EQUATE `NOTIFYICONDATAA_V1_SIZE = 88
%EQUATE `NOTIFYICONDATAW_V1_SIZE = 152
#IF %DEF(%UNICODE)
%EQUATE `NOTIFYICONDATA_V1_SIZE = %NOTIFYICONDATAW_V1_SIZE
#ELSE
%EQUATE `NOTIFYICONDATA_V1_SIZE = %NOTIFYICONDATAA_V1_SIZE
#ENDIF
%EQUATE `NOTIFYICONDATAA_V2_SIZE = 488
%EQUATE `NOTIFYICONDATAW_V2_SIZE = 936
#IF %DEF(%UNICODE)
%EQUATE `NOTIFYICONDATA_V2_SIZE = %NOTIFYICONDATAW_V2_SIZE
#ELSE
%EQUATE `NOTIFYICONDATA_V2_SIZE = %NOTIFYICONDATAA_V2_SIZE
#ENDIF
%EQUATE `NOTIFYICONDATAA_V3_SIZE = 504
%EQUATE `NOTIFYICONDATAW_V3_SIZE = 952
#IF %DEF(%UNICODE)
%EQUATE `NOTIFYICONDATA_V3_SIZE = %NOTIFYICONDATAW_V3_SIZE
#ELSE
%EQUATE `NOTIFYICONDATA_V3_SIZE = %NOTIFYICONDATAA_V3_SIZE
#ENDIF
'#if (_WIN32_IE >= 0x0500)
%EQUATE `NIN_SELECT = %WM_USER + 0
%EQUATE `NINF_KEY = &H1
%EQUATE `NIN_KEYSELECT = %NIN_SELECT OR %NINF_KEY
'#endif
'#if (_WIN32_IE >= 0x0501)
%EQUATE `NIN_BALLOONSHOW = %WM_USER + 2
%EQUATE `NIN_BALLOONHIDE = %WM_USER + 3
%EQUATE `NIN_BALLOONTIMEOUT = %WM_USER + 4
%EQUATE `NIN_BALLOONUSERCLICK = %WM_USER + 5
'#endif
'#if (NTDDI_VERSION >= NTDDI_VISTA)
%EQUATE `NIN_POPUPOPEN = %WM_USER + 6
%EQUATE `NIN_POPUPCLOSE = %WM_USER + 7
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'#if (NTDDI_VERSION >= NTDDI_WIN7)
'#endif // (NTDDI_VERSION >= NTDDI_WIN7)
%EQUATE `NIM_ADD = &H00000000
%EQUATE `NIM_MODIFY = &H00000001
%EQUATE `NIM_DELETE = &H00000002
'#if (_WIN32_IE >= &H0500)
%EQUATE `NIM_SETFOCUS = &H00000003
%EQUATE `NIM_SETVERSION = &H00000004
'// set NOTIFYICONDATA.uVersion with 0, 3 or 4
'// please read the documentation on the behavior difference that the different versions imply
%EQUATE `NOTIFYICON_VERSION = 3
'#if (NTDDI_VERSION >= NTDDI_VISTA)
%EQUATE `NOTIFYICON_VERSION_4 = 4
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'#endif
%EQUATE `NIF_MESSAGE = &H00000001
%EQUATE `NIF_ICON = &H00000002
%EQUATE `NIF_TIP = &H00000004
'#if (_WIN32_IE >= &H0500)
%EQUATE `NIF_STATE = &H00000008
%EQUATE `NIF_INFO = &H00000010
'#endif
'#if (_WIN32_IE >= &H600)
%EQUATE `NIF_GUID = &H00000020
'#endif
'#if (NTDDI_VERSION >= NTDDI_VISTA)
%EQUATE `NIF_REALTIME = &H00000040
%EQUATE `NIF_SHOWTIP = &H00000080
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'#if (_WIN32_IE >= 0x0500)
%EQUATE `NIS_HIDDEN = &H00000001
%EQUATE `NIS_SHAREDICON = &H00000002
'// says this is the source of a shared icon
'// Notify Icon Infotip flags
%EQUATE `NIIF_NONE = &H00000000
'// icon flags are mutually exclusive
'// and take only the lowest 2 bits
%EQUATE `NIIF_INFO = &H00000001
%EQUATE `NIIF_WARNING = &H00000002
%EQUATE `NIIF_ERROR = &H00000003
'#if (NTDDI_VERSION >= NTDDI_XPSP2) // also available in NTDDI_WS03SP1
%EQUATE `NIIF_USER = &H00000004
'#endif // (NTDDI_VERSION >= NTDDI_XPSP2)
%EQUATE `NIIF_ICON_MASK = &H0000000F
'#if (_WIN32_IE >= &H0501)
%EQUATE `NIIF_NOSOUND = &H00000010
'#endif
'#endif
'#if (NTDDI_VERSION >= NTDDI_VISTA)
%EQUATE `NIIF_LARGE_ICON = &H00000020
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'#if (NTDDI_VERSION >= NTDDI_WIN7)
%EQUATE `NIIF_RESPECT_QUIET_TIME = &H00000080
'#endif // (NTDDI_VERSION >= NTDDI_WIN7)
' // Size = 28 bytes
TYPE NOTIFYICONIDENTIFIER BYTE
 cbSize AS DWORD
 hWnd AS DWORD
 uID AS DWORD ' UINT
 guidItem AS GUID ' GUID
END TYPE
DECLARE FUNCTION Shell_NotifyIconA LIB "shell32.dll" ALIAS "Shell_NotifyIconA" ( BYVAL dwMessage AS QUAD , BYREF lpdata AS NOTIFYICONDATAA ) AS LONG
DECLARE FUNCTION Shell_NotifyIconW LIB "shell32.dll" ALIAS "Shell_NotifyIconW" ( BYVAL dwMessage AS QUAD
 , BYREF lpdata AS NOTIFYICONDATAW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO Shell_NotifyIcon = Shell_NotifyIconW
#ELSE
 MACRO Shell_NotifyIcon = Shell_NotifyIconA
#ENDIF
DECLARE FUNCTION Shell_NotifyIconGetRect LIB "shell32.dll" ALIAS "Shell_NotifyIconGetRect" ( BYREF identifier AS NOTIFYICONIDENTIFIER , BYREF iconLocation AS RECT ) AS LONG
'////
'//// End Taskbar Notification Icons
'////
#IF NOT %DEF(%SHFILEINFO_DEFINED)
 %SHFILEINFO_DEFINED = 1
'////
'//// Begin SHGetFileInfo
'////
'/*
' * The SHGetFileInfo API provides an easy way to get attributes
' * for a file given a pathname.
' *
' * PARAMETERS
' *
' * pszPath file name to get info about
' * dwFileAttributes file attribs, only used with SHGFI_USEFILEATTRIBUTES
' * psfi place to return file info
' * cbFileInfo size of structure
' * uFlags flags
' *
' * RETURN
' * TRUE if things worked
' */
' // Size = 352 bytes
TYPE SHFILEINFOA BYTE
 hIcon AS DWORD ' HICON hIcon // out: icon
 iIcon AS LONG ' int iIcon // out: icon index
 dwAttributes AS DWORD ' DWORD dwAttributes // out: SFGAO_ flags
 szDisplayName AS ASCIIZ * %MAX_PATH ' CHAR szDisplayName[MAX_PATH] // out: display name (or path)
 szTypeName AS ASCIIZ * 80 ' CHAR szTypeName[80] // out: type name
END TYPE
' // Size = 692 bytes
TYPE SHFILEINFOW BYTE
 hIcon AS DWORD ' HICON hIcon // out: icon
 iIcon AS LONG ' int iIcon // out: icon index
 dwAttributes AS DWORD ' DWORD dwAttributes // out: SFGAO_ flags
 szDisplayName AS WSTRINGZ * %MAX_PATH ' WCHAR szDisplayName[MAX_PATH] // out: display name (or path)
 szTypeName AS WSTRINGZ * 80 ' WCHAR szTypeName[80] // out: type name
END TYPE
#IF %DEF(%UNICODE)
 MACRO SHFILEINFO = SHFILEINFOW
#ELSE
 MACRO SHFILEINFO = SHFILEINFOA
#ENDIF
'// NOTE: This is also in shlwapi.h. Please keep in synch.
#ENDIF ' // !SHFILEINFO_DEFINED
%EQUATE `SHGFI_ICON = &H000000100 ' // get icon
%EQUATE `SHGFI_DISPLAYNAME = &H000000200 ' // get display name
%EQUATE `SHGFI_TYPENAME = &H000000400 ' // get type name
%EQUATE `SHGFI_ATTRIBUTES = &H000000800 ' // get attributes
%EQUATE `SHGFI_ICONLOCATION = &H000001000 ' // get icon location
%EQUATE `SHGFI_EXETYPE = &H000002000 ' // return exe type
%EQUATE `SHGFI_SYSICONINDEX = &H000004000 ' // get system icon index
%EQUATE `SHGFI_LINKOVERLAY = &H000008000 ' // put a link overlay on icon
%EQUATE `SHGFI_SELECTED = &H000010000 ' // show icon in selected state
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
%EQUATE `SHGFI_ATTR_SPECIFIED = &H000020000 ' // get only specified attributes
'#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
%EQUATE `SHGFI_LARGEICON = &H000000000 ' // get large icon
%EQUATE `SHGFI_SMALLICON = &H000000001 ' // get small icon
%EQUATE `SHGFI_OPENICON = &H000000002 ' // get open icon
%EQUATE `SHGFI_SHELLICONSIZE = &H000000004 ' // get shell size icon
%EQUATE `SHGFI_PIDL = &H000000008 ' // pszPath is a pidl
%EQUATE `SHGFI_USEFILEATTRIBUTES = &H000000010 ' // use passed dwFileAttribute
'#if (_WIN32_IE >= &H0500)
%EQUATE `SHGFI_ADDOVERLAYS = &H000000020 ' // apply the appropriate overlays
%EQUATE `SHGFI_OVERLAYINDEX = &H000000040 ' // Get the index of the overlay
 ' // in the upper 8 bits of the iIcon
'#endif
DECLARE FUNCTION SHGetFileInfoA LIB "shell32.dll" ALIAS "SHGetFileInfoA" ( BYREF pszPath AS ASCIIZ , BYVAL dwFileAttributes AS QUAD , BYREF psfi AS SHFILEINFOA , BYVAL cbFileInfo AS QUAD , BYVAL uFlags AS QUAD ) AS QUAD ' DWORD_PTR
DECLARE FUNCTION SHGetFileInfoW LIB "shell32.dll" ALIAS "SHGetFileInfoW" ( BYREF pszPath AS WSTRINGZ , BYVAL dwFileAttributes AS QUAD , BYREF psfi AS SHFILEINFOW , BYVAL cbFileInfo AS QUAD , BYVAL uFlags AS QUAD ) AS QUAD ' DWORD_PTR
#IF %DEF(%UNICODE)
 MACRO SHGetFileInfo = SHGetFileInfoW
#ELSE
 MACRO SHGetFileInfo = SHGetFileInfoA
#ENDIF
'#if (NTDDI_VERSION >= NTDDI_VISTA)
' // Size = 536 bytes
TYPE SHSTOCKICONINFO BYTE
 cbSize AS DWORD
 hIcon AS DWORD ' HICON
 iSysImageIndex AS LONG ' int
 iIcon AS LONG ' int
 szPath AS WSTRINGZ * %MAX_PATH ' WCHAR
END TYPE
%EQUATE `SHGSI_ICONLOCATION = 0 ' // you always get the icon location
%EQUATE `SHGSI_ICON = %SHGFI_ICON
%EQUATE `SHGSI_SYSICONINDEX = %SHGFI_SYSICONINDEX
%EQUATE `SHGSI_LINKOVERLAY = %SHGFI_LINKOVERLAY
%EQUATE `SHGSI_SELECTED = %SHGFI_SELECTED
%EQUATE `SHGSI_LARGEICON = %SHGFI_LARGEICON
%EQUATE `SHGSI_SMALLICON = %SHGFI_SMALLICON
%EQUATE `SHGSI_SHELLICONSIZE = %SHGFI_SHELLICONSIZE
'// Shell icons
' enum SHSTOCKICONID
%EQUATE `SIID_DOCNOASSOC = 0 ' // document (blank page) no associated program
%EQUATE `SIID_DOCASSOC = 1 ' // document with an associated program
%EQUATE `SIID_APPLICATION = 2 ' // generic application with no custom icon
%EQUATE `SIID_FOLDER = 3 ' // folder (closed)
%EQUATE `SIID_FOLDEROPEN = 4 ' // folder (open)
%EQUATE `SIID_DRIVE525 = 5 ' // 5.25" floppy disk drive
%EQUATE `SIID_DRIVE35 = 6 ' // 3.5" floppy disk drive
%EQUATE `SIID_DRIVEREMOVE = 7 ' // removable drive
%EQUATE `SIID_DRIVEFIXED = 8 ' // fixed (hard disk) drive
%EQUATE `SIID_DRIVENET = 9 ' // network drive
%EQUATE `SIID_DRIVENETDISABLED = 10 ' // disconnected network drive
%EQUATE `SIID_DRIVECD = 11 ' // CD drive
%EQUATE `SIID_DRIVERAM = 12 ' // RAM disk drive
%EQUATE `SIID_WORLD = 13 ' // entire network
%EQUATE `SIID_SERVER = 15 ' // a computer on the network
%EQUATE `SIID_PRINTER = 16 ' // printer
%EQUATE `SIID_MYNETWORK = 17 ' // My network places
%EQUATE `SIID_FIND = 22 ' // Find
%EQUATE `SIID_HELP = 23 ' // Help
%EQUATE `SIID_SHARE = 28 ' // overlay for shared items
%EQUATE `SIID_LINK = 29 ' // overlay for shortcuts to items
%EQUATE `SIID_SLOWFILE = 30 ' // overlay for slow items
%EQUATE `SIID_RECYCLER = 31 ' // empty recycle bin
%EQUATE `SIID_RECYCLERFULL = 32 ' // full recycle bin
%EQUATE `SIID_MEDIACDAUDIO = 40 ' // Audio CD Media
%EQUATE `SIID_LOCK = 47 ' // Security lock
%EQUATE `SIID_AUTOLIST = 49 ' // AutoList
%EQUATE `SIID_PRINTERNET = 50 ' // Network printer
%EQUATE `SIID_SERVERSHARE = 51 ' // Server share
%EQUATE `SIID_PRINTERFAX = 52 ' // Fax printer
%EQUATE `SIID_PRINTERFAXNET = 53 ' // Networked Fax Printer
%EQUATE `SIID_PRINTERFILE = 54 ' // Print to File
%EQUATE `SIID_STACK = 55 ' // Stack
%EQUATE `SIID_MEDIASVCD = 56 ' // SVCD Media
%EQUATE `SIID_STUFFEDFOLDER = 57 ' // Folder containing other items
%EQUATE `SIID_DRIVEUNKNOWN = 58 ' // Unknown drive
%EQUATE `SIID_DRIVEDVD = 59 ' // DVD Drive
%EQUATE `SIID_MEDIADVD = 60 ' // DVD Media
%EQUATE `SIID_MEDIADVDRAM = 61 ' // DVD-RAM Media
%EQUATE `SIID_MEDIADVDRW = 62 ' // DVD-RW Media
%EQUATE `SIID_MEDIADVDR = 63 ' // DVD-R Media
%EQUATE `SIID_MEDIADVDROM = 64 ' // DVD-ROM Media
%EQUATE `SIID_MEDIACDAUDIOPLUS = 65 ' // CD+ (Enhanced CD) Media
%EQUATE `SIID_MEDIACDRW = 66 ' // CD-RW Media
%EQUATE `SIID_MEDIACDR = 67 ' // CD-R Media
%EQUATE `SIID_MEDIACDBURN = 68 ' // Burning CD
%EQUATE `SIID_MEDIABLANKCD = 69 ' // Blank CD Media
%EQUATE `SIID_MEDIACDROM = 70 ' // CD-ROM Media
%EQUATE `SIID_AUDIOFILES = 71 ' // Audio files
%EQUATE `SIID_IMAGEFILES = 72 ' // Image files
%EQUATE `SIID_VIDEOFILES = 73 ' // Video files
%EQUATE `SIID_MIXEDFILES = 74 ' // Mixed files
%EQUATE `SIID_FOLDERBACK = 75 ' // Folder back
%EQUATE `SIID_FOLDERFRONT = 76 ' // Folder front
%EQUATE `SIID_SHIELD = 77 ' // Security shield. Use for UAC prompts only.
%EQUATE `SIID_WARNING = 78 ' // Warning
%EQUATE `SIID_INFO = 79 ' // Informational
%EQUATE `SIID_ERROR = 80 ' // Error
%EQUATE `SIID_KEY = 81 ' // Key / Secure
%EQUATE `SIID_SOFTWARE = 82 ' // Software
%EQUATE `SIID_RENAME = 83 ' // Rename
%EQUATE `SIID_DELETE = 84 ' // Delete
%EQUATE `SIID_MEDIAAUDIODVD = 85 ' // Audio DVD Media
%EQUATE `SIID_MEDIAMOVIEDVD = 86 ' // Movie DVD Media
%EQUATE `SIID_MEDIAENHANCEDCD = 87 ' // Enhanced CD Media
%EQUATE `SIID_MEDIAENHANCEDDVD = 88 ' // Enhanced DVD Media
%EQUATE `SIID_MEDIAHDDVD = 89 ' // HD-DVD Media
%EQUATE `SIID_MEDIABLURAY = 90 ' // BluRay Media
%EQUATE `SIID_MEDIAVCD = 91 ' // VCD Media
%EQUATE `SIID_MEDIADVDPLUSR = 92 ' // DVD+R Media
%EQUATE `SIID_MEDIADVDPLUSRW = 93 ' // DVD+RW Media
%EQUATE `SIID_DESKTOPPC = 94 ' // desktop computer
%EQUATE `SIID_MOBILEPC = 95 ' // mobile computer (laptop/notebook)
%EQUATE `SIID_USERS = 96 ' // users
%EQUATE `SIID_MEDIASMARTMEDIA = 97 ' // Smart Media
%EQUATE `SIID_MEDIACOMPACTFLASH = 98 ' // Compact Flash
%EQUATE `SIID_DEVICECELLPHONE = 99 ' // Cell phone
%EQUATE `SIID_DEVICECAMERA = 100 ' // Camera
%EQUATE `SIID_DEVICEVIDEOCAMERA = 101 ' // Video camera
%EQUATE `SIID_DEVICEAUDIOPLAYER = 102 ' // Audio player
%EQUATE `SIID_NETWORKCONNECT = 103 ' // Connect to network
%EQUATE `SIID_INTERNET = 104 ' // Internet
%EQUATE `SIID_ZIPFILE = 105 ' // ZIP file
%EQUATE `SIID_SETTINGS = 106 ' // Settings
'// 107-131 are internal Vista RTM icons
'// 132-159 for SP1 icons
%EQUATE `SIID_DRIVEHDDVD = 132 ' // HDDVD Drive (all types)
%EQUATE `SIID_DRIVEBD = 133 ' // BluRay Drive (all types)
%EQUATE `SIID_MEDIAHDDVDROM = 134 ' // HDDVD-ROM Media
%EQUATE `SIID_MEDIAHDDVDR = 135 ' // HDDVD-R Media
%EQUATE `SIID_MEDIAHDDVDRAM = 136 ' // HDDVD-RAM Media
%EQUATE `SIID_MEDIABDROM = 137 ' // BluRay ROM Media
%EQUATE `SIID_MEDIABDR = 138 ' // BluRay R Media
%EQUATE `SIID_MEDIABDRE = 139 ' // BluRay RE Media (Rewriable and RAM)
%EQUATE `SIID_CLUSTEREDDRIVE = 140 ' // Clustered disk
'// 160+ are for Windows 7 icons
%EQUATE `SIID_MAX_ICONS = 174
%EQUATE `SIID_INVALID = -1 ' ((SHSTOCKICONID)-1)
DECLARE FUNCTION SHGetStockIconInfo LIB "shell32.dll" ALIAS "SHGetStockIconInfo" ( BYVAL siid AS LONG , BYVAL uFlags AS QUAD , BYREF psii AS SHSTOCKICONINFO ) AS LONG
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
'#define SHGetDiskFreeSpace SHGetDiskFreeSpaceEx
DECLARE FUNCTION SHGetDiskFreeSpaceExA LIB "shell32.dll" ALIAS "SHGetDiskFreeSpaceExA" ( BYREF pszVolume AS ASCIIZ , BYREF pqwFreeCaller AS QUAD , BYREF pqwTot AS QUAD , BYREF pqwFree AS QUAD ) AS LONG
DECLARE FUNCTION SHGetDiskFreeSpaceExW LIB "shell32.dll" ALIAS "SHGetDiskFreeSpaceExW" ( BYREF pszVolume AS WSTRINGZ
 , BYREF pqwFreeCaller AS QUAD
 , BYREF pqwTot AS QUAD
 , BYREF pqwFree AS QUAD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SHGetDiskFreeSpaceEx = SHGetDiskFreeSpaceExW
 MACRO SHGetDiskFreeSpace = SHGetDiskFreeSpaceExW
#ELSE
 MACRO SHGetDiskFreeSpaceEx = SHGetDiskFreeSpaceExA
 MACRO SHGetDiskFreeSpace = SHGetDiskFreeSpaceExW
#ENDIF
DECLARE FUNCTION SHGetNewLinkInfoA LIB "shell32.dll" ALIAS "SHGetNewLinkInfoA" ( BYREF pszLinkTo AS ASCIIZ , BYREF pszDir AS ASCIIZ , BYREF pszName AS ASCIIZ , BYREF pfMustCopy AS LONG , BYVAL uFlags AS QUAD ) AS LONG
DECLARE FUNCTION SHGetNewLinkInfoW LIB "shell32.dll" ALIAS "SHGetNewLinkInfoW" ( BYREF pszLinkTo AS WSTRINGZ
 , BYREF pszDir AS WSTRINGZ
 , BYREF pszName AS WSTRINGZ
 , BYREF pfMustCopy AS LONG
 , BYVAL uFlags AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SHGetNewLinkInfo = SHGetNewLinkInfoW
#ELSE
 MACRO SHGetNewLinkInfo = SHGetNewLinkInfoA
#ENDIF
%EQUATE `SHGNLI_PIDL = &H000000001 ' // pszLinkTo is a pidl
%EQUATE `SHGNLI_PREFIXNAME = &H000000002 ' // Make name "Shortcut to xxx"
%EQUATE `SHGNLI_NOUNIQUE = &H000000004 ' // don't do the unique name generation
'#if (_WIN32_IE >= &H0501)
%EQUATE `SHGNLI_NOLNK = &H000000008 ' // don't add ".lnk" extension
'#endif // _WIN2_IE >= &H0501
'#if (_WIN32_IE >= 0x0600)
%EQUATE `SHGNLI_NOLOCNAME = &H000000010 ' // use non localized (parsing) name from the target
'#endif
'#if (NTDDI_VERSION >= NTDDI_WIN7)
%EQUATE `SHGNLI_USEURLEXT = &H000000020 ' // use ".url" extension instead of ".lnk"
'#endif
'#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
'////
'//// End SHGetFileInfo
'////
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
'// Printer stuff
%EQUATE `PRINTACTION_OPEN = 0 ' // pszBuf1:<PrinterName>
%EQUATE `PRINTACTION_PROPERTIES = 1 ' // pszBuf1:<PrinterName>, pszBuf2:optional <PageName>
%EQUATE `PRINTACTION_NETINSTALL = 2 ' // pszBuf1:<NetPrinterName>
%EQUATE `PRINTACTION_NETINSTALLLINK = 3 ' // pszBuf1:<NetPrinterName>, pszBuf2:<path to store link>
%EQUATE `PRINTACTION_TESTPAGE = 4 ' // pszBuf1:<PrinterName>
%EQUATE `PRINTACTION_OPENNETPRN = 5 ' // pszBuf1:<NetPrinterName>
'#ifdef WINNT
%EQUATE `PRINTACTION_DOCUMENTDEFAULTS = 6 ' // pszBuf1:<PrinterName>
%EQUATE `PRINTACTION_SERVERPROPERTIES = 7 ' // pszBuf1:<Server> or <NetPrinterName>
'#endif
DECLARE FUNCTION SHInvokePrinterCommandA LIB "shell32.dll" ALIAS "SHInvokePrinterCommandA" ( BYVAL hwnd AS QUAD , BYVAL uAction AS QUAD , BYREF lpBuf1 AS ASCIIZ , BYREF lpBuf2 AS ASCIIZ , BYVAL fModal AS LONG ) AS LONG
'FUNCTION SHInvokePrinterCommandA ( ' BYVAL hWnd AS QUAD
' , BYVAL uAction AS DWORD
' , BYREF lpBuf1 AS ASCIIZ
' , BYREF lpBuf2 AS ASCIIZ
' , BYVAL fModal AS LONG
' ) AS LONG
' LOCAL hLib AS DWORD
' LOCAL pAddr AS DWORD
' LOCAL bRes AS LONG
' hLib = LoadLibrary("SHELL32.DLL")
' IF hLib = %NULL THEN EXIT FUNCTION
' pAddr = GetProcAddress(hLib, "SHInvokePrinterCommandA")
' IF pAddr THEN CALL DWORD pAddr USING SHInvokePrinterCommandA(hWnd, uAction, lpBuf1, lpBuf2, fModal) TO bRes
' FreeLibrary hLib
' FUNCTION = bRes
'END FUNCTION
DECLARE FUNCTION SHInvokePrinterCommandW LIB "shell32.dll" ALIAS "SHInvokePrinterCommandW" ( BYVAL hwnd AS QUAD , BYVAL uAction AS QUAD , BYREF lpBuf1 AS WSTRINGZ , BYREF lpBuf2 AS WSTRINGZ , BYVAL fModal AS LONG ) AS LONG
'FUNCTION SHInvokePrinterCommandW ( ' BYVAL hWnd AS QUAD
' , BYVAL uAction AS DWORD
' , BYREF lpBuf1 AS WSTRINGZ
' , BYREF lpBuf2 AS WSTRINGZ
' , BYVAL fModal AS LONG
' ) AS LONG
' LOCAL hLib AS DWORD
' LOCAL pAddr AS DWORD
' LOCAL bRes AS LONG
' hLib = LoadLibrary("SHELL32.DLL")
' IF hLib = %NULL THEN EXIT FUNCTION
' pAddr = GetProcAddress(hLib, "SHInvokePrinterCommandW")
' IF pAddr THEN CALL DWORD pAddr USING SHInvokePrinterCommandW(hWnd, uAction, lpBuf1, lpBuf2, fModal) TO bRes
' FreeLibrary hLib
' FUNCTION = bRes
'END FUNCTION
#IF %DEF(%UNICODE)
 MACRO SHInvokePrinterCommand(hWnd, uAction, lpBuf1, lpBuf2, fModal) = SHInvokePrinterCommandW(hWnd, uAction, lpBuf1, lpBuf2, fModal)
#ELSE
 MACRO SHInvokePrinterCommand(hWnd, uAction, lpBuf1, lpBuf2, fModal) = SHInvokePrinterCommandA(hWnd, uAction, lpBuf1, lpBuf2, fModal)
#ENDIF
'#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
'#if (NTDDI_VERSION >= NTDDI_VISTA)
' // Size = 20 bytes
TYPE OPEN_PRINTER_PROPS_INFOA BYTE
 dwSize AS DWORD
 pszSheetName AS ASCIIZ PTR
 uSheetIndex AS DWORD ' UINT
 dwFlags AS DWORD
 bModal AS LONG
END TYPE
' // Size = 20 bytes
TYPE OPEN_PRINTER_PROPS_INFOW BYTE
 dwSize AS DWORD
 pszSheetName AS WSTRINGZ PTR
 uSheetIndex AS DWORD ' UINT
 dwFlags AS DWORD
 bModal AS LONG
END TYPE
#IF %DEF(%UNICODE)
 MACRO OPEN_PRINTER_PROPS_INFO = OPEN_PRINTER_PROPS_INFOW
#ELSE
 MACRO OPEN_PRINTER_PROPS_INFO = OPEN_PRINTER_PROPS_INFOA
#ENDIF
%EQUATE `PRINT_PROP_FORCE_NAME = &H01
'#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
'#endif /* WINVER >= 0x0400 */
'#if (_WIN32_WINNT >= 0x0500) || (_WIN32_WINDOWS >= 0x0500)
'//
'// The SHLoadNonloadedIconOverlayIdentifiers API causes the shell's
'// icon overlay manager to load any registered icon overlay
'// identifers that are not currently loaded. This is useful if an
'// overlay identifier did not load at shell startup but is needed
'// and can be loaded at a later time. Identifiers already loaded
'// are not affected. Overlay identifiers implement the
'// IShellIconOverlayIdentifier interface.
'//
'// Returns:
'// S_OK
'//
DECLARE FUNCTION SHLoadNonloadedIconOverlayIdentifiers LIB "shell32.dll" ALIAS "SHLoadNonloadedIconOverlayIdentifiers" ( ) AS LONG
'//
'// The SHIsFileAvailableOffline API determines whether a file
'// or folder is available for offline use.
'//
'// Parameters:
'// pwszPath file name to get info about
'// pdwStatus (optional) OFFLINE_STATUS_* flags returned here
'//
'// Returns:
'// S_OK File/directory is available offline, unless
'// OFFLINE_STATUS_INCOMPLETE is returned.
'// E_INVALIDARG Path is invalid, or not a net path
'// E_FAIL File/directory is not available offline
'//
'// Notes:
'// OFFLINE_STATUS_INCOMPLETE is never returned for directories.
'// Both OFFLINE_STATUS_LOCAL and OFFLINE_STATUS_REMOTE may be returned,
'// indicating "open in both places." This is common when the server is online.
'//
DECLARE FUNCTION SHIsFileAvailableOffline LIB "shell32.dll" ALIAS "SHIsFileAvailableOffline" ( BYREF pszPath AS WSTRINGZ , BYREF pdwStatus AS QUAD ) AS LONG
%EQUATE `OFFLINE_STATUS_LOCAL = &H0001 ' // If open, it's open locally
%EQUATE `OFFLINE_STATUS_REMOTE = &H0002 ' // If open, it's open remotely
%EQUATE `OFFLINE_STATUS_INCOMPLETE = &H0004 ' // The local copy is currently imcomplete.
 ' // The file will not be available offline
 ' // until it has been synchronized.
'#endif
'#if (NTDDI_VERSION >= NTDDI_WINXP)
'// sets the specified path to use the string resource
'// as the UI instead of the file system name
DECLARE FUNCTION SHSetLocalizedName LIB "shell32.dll" ALIAS "SHSetLocalizedName" ( BYREF pszPath AS WSTRINGZ , BYREF pszResModule AS WSTRINGZ , BYVAL idsRes AS LONG ) AS LONG
'#endif // (NTDDI_VERSION >= NTDDI_WINXP)
'#if (NTDDI_VERSION >= NTDDI_VISTA)
'// sets the specified path to use the string resource
'// as the UI instead of the file system name
DECLARE FUNCTION SHRemoveLocalizedName LIB "shell32.dll" ALIAS "SHRemoveLocalizedName" ( BYREF pszPath AS WSTRINGZ ) AS LONG
'// gets the string resource for the specified path
DECLARE FUNCTION SHGetLocalizedName LIB "shell32.dll" ALIAS "SHGetLocalizedName" ( BYREF pszPath AS WSTRINGZ , BYREF pszResModule AS WSTRINGZ , BYVAL cch AS QUAD , BYREF pidsRes AS QUAD ) AS LONG
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'//====== ShellMessageBox ================================================
'// If lpcTitle is NULL, the title is taken from hWnd
'// If lpcText is NULL, this is assumed to be an Out Of Memory message
'// If the selector of lpcTitle or lpcText is NULL, the offset should be a
'// string resource ID
'// The variable arguments must all be 32-bit values (even if fewer bits
'// are actually used)
'// lpcText (or whatever string resource it causes to be loaded) should
'// be a formatting string similar to wsprintf except that only the
'// following formats are available:
'// %% formats to a single '%'
'// %nn%s the nn-th arg is a string which is inserted
'// %nn%ld the nn-th arg is a DWORD, and formatted decimal
'// %nn%lx the nn-th arg is a DWORD, and formatted hex
'// note that lengths are allowed on the %s, %ld, and %lx, just
'// like wsprintf
'//
'int _cdecl ShellMessageBoxA(
' HINSTANCE hAppInst,
' HWND hWnd,
' LPCSTR lpcText,
' LPCSTR lpcTitle,
' UINT fuStyle,
' ...);
DECLARE FUNCTION ShellMessageBoxA CDECL LIB "shell32.dll" ALIAS "ShellMessageBoxA" ( BYVAL hInst AS QUAD , BYVAL hWnd AS QUAD , BYREF pszMsg AS ASCIIZ , BYREF pszTitle AS ASCIIZ , BYVAL fuStyle AS QUAD , OPTIONAL BYREF ANY ' optional parameters , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY ) AS LONG ' int
'int _cdecl ShellMessageBoxW(
' HINSTANCE hAppInst,
' HWND hWnd,
' LPCWSTR lpcText,
' LPCWSTR lpcTitle,
' UINT fuStyle,
' ...);
DECLARE FUNCTION ShellMessageBoxW CDECL LIB "shell32.dll" ALIAS "ShellMessageBoxW" ( BYVAL hInst AS QUAD , BYVAL hWnd AS QUAD , BYVAL pszMsg AS QUAD , BYVAL pszTitle AS QUAD , BYVAL fuStyle AS QUAD , OPTIONAL BYREF ANY ' optional parameters , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY , OPTIONAL BYREF ANY ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO ShellMessageBox = ShellMessageBoxW
#ELSE
 MACRO ShellMessageBox = ShellMessageBoxA
#ENDIF
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
DECLARE FUNCTION IsLFNDriveA LIB "shell32.dll" ALIAS "IsLFNDriveA" ( OPTIONAL BYREF pszPath AS ASCIIZ ) AS LONG
DECLARE FUNCTION IsLFNDriveW LIB "shell32.dll" ALIAS "IsLFNDriveW" ( OPTIONAL BYREF pszPath AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO IsLFNDrive = IsLFNDriveW
#ELSE
 MACRO IsLFNDrive = IsLFNDriveA
#ENDIF
'#endif // (NTDDI_VERSION >= NTDDI_WIN2K)
'#if _WIN32_IE >= 0x0600
' Note: This function is exported from Shell32.dll in Unicode; there is no ANSI version.
'STDAPI SHEnumerateUnreadMailAccountsA(HKEY hKeyUser, DWORD dwIndex, LPSTR pszMailAddress, int cchMailAddress);
'STDAPI SHEnumerateUnreadMailAccountsW(HKEY hKeyUser, DWORD dwIndex, LPWSTR pszMailAddress, int cchMailAddress);
DECLARE FUNCTION SHEnumerateUnreadMailAccountsW LIB "shell32.dll" ALIAS "SHEnumerateUnreadMailAccountsW" ( BYVAL hKeyUser AS QUAD , BYVAL dwIndex AS QUAD , BYREF pszMailAddress AS WSTRINGZ , BYVAL cchMailAddress AS LONG ) AS LONG
MACRO SHEnumerateUnreadMailAccounts = SHEnumerateUnreadMailAccountsW
' Note: This function is exported from Shell32.dll in Unicode; there is no ANSI version.
'STDAPI SHGetUnreadMailCountA(HKEY hKeyUser, LPCSTR pszMailAddress, DWORD *pdwCount, FILETIME *pFileTime, LPSTR pszShellExecuteCommand, int cchShellExecuteCommand);
'STDAPI SHGetUnreadMailCountW(HKEY hKeyUser, LPCWSTR pszMailAddress, DWORD *pdwCount, FILETIME *pFileTime, LPWSTR pszShellExecuteCommand, int cchShellExecuteCommand);
DECLARE FUNCTION SHGetUnreadMailCountW LIB "shell32.dll" ALIAS "SHGetUnreadMailCountW" ( BYVAL hKeyUser AS QUAD , BYREF pszMailAddress AS WSTRINGZ , BYREF pdwCount AS QUAD , BYREF pFileTime AS FILETIME , BYREF pszShellExecuteCommand AS WSTRINGZ , BYVAL cchShellExecuteCommand AS LONG ) AS LONG
MACRO SHGetUnreadMailCount = SHGetUnreadMailCountW
' NOTE: This function is exported from Shell32.dll in Unicode; there is no ANSI version.
'STDAPI SHSetUnreadMailCountA(LPCSTR pszMailAddress, DWORD dwCount, LPCSTR pszShellExecuteCommand);
'STDAPI SHSetUnreadMailCountW(LPCWSTR pszMailAddress, DWORD dwCount, LPCWSTR pszShellExecuteCommand);
DECLARE FUNCTION SHSetUnreadMailCountW LIB "shell32.dll" ALIAS "SHSetUnreadMailCountW" ( BYREF pszMailAddress AS WSTRINGZ , BYVAL dwCount AS QUAD , BYREF pszShellExecuteCommand AS WSTRINGZ ) AS LONG
MACRO SHSetUnreadMailCount = SHSetUnreadMailCountW
'#endif /* _WIN32_IE >= 0x0600 */
'#if (_WIN32_IE >= 0x0601)
DECLARE FUNCTION SHTestTokenMembership LIB "shell32.dll" ALIAS "SHTestTokenMembership" ( BYVAL hToken AS QUAD , BYVAL ulRID AS QUAD ) AS LONG
'#endif // (_WIN32_IE >= 0x0601)
'#if _WIN32_IE >= 0x0600
'#if (NTDDI_VERSION >= NTDDI_WINXP)
DECLARE FUNCTION SHGetImageList LIB "shell32.dll" ALIAS "SHGetImageList" ( BYVAL iImageList AS LONG , BYREF riid AS GUID , BYREF ppv AS ANY ) AS LONG
'#endif // (NTDDI_VERSION >= NTDDI_WINXP)
'#if (NTDDI_VERSION >= NTDDI_WINXP)
%EQUATE `SHIL_LARGE = 0 ' // normally 32x32
%EQUATE `SHIL_SMALL = 1 ' // normally 16x16
%EQUATE `SHIL_EXTRALARGE = 2
%EQUATE `SHIL_SYSSMALL = 3 ' // like SHIL_SMALL, but tracks system small icon metric correctly
'#if (NTDDI_VERSION >= NTDDI_VISTA)
%EQUATE `SHIL_JUMBO = 4 ' // normally 256x256
'%SHIL_LAST = %SHIL_JUMBO
'#else
'%SHIL_LAST = %SHIL_SYSSMALL
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'#endif // (NTDDI_VERSION >= NTDDI_WINXP)
' // Function call types for ntshrui folder sharing helpers
'typedef HRESULT (STDMETHODCALLTYPE *PFNCANSHAREFOLDERW)(LPCWSTR pszPath);
'typedef HRESULT (STDMETHODCALLTYPE *PFNSHOWSHAREFOLDERUIW)(HWND hwndParent, LPCWSTR pszPath);
' This function has no associated .lib file. You must use LoadLibrary and GetProcAddress
' to use it.
' This function is available through Microsoft Windows XP Service Pack 2 (SP2) and Windows
' Server 2003. It might be altered or unavailable in subsequent versions of Windows.
' Minimum operating system: Windows XP.
' Implemented as Unicode version only.
FUNCTION CanShareFolderW ( BYREF pszPath AS WSTRINGZ
 ) AS LONG
 LOCAL hLib AS DWORD
 LOCAL pAddr AS DWORD
 LOCAL hr AS LONG
 hLib = LoadLibrary("NTSHRUI.DLL")
 IF hLib = %NULL THEN
 FUNCTION = GetLastError
 EXIT FUNCTION
 END IF
 pAddr = GetProcAddress(hLib, "CanShareFolderW")
 IF pAddr = %NULL THEN
 hr = GetLastError
 ELSE
 CALL DWORD pAddr USING CanShareFolderW(pszPath) TO hr
 END IF
 FreeLibrary hLib
 FUNCTION = hr
END FUNCTION
MACRO CanShareFolder(pszPath) = CanShareFolderW(pszPath)
' typedef HRESULT (STDMETHODCALLTYPE *PFNSHOWSHAREFOLDERUIW)(IN HWND hwndParent, IN LPCWSTR pszPath);
' Note: Implemented as Unicode version only.
' Minimum operating system: Windows XP.
' This function has no associated .lib file. You must use LoadLibrary and GetProcAddress
' to use it.
FUNCTION ShowShareFolderUI ( BYVAL hwndParent AS DWORD
 , BYREF pszPath AS WSTRINGZ
 ) AS LONG
 LOCAL hLib AS DWORD
 LOCAL pAddr AS DWORD
 LOCAL hr AS LONG
 hLib = LoadLibrary("NTSHRUI.DLL")
 IF hLib = %NULL THEN
 FUNCTION = GetLastError
 EXIT FUNCTION
 END IF
 pAddr = GetProcAddress(hLib, "ShowShareFolderUI")
 IF pAddr = %NULL THEN
 hr = GetLastError
 ELSE
 CALL DWORD pAddr USING ShowShareFolderUI(hWndParent, pszPath) TO hr
 END IF
 FreeLibrary hLib
 FUNCTION = hr
END FUNCTION
'#endif /* _WIN32_IE >= 0x0600 */
'#if !defined(_WIN64)
'#include <poppack.h>
'#endif
'#if (NTDDI_VERSION >= NTDDI_VISTA)
'// API for new Network Address Control
'// Instantiation
'#define WC_NETADDRESS L"msctls_netaddress"
$$WC_NETADDRESS = "msctls_netaddress"$$
DECLARE FUNCTION InitNetworkAddressControl LIB "shell32.dll" ALIAS "InitNetworkAddressControl" ( ) AS LONG
'// Address Control Messages
'// NCM_GETADDRESS returns the type of address that is present in the
'// control (based on TBD Net Address flags). If the input string has
'// not been validated using this message will force the validation of
'// the input string. The WPARAM is a BOOL to determine to show the
'// balloon tip. The LPARAM is a pointer to the structure to fill in
'// with the address type and address string.
%EQUATE `NCM_GETADDRESS = (%WM_USER+1)
'#define NetAddr_GetAddress(hwnd,pv) \
' (HRESULT)SNDMSG(hwnd,NCM_GETADDRESS,0,(LPARAM)pv)
' // Size = 8 bytes
TYPE NC_ADDRESS WORD ' Must be WORD aligned
 pAddrInfo AS DWORD ' struct NET_ADDRESS_INFO_ * // defined in iphlpapi.h
 PortNumber AS WORD ' USHORT
 PrefixLength AS BYTE ' BYTE
END TYPE
FUNCTION NetAddr_GetAddress(BYVAL hwnd AS DWORD, BYREF pv AS NC_ADDRESS) AS LONG
 FUNCTION = SendMessage(hwnd, %NCM_GETADDRESS, 0, VARPTR(pv))
END FUNCTION
'// NCM_SETALLOWTYPE sets the type of addresses that the control will allow.
'// The address flags are defined in iphlpapi.h
%EQUATE `NCM_SETALLOWTYPE = (%WM_USER+2)
FUNCTION NetAddr_SetAllowType(BYVAL hwnd AS DWORD, BYVAL addrMask AS LONG) AS LONG
 FUNCTION = SendMessage(hwnd, %NCM_SETALLOWTYPE, addrMask, 0)
END FUNCTION
'// NCM_GETALLOWTYPE returns the currently allowed type mask.
%EQUATE `NCM_GETALLOWTYPE = (%WM_USER+3)
FUNCTION NetAddr_GetAllowType(BYVAL hwnd AS DWORD) AS DWORD
 FUNCTION = SendMessage(hwnd, %NCM_GETALLOWTYPE, 0, 0)
END FUNCTION
'// NCM_DISPLAYERRORTIP displays the error balloon tip with the correct
'// error string (based on the last failure from the NCM_GETADDRESS call
%EQUATE `NCM_DISPLAYERRORTIP = (%WM_USER+4)
FUNCTION NetAddr_DisplayErrorTip(BYVAL hwnd AS DWORD) AS LONG
 FUNCTION = SendMessage(hwnd, %NCM_DISPLAYERRORTIP, 0, 0)
END FUNCTION
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'#if (NTDDI_VERSION >= NTDDI_VISTA)
'// Returns the type of media (CD, DVD, Blank, etc) that is in the drive.
'// dwMediaContent is set to a combination of ARCONTENT flags.
DECLARE FUNCTION SHGetDriveMedia LIB "shell32.dll" ALIAS "SHGetDriveMedia" ( BYREF pszDrive AS WSTRINGZ , BYREF pdwMediaContent AS QUAD ) AS LONG
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'// Windows Parental Controls (WPC) query apis
'#if (NTDDI_VERSION >= NTDDI_VISTA)
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'// Undocumented.
'// Updates the Recycle Bin icon on the desktop to reflect the state of the systemwide Recycle Bin.
'// If an error occued, the function returns a non-zero error code. If successful, the function returns 0.
DECLARE FUNCTION SHUpdateRecycleBinIcon LIB "shell32.dll" ALIAS "SHUpdateRecycleBinIcon" () AS LONG
#ENDIF
