! Copyright (C) 2006, 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.data alien.strings
-alien.syntax classes.struct combinators io.backend io.files
-io.pathnames kernel math sequences specialized-arrays
-ui.backend.windows windows windows.com windows.com.syntax
-windows.errors windows.kernel32 windows.ole32 windows.types
-windows.user32 io.files.info ;
-SPECIALIZED-ARRAY: ushort
+alien.syntax classes.struct io.backend kernel
+specialized-arrays
+specialized-arrays.instances.alien.c-types.ushort windows
+windows.com windows.com.syntax windows.kernel32 windows.ole32
+windows.types ;
IN: windows.shell32
CONSTANT: CSIDL_DESKTOP 0x00
LIBRARY: shell32
-FUNCTION: HRESULT SHGetFolderPathW ( HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPTSTR pszPath ) ;
+FUNCTION: HRESULT SHGetFolderPathW ( HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPTSTR pszPath )
ALIAS: SHGetFolderPath SHGetFolderPathW
-FUNCTION: HINSTANCE ShellExecuteW ( HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory, INT nShowCmd ) ;
+FUNCTION: HINSTANCE ShellExecuteW ( HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory, INT nShowCmd )
ALIAS: ShellExecute ShellExecuteW
CONSTANT: SHGFI_ICON 0x000000100
SHFILEINFO *psfi,
UINT cbFileInfo,
UINT uFlags
-) ;
+)
: shell32-file-info ( path -- err struct )
normalize-path
INSTANCE: +win32-os2-executable+ windows-executable ! ne
INSTANCE: +win32-nt-executable+ windows-executable ! pe
-: file-executable-type ( path -- executable/f )
- normalize-path dup
- 0
- f
- ! hi is zero means old style executable
- 0 SHGFI_EXETYPE SHGetFileInfoW
- [
- file-info drop f
- ] [
- nip >lo-hi first2 zero? [
- {
- { 0x5A4D [ +dos-executable+ ] }
- { 0x4550 [ +win32-console-executable+ ] }
- [ drop f ]
- } case
- ] [
- {
- { 0x454C [ +win32-vxd-executable+ ] }
- { 0x454E [ +win32-os2-executable+ ] }
- { 0x4550 [ +win32-nt-executable+ ] }
- [ drop f ]
- } case
- ] if
- ] if-zero ;
-
: shell32-directory ( n -- str )
f swap f SHGFP_TYPE_DEFAULT
MAX_UNICODE_PATH ushort <c-array>
: program-files-common-x86 ( -- str )
CSIDL_PROGRAM_FILES_COMMONX86 shell32-directory ;
-
+
CONSTANT: SHCONTF_FOLDERS 32
CONSTANT: SHCONTF_NONFOLDERS 64
HRESULT GetDisplayNameOf ( LPCITEMIDLIST pidl, SHGDNF uFlags, STRRET* lpName )
HRESULT SetNameOf ( HWND hwnd, LPCITEMIDLIST pidl, LPCOLESTR lpszName, SHGDNF uFlags, LPITEMIDLIST* ppidlOut ) ;
-FUNCTION: HRESULT SHGetDesktopFolder ( IShellFolder** ppshf ) ;
+FUNCTION: HRESULT SHGetDesktopFolder ( IShellFolder** ppshf )
-FUNCTION: UINT DragQueryFileW ( HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch ) ;
+FUNCTION: UINT DragQueryFileW ( HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch )
ALIAS: DragQueryFile DragQueryFileW
-FUNCTION: BOOL IsUserAnAdmin ( ) ;
+FUNCTION: BOOL IsUserAnAdmin ( )