Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Getting My Documents Folder
Jano Svitok
7/23/2006 9:38:00 AM
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::Shell::SHGetSpecialFolderPath(0, my_docs_folder,
Windows::Shell::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
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shgetfold...
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 Berger for this nice package!
J.
On 7/23/06, Dave Ru <daverubie@gmail.com> wrote:
> 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
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnima01/html/i...
>
> Thanks,
> Dave
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Getting My Documents Folder
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password