News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Get the users Desktop folder

Started by Shintaro, August 14, 2014, 06:58:45 PM

Previous topic - Next topic

Shintaro

Hi,

I am trying to get the users Desktop folder, but I am unsure what API I should be using. Should I be using SHGetDesktopFolder? Is there some example code around, because I can't seem to find it.

Kind regards.
"Wyrd bið ful āræd. Fate is inexorable."

qWord

e.g.:
include \masm32\include\masm32rt.inc
.code
main proc
LOCAL  sz[MAX_PATH]:CHAR

invoke SHGetFolderPath,0,CSIDL_DESKTOP,0,0,ADDR sz
print ADDR sz,13,10

inkey
exit
main endp
end main
MREAL macros - when you need floating point arithmetic while assembling!

Shintaro

qWord,

Thank you for the example. I really appreciate it.

I'm obviously looking in the wrong files for explanations on the Win32 API. Win32.hlp doesn't seem to have SHGetFolderPath.
Where should I be looking?

Regards.
"Wyrd bið ful āræd. Fate is inexorable."

GoneFishing

Here MSDN says that SHGetFolderPath function is deprecated and encourages to use SHGetKnownFolderPath function instead.

jj2007

Another option is the registry:

include \masm32\MasmBasic\MasmBasic.inc
  Init                  ; ## Find Shell folders ##
  Let esi="HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
  GetRegArray esi, My$()
  For_ ecx=0 To eax-1
      Print My$(ecx)      ; e.g. AppData, Cookies, Desktop, ...
      PrintLine At(20, Locate(y)) GetRegVal(esi, My$(ecx))
  Next
  Exit
end start

Output:
AppData             C:\Documents and Settings\user\Dati applicazioni
Cookies             C:\Documents and Settings\user\Cookies
Desktop             C:\DOCUME~1\user\Desktop
Favorites           C:\DOCUME~1\user\Preferiti
NetHood             C:\Documents and Settings\user\Risorse di rete
Personal            C:\DOCUME~1\user\Documenti
PrintHood           C:\Documents and Settings\user\Risorse di stampa
Recent              C:\Documents and Settings\user\Recent
SendTo              C:\Documents and Settings\user\SendTo
Start Menu          C:\Documents and Settings\user\Menu Avvio
Templates           C:\Documents and Settings\user\Modelli
Programs            C:\Documents and Settings\user\Menu Avvio\Programmi


jj2007

Quote from: sinsi on August 15, 2014, 08:48:12 AMWhy is there the message '!Do not use this registry key' in the registry?

No such message on my Win XP SP3, sinsi 8)

Thanks for the reading anyway ;-)

Quote from: vertograd on August 15, 2014, 12:17:19 AM
Here MSDN says that SHGetFolderPath function is deprecated and encourages to use SHGetKnownFolderPath function instead.
Your software won't be compatible with Win XP any more.

Shintaro

Thanks guys I appreciate the help.

If I may ask, could you please show me or point me to an example of native exception handling.
"Wyrd bið ful āræd. Fate is inexorable."