sub BrowseForFolder { undef $Win32::FileOp::Error; my $lpszTitle = shift() || "\0"; my $nFolder = shift() || 0; my $ulFlags= (shift() || 0) | 0x0000; my $hwndOwner = (defined $_[0] ? shift() : GetWindowHandle()); my ($pidlRoot, $pszDisplayName, $lpfn, $lParam, $iImage, $pszPath) = ("\0"x260, "\0"x260, 0, 0, 0, "\0"x260 ); $nFolder = CSIDL_DRIVES() unless defined $nFolder; $Win32::FileOp::SHGetSpecialFolderLocation->Call($hwndOwner, $nFolder, $pidlRoot) and return undef; $pidlRoot = hex unpack 'H*',(join'', reverse split//, $pidlRoot); my $browseinfo = pack 'LLppILLI', ($hwndOwner, $pidlRoot, $pszDisplayName, $lpszTitle, $ulFlags, $lpfn, $lParam, $iImage); my $bool = $Win32::FileOp::SHGetPathFromIDList->Call( $Win32::FileOp::SHBrowseForFolder->Call($browseinfo), $pszPath ); $pszPath =~ s/\0.*$//s; $bool ? $pszPath : undef; }