.net

Stop Playing Sounds in the Background

‘ —————————————- ‘  Required Imports : ‘ ‘  System ‘  Microsoft.VisualBasic ‘ —————————————-

My.Computer.Audio.Stop()

Opening and closing the CD tray in .NET

Microsoft .NET Framework doesn’t provide a method that you can simply call for opening or closing the CD or DVD tray of the computer drives. However, that doesn’t mean this can’t be easily accomplished by using the mciSendString from the Windows API. The project attached to this tutorial is created in Visual More >

Converting Word Documents to RTF, HTML, TXT, XML

Opening and manipulating Microsoft Office Word documents (.doc) can be done rather easily using the .NET Framework. You are capable of opening, editing and creating Word documents with only a few lines of code. However, since classes for managing the Word document format are not available in the .NET Framework, More >

Shut down system using C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. // Remember to add a reference to the System.Management assembly
  9. using System.Management;
  10. namespace ShutDown
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void btnShutDown_Click(object sender, EventArgs e)
  19. {
  20. ManagementBaseObject mboShutdown = null;
  21. ManagementClass mcWin32 = new ManagementClass(“Win32_OperatingSystem”);
  22. mcWin32.Get();
  23. // You can’t shutdown without security privileges
  24. mcWin32.Scope.Options.EnablePrivileges = true;
  25. ManagementBaseObject mboShutdownParams = mcWin32.GetMethodParameters(“Win32Shutdown”);
  26. // Flag 1 means More >

Capturing screenshots using C#

On the web, there are a few tutorials that will show you how to make a screen capture similar to the one that’s created and stored in the clipboard when the “Print Screen” button is pressed. However, you will find that these tutorials are a bit too complicated for such More >

File transfers through networks and the Internet

In this tutorial we’re going to build a very interesting .NET application, and based on the code here you will hopefully be able to build various applications or to help you with extending your current work.

Before digging into the code, you should know that the code you see in this tutorial More >

Convert ASCII values from hex to characters

  1. // An object storing the hex value
  2. string HexValue = “4765656B7065646961″;
  3. // An object storing the string value
  4. string StrValue = “”;
  5. // While there’s still something to convert in the hex string
  6. while (HexValue.Length > 0)
  7. {
  8. // Use ToChar() to convert each ASCII value (two hex digits) to the actual character
  9. StrValue += System.Convert.ToChar(System.Convert.ToUInt32(HexValue.Substring(0, 2), 16)).ToString();
  10. // Remove More >

Unzipping compressed files using GZipStream

Compressing (zipping)

In the previous tutorial entitled Zipping files using GZipStream we reviewed how to compress files using the System.IO.Compression namespace, and we also learned that the GZipStream class of this namespace has some limitations. If you haven’t read that tutorial, I suggest that you read it, and among other things you More >