Hi,
I’m trying to find the my documents folder for the current user in
windows. I know this can be done using Win32API, but I’m a little
confused
on the syntax. Here’s an article on how to do it in VB
.
Thanks,
Dave
Hi,
I’m trying to find the my documents folder for the current user in
windows. I know this can be done using Win32API, but I’m a little
confused
on the syntax. Here’s an article on how to do it in VB
.
Thanks,
Dave
Hi,
Install windows-pr gem from win32 utils
(rubyforge.org/project/win32utils) and then
require ‘windows/shell’
MAX_PATH = 260 # don’t know exactly
DONT_CREATE = 0
my_docs_folder = ’ ’ * MAX_PATH
ret = Windows:
:SHGetSpecialFolderPath(0, my_docs_folder,
Windows:
:CSIDL_MYDOCUMENTS, DONT_CREATE)
if ret == 0
my_docs_folder = ‘’
else
my_docs_folder = my_docs_folder[ /^[^\0]*/ ]
end
Or, if you are on W2K+, you can use SHGetFolderPath
NB: Do NOT use registry to retrieve this information - the needed
keys may not exist - they are created on-demand as a
backward-compatibilty hack.
Tomorrow I can send you my debugged copy… send me email if you are
interested.
NB2: Thanks to Dan B. for this nice package!
J.
Dave Ru wrote:
Thanks,
Dave
require ‘win32/dir’
Dir::PERSONAL # “C:\Documents and Settings\djberge\My Documents”
Regards,
Dan
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs