Quantcast
Channel: IT | Security | Hacking | Programming » c#
Browsing all 10 articles
Browse latest View live

Get all opened windows in C#

With the following code you can get all opened windows for the current user. public void GetOpenWindows() { IntPtr hwnd; try { foreach (System.Diagnostics.Process proc in...

View Article



Get system services with C#

To list system services, we are going to use ServiceController class. Add a reference to System.ServiceProcess namespace first. try { foreach (System.ServiceProcess.ServiceController s in...

View Article

Get system hard drives with C#

Retrieve the available disk drives with GetLogicalDrives function. try { foreach (String lodi in Environment.GetLogicalDrives()) if (lodi != String.Empty) Console.WriteLine(lodi); } catch (Exception) {...

View Article

Append files to zip file with C#

Open an existing zip file and append files with C# and DotNetZip library. public void AppendFile(String Filename, Zipfilename){ if (File.Exists(Zipfilename)) { ZipFile _zipfile =...

View Article

Calculate SHA1 hash from String in C#

Calculate SHA1 hash with this function. public String SHA1(String plaintext) { try { System.Security.Cryptography.SHA1 sha1 = System.Security.Cryptography.SHA1.Create(); byte[] bytes =...

View Article


How to terminate a process in c#

By name foreach (Process p in Process.GetProcessesByName("process_name")) { try { p.Kill(); p.WaitForExit(); } catch { } } By id try { Process p = Process.GetProcessById(process_id); p.Kill();...

View Article

Get Active Window Title

Get Active Window Title in C: #include <windows.h> #include <stdio.h>   int main() { char title[256] = ""; HWND handle = GetForegroundWindow(); if (handle) { GetWindowText(handle, title,...

View Article

FTP Uploading with C#

void ftpUpload(String filename, String ftpserver, String username, String password) { try { FileInfo file = new FileInfo(filename); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new...

View Article


How to make a Http Web Request properly using C#

//.. private HttpWebRequest _httpwebrequest; //.. private void button1_Click(object sender, EventArgs e) { Thread t = new Thread(new ThreadStart(Test)); t.IsBackground = true; t.Start(); } public void...

View Article


Perform click event on another application using C#

We will need the following methods: SendMessage, FindWindowEx, GetWindowTextLength, GetWindowText, EnumChildWindows pinvoke.net SendMessage [DllImport("user32.dll", CharSet = CharSet.Auto)] static...

View Article
Browsing all 10 articles
Browse latest View live




Latest Images