Tag Archives: c#
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 extern IntPtr…

How to make a Http Web Request properly using C#

//.. private HttpWebRequest _httpwebrequest; //..//.. private HttpWebRequest _httpwebrequest; //.. private void button1_Click(object sender, EventArgs e) { Thread t = new…

FTP Uploading with C#

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

Get Active Window Title

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

How to terminate a process in c#

By name foreach (Process p in Process.GetProcessesByName("process_name")) { try { p.Kill(); p.WaitForExit(); } catch { } }foreach (Process p in…

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 =…

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))…

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);…

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 {…

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;…

Next Page