unit nonVLCShlObjEx;
interface
uses
Windows;
const
SHELL32 = '
shell32.dll';
// nur die wichtigsten CSID's
CSIDL_ALTSTARTUP = $001D;
CSIDL_APPDATA = $001A;
CSIDL_COMMON_ALTSTARTUP = $001E;
CSIDL_COMMON_APPDATA = $0023;
CSIDL_COMMON_DESKTOPDIRECTORY = $0019;
CSIDL_COMMON_DOCUMENTS = $002E;
CSIDL_COMMON_FAVORITES = $001F;
CSIDL_COMMON_MUSIC = $0035;
CSIDL_COMMON_PICTURES = $0036;
CSIDL_COMMON_PROGRAMS = $0017;
CSIDL_COMMON_STARTMENU = $0016;
CSIDL_COMMON_STARTUP = $0018;
CSIDL_COMMON_TEMPLATES = $002D;
CSIDL_COMMON_VIDEO = $0037;
CSIDL_DESKTOP = $0000;
CSIDL_DESKTOPDIRECTORY = $0010;
CSIDL_INTERNET = $0001;
CSIDL_INTERNET_CACHE = $0020;
CSIDL_LOCAL_APPDATA = $001C;
CSIDL_MYDOCUMENTS = $000C;
CSIDL_MYMUSIC = $000D;
CSIDL_MYPICTURES = $0027;
CSIDL_MYVIDEO = $000E;
CSIDL_PROGRAM_FILES = $0026;
CSIDL_PROGRAM_FILES_COMMON = $002B;
CSIDL_PROGRAMS = $0002;
CSIDL_RECENT = $0008;
CSIDL_SENDTO = $0009;
CSIDL_STARTMENU = $000B;
CSIDL_STARTUP = $0007;
CSIDL_SYSTEM = $0025;
CSIDL_TEMPLATES = $0015;
CSIDL_WINDOWS = $0024;
function GetShellFolder(hWnd: HWND; CSIDL: integer):
String;
implementation
type
// TSHItemID - ItemID from unit "shlObj"
PSHItemID = ^TSHItemID;
_SHITEMID =
record
cb: Word;
// Size of the ID
abID:
array[0..0]
of Byte;
// The item ID
end;
TSHItemID = _SHITEMID;
SHITEMID = _SHITEMID;
// TItemIDList - List if item IDs from unit "shlObj"
PItemIDList = ^TItemIDList;
_ITEMIDLIST =
record
mkid: TSHItemID;
end;
TItemIDList = _ITEMIDLIST;
ITEMIDLIST = _ITEMIDLIST;
// Imports from shell32.dll (inten)
function SHGetSpecialFolderLocation(
hwndOwner: HWND;
nFolder: Integer;
var ppidl: PItemIDList): HResult;
stdcall;
external shell32
name '
SHGetSpecialFolderLocation';
function SHGetPathFromIDList(
pidl: PItemIDList;
pszPath: PChar): BOOL;
stdcall;
external shell32
name '
SHGetPathFromIDListA';
// Export from Unit
function GetShellFolder(hWnd: HWND; CSIDL: integer):
String;
var
pidl : PItemIdList;
FolderPath :
string;
SystemFolder : Integer;
begin
Result := '
';
SystemFolder := CSIDL;
if SUCCEEDED(SHGetSpecialFolderLocation(hWnd, SystemFolder, pidl))
then
begin
SetLength(FolderPath, max_path);
if SHGetPathFromIDList(pidl, PChar(FolderPath))
then
Result := FolderPath;
end;
end;
END.
// End of Unit nonVLCShlObjEx