niedziela, 5 listopada 2017

Class reading Shell Folders (C++ Builder)




#include <vcl.h>
#include <shlobj.h>
#include <Registry.hpp>

class read_Directory
{
private:
UnicodeString my_Key;
UnicodeString my_Result;
UnicodeString text_Folders;
public:
read_Directory(UnicodeString tF)
{
text_Folders=tF;
TRegistry *reg=new TRegistry();
reg->Access=KEY_READ;
reg->RootKey=HKEY_CURRENT_USER;
my_Key="\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
if(reg->OpenKey(my_Key,false))
{
  if(reg->ValueExists(text_Folders))
my_Result=reg->ReadString(text_Folders);
  else
my_Result="Value not exists";
}
else
{
  my_Result="Key not exists";
}
delete reg;
}
UnicodeString Write()
{
return my_Result;
}
};



Example:


void __fastcall TForm1::Button1Click(TObject *Sender)
{
 read_Directory r_D1("Personal");
 Edit1->Text=r_D1.Write();
 read_Directory r_D2("History");
 Edit2->Text=r_D2.Write();
 read_Directory r_D3("Cookies");
 Edit3->Text=r_D3.Write();
 read_Directory r_D4("Linux");
 Edit4->Text=r_D4.Write();
}

Brak komentarzy:

Prześlij komentarz