Retrieving the Windows desktop folder

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Retrieving the Windows desktop folder

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:21 pm

by HaydnChapman >> Tue, 11 Feb 2003 23:31:26 GMT

Different versions on win/winnt place the desktop folder in different location. Is it possible to make a call to get the windows desktop folder from the system.

There is an API SHGetSpecialFolderLocation in the shell32.dll but I am unable to get it to work.

Haydn Chapman
Iveco

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Retrieving the Windows desktop folder

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:21 pm

by allistar >> Tue, 11 Feb 2003 23:40:45 GMT

Hi Haydn,
This C++ code will do the trick. You can make an external function
that gets called from Jade:

BOOL ok = true;
char *desktopPath = (char*)malloc(MAX_PATH);
LPITEMIDLIST desktopPidl;
LPMALLOC shellMalloc;
ok = !FAILED(SHGetMalloc(&shellMalloc));
if (ok) {
ok = !FAILED(SHGetSpecialFolderLocation(NULL,
CSIDL_DESKTOPDIRECTORY, &desktopPidl));
}
if (ok) {
ok = SHGetPathFromIDList(desktopPidl, desktopPath);
}
if (ok) {
shellMalloc->Free(desktopPidl);
shellMalloc->Release();
//now "desktopPath" contains the desktop pacth for
this computer.
}
free(desktopPath);
free(path);

Regards,
Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer
Auckland, NEW ZEALAND

Greentree International,
Developer of Greentree Financial Software. ------------------------------------------------------------------


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 34 guests