void __fastcall TForm1::Button1Click(TObject *Sender)
{
//cb is a combo box, lb is a label
int folder;
switch (cb->ItemIndex)
{
case 0:
folder = CSIDL_BITBUCKET;
break;
case 1:
folder = CSIDL_CONTROLS;
break;
case 2:
folder = CSIDL_DESKTOP;
break;
case 3:
folder = CSIDL_DRIVES;
break;
case 4:
folder = CSIDL_FONTS;
break;
case 5:
folder = CSIDL_NETWORK;
break;
case 6:
folder = CSIDL_PRINTERS;
break;
case 7:
folder = CSIDL_PROGRAMS;
break;
case 8:
folder = CSIDL_RECENT;
break;
case 9:
folder = CSIDL_SENDTO;
break;
case 10:
folder = CSIDL_STARTMENU;
break;
case 11:
folder = CSIDL_STARTUP;
break;
case 12:
folder = CSIDL_TEMPLATES;
break;
default:
folder = -1;
break;
}
if (folder >= 0)
{
LPITEMIDLIST pidl;
if (SHGetSpecialFolderLocation(Handle,folder,&pidl) == NOERROR)
{
char buf[MAX_PATH];
SHGetPathFromIDList(pidl,buf);
lb->Caption = buf;
}
}
}
|