Advertisement
Dani_info

LockFolder

May 23rd, 2018
116
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <windows.h>
  4. using namespace std;
  5.  
  6. void lockfolder();
  7. void unlockfolder();
  8. void setcolour(unsigned int colour);
  9.  
  10. int main()
  11.  
  12. {
  13.  unsigned int choice=0;
  14.  SetConsoleTitle("Folder Lock");
  15.  system("CLS");
  16.  setcolour(14);
  17.  cout << "\t\t\t\t" << "- DanY\n";
  18.  cout << "\t\t\t\t" << "-----------------\n";
  19.  setcolour(15);
  20.  
  21.  setcolour(30);
  22.  
  23.  cout << "\n\n" << "Options:\t\t\t\n";
  24.  cout << "\t======================\n";
  25.  cout << "\t1. - Lock Folder.\n";
  26.  cout << "\t2. - Unlock Folder.\n";
  27.  cout << "\t3. - Exit.\n";
  28.  cout << "\t======================  \n";
  29.  
  30.  setcolour(128);
  31.  cout << "\nEnter your choice: ";
  32.  cin >> choice;
  33.  
  34.  switch (choice)
  35.  {
  36.  case 1: lockfolder(); break;
  37.  case 2: unlockfolder(); break;
  38.  case 3: exit(0); break;
  39.  default: cout << "\nError. Unknown Option Entered. Quitting ....\n"; break;
  40.  }
  41.  
  42.  return 0;
  43. }
  44. void setcolour(unsigned int colour)
  45. {
  46.  HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
  47.  SetConsoleTextAttribute(handle, colour);
  48. }
  49.  
  50. void lockfolder()
  51. {
  52.  char pass[15]="dani2002";
  53.  ofstream lfolder;
  54.  char folder[200]={""};
  55.  char tempfolder[200]={'0'};
  56.  char attributes[50]={'0'};
  57.  
  58.  setcolour(13);
  59.  
  60.  cout << "\nEnter the complete path to the Folder: ";
  61.  cin >> folder;
  62.  
  63.  strcpy(tempfolder, folder);
  64.  
  65.  strcat(folder, "\\Desktop.ini");
  66.  
  67.  lfolder.open(folder, ios::out);
  68.  
  69.  lfolder << "[.shellClassInfo]" << endl;
  70.  lfolder << "CLSID = {63E23168-BFF7-4E87-A246-EF024425E4EC}" << endl;
  71.  
  72.  lfolder.close();
  73.  
  74.  strcpy(attributes, "attrib +h +s ");
  75.  strcat(attributes, tempfolder);
  76.  
  77.  WinExec(attributes, NULL);
  78.  
  79.  lfolder.open("C:\\windows\\db.dat", ios::app);
  80.  lfolder << "Folder Locked: " << tempfolder << endl;
  81.  lfolder.close();
  82.  
  83.  cout << "\n\n" << tempfolder << " has been locked successfully!\n";
  84. }
  85.  
  86. void unlockfolder()
  87. {
  88.  char folder[255];
  89.  char tempfolder[255];
  90.  char attributes[50];
  91.  char del[50];
  92.  ofstream lfolder;
  93.  
  94.  setcolour(14);
  95.  
  96.  cout << "\nEnter the complete path to the Folder: ";
  97.  cin >> folder;//location
  98.  
  99.  strcpy(tempfolder, folder);
  100.  
  101.  strcat(folder, "\\Desktop.ini");
  102.  
  103.  strcpy(del, "del ");
  104.  strcat(del, folder);
  105.  system(del);
  106.  
  107.  strcpy(attributes, "attrib -h -s ");
  108.  strcat(attributes, tempfolder);
  109.  
  110.  WinExec(attributes, NULL);
  111.  
  112.  lfolder.open("C:\\windows\\db.dat", ios::app);
  113.  lfolder << "! Folder Unlocked: " << tempfolder << endl;
  114.  lfolder.close();
  115.  
  116.  cout << "\n\n" << tempfolder << " has been unlocked successfully!\n";
  117. }
Advertisement
RAW Paste Data Copied
Advertisement