diff --git a/programs/winecfg/drive.c b/programs/winecfg/drive.c index a5fc3bfd73a..bfe9a48e94d 100644 --- a/programs/winecfg/drive.c +++ b/programs/winecfg/drive.c @@ -370,3 +370,55 @@ void apply_drive_changes(void) } CloseHandle( mgr ); } + + +void query_shell_folder( const WCHAR *path, char *dest, unsigned int len ) +{ + UNICODE_STRING nt_name; + HANDLE mgr; + + if ((mgr = open_mountmgr()) == INVALID_HANDLE_VALUE) return; + + if (!RtlDosPathNameToNtPathName_U( path, &nt_name, NULL, NULL )) + { + CloseHandle( mgr ); + return; + } + DeviceIoControl( mgr, IOCTL_MOUNTMGR_QUERY_SHELL_FOLDER, nt_name.Buffer, nt_name.Length, + dest, len, NULL, NULL ); + RtlFreeUnicodeString( &nt_name ); +} + +void set_shell_folder( const WCHAR *path, const char *dest ) +{ + struct mountmgr_shell_folder *ioctl; + UNICODE_STRING nt_name; + HANDLE mgr; + DWORD len; + + if ((mgr = open_mountmgr()) == INVALID_HANDLE_VALUE) return; + + if (!RtlDosPathNameToNtPathName_U( path, &nt_name, NULL, NULL )) + { + CloseHandle( mgr ); + return; + } + + len = sizeof(*ioctl) + nt_name.Length; + if (dest) len += strlen(dest) + 1; + + if (!(ioctl = HeapAlloc( GetProcessHeap(), 0, len ))) return; + ioctl->folder_offset = sizeof(*ioctl); + ioctl->folder_size = nt_name.Length; + memcpy( (char *)ioctl + ioctl->folder_offset, nt_name.Buffer, nt_name.Length ); + if (dest) + { + ioctl->symlink_offset = ioctl->folder_offset + ioctl->folder_size; + strcpy( (char *)ioctl + ioctl->symlink_offset, dest ); + } + else ioctl->symlink_offset = 0; + + DeviceIoControl( mgr, IOCTL_MOUNTMGR_DEFINE_SHELL_FOLDER, ioctl, len, NULL, 0, NULL, NULL ); + HeapFree( GetProcessHeap(), 0, ioctl ); + RtlFreeUnicodeString( &nt_name ); +} diff --git a/programs/winecfg/theme.c b/programs/winecfg/theme.c index b3a3eeed3ba..151dc486659 100644 --- a/programs/winecfg/theme.c +++ b/programs/winecfg/theme.c @@ -28,12 +28,6 @@ #include #include #include -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif #define COBJMACROS @@ -765,25 +759,14 @@ static void init_shell_folder_listview_headers(HWND dialog) { /* Reads the currently set shell folder symbol link targets into asfiInfo. */ static void read_shell_folder_link_targets(void) { WCHAR wszPath[MAX_PATH]; - HRESULT hr; int i; for (i=0; i= 0) asfiInfo[i].szLinkTarget[cLen] = '\0'; - } - HeapFree(GetProcessHeap(), 0, pszUnixPath); - } - } - } + if (SUCCEEDED( SHGetFolderPathW( NULL, asfiInfo[i].nFolder | CSIDL_FLAG_DONT_VERIFY, NULL, + SHGFP_TYPE_CURRENT, wszPath ))) + query_shell_folder( wszPath, asfiInfo[i].szLinkTarget, FILENAME_MAX ); + } } static void update_shell_folder_listview(HWND dialog) { @@ -904,56 +887,12 @@ static void on_shell_folder_edit_changed(HWND hDlg) { static void apply_shell_folder_changes(void) { WCHAR wszPath[MAX_PATH]; - char szBackupPath[FILENAME_MAX], szUnixPath[FILENAME_MAX], *pszUnixPath = NULL; int i; - struct stat statPath; - HRESULT hr; for (i=0; i