News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

special folders

Started by ossama, December 28, 2007, 05:29:04 PM

Previous topic - Next topic

ossama

hi,
is there a way to get the desktop folder path without using these functions
SHGetSpecialFolderLocation()
and
SHGetPathFromIDList()

for example to get the system folder path we call a simple function
GetSystemDirectory

donkey

They are stored in the registry in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ossama

Quote from: donkey on December 28, 2007, 05:34:34 PM
They are stored in the registry in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

Donkey

is it for all versions of windows?

ossama

i have looked in that key,but it does not give me other special folders like Program Files folder

donkey

Don't know, I use the functions that are designed to obtain the information rather than write a kludge that may not be supported in other versions. I am pretty sure it doesn't work on Vista, I think the key name in Vista is "User Shell Folders" or something like that.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

Quote from: ossama on December 28, 2007, 05:38:17 PM
i have looked in that key,but it does not give me other special folders like Program Files folder

Oh well, you will have to do it another way, like perhaps use the actual API function that is DESIGNED TO DO IT.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ramguru

In addition to what donkey said

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

another reg key is:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion

ossama

QuoteOh well, you will have to do it another way, like perhaps use the actual API function that is DESIGNED TO DO IT.

i am agree with donkey,
using api functions is the best way,
so to get for example the desktop folder,one can use the functions
SHGetSpecialFolderLocation()
and
SHGetPathFromIDList()

is it the only way (using api)?

donkey

Quote from: ossama on December 28, 2007, 06:04:03 PM
QuoteOh well, you will have to do it another way, like perhaps use the actual API function that is DESIGNED TO DO IT.

i am agree with donkey,
using api functions is the best way,
so to get for example the desktop folder,one can use the functions
SHGetSpecialFolderLocation()
and
SHGetPathFromIDList()

is it the only way (using api)?

There is no conceivable reason not to use these functions. Very few programs do not load Shell32.DLL and those API's are included for all versions of Windows so they are guaranteed to be available.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Jackal

there is another api function but i forget what it is and to be honest its more of a pain to use. to retrieve the desktop folder i use

Invoke SHGetSpecialFolderPath, NULL, addr DeskBuffer, CSIDL_DESKTOPDIRECTORY, 0

to get the startmenu folder i use

Invoke SHGetSpecialFolderPath, NULL, addr StartMBuff, CSIDL_STARTMENU, 0

donkey

There are of course other APIs and methods to extract the information, however they can be cumbersome and difficult to find supporting documentation for, one method is using the IShellFolder interface using COM. Here is an example in GoAsm using the interface to extract the My Documents path...

GetMyDocumentsFolderA FRAME lpOutput
uses edi
LOCAL psfDesktop :D
LOCAL pidlDocFile[64] :D
LOCAL chEaten :D

// Get a pointer to the IShellFolder interface
invoke SHGetDesktopFolder, offset psfDesktop

// Parse the name of the My Documents folder using its CLSID
CoInvoke(psfDesktop,IShellFolder.ParseDisplayName,0,0, \
L"::{450d8fba-ad25-11d0-98a8-0800361b1103}",offset chEaten, \
offset pidlDocFile,0)

// Release the interface
CoInvoke(psfDesktop, IShellFolder.IUnknown.Release)

// Convert the pidl to a fully qualified path
invoke SHGetPathFromIDListA,[pidlDocFile],[lpOutput]

ret
endf


As I said there is little documentation for this type of extraction and there may not be CLSIDs for every folder but I suspect that the SHGet*** functions are simply flat API wrappers for the COM call above.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

zooba

Those registry keys exist only for backwards compatibility. The SHGetSpecialFolderPath function is the recommended method for retrieving these folders.

Cheers,

Zooba :U

ossama

thank you for help,
i will use SHGetSpecialFolderPath.