Retrieving the Windows desktop folder
Posted: Fri Aug 07, 2009 12:21 pm
by ConvertFromOldNGs
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
Re: Retrieving the Windows desktop folder
Posted: Fri Aug 07, 2009 12:21 pm
by ConvertFromOldNGs
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. ------------------------------------------------------------------