How To : Change Drive Name Or Label In C#

driv
Changing Drive things are pretty easy with kernel32 so what we are going to do is just change the name or label , okay okay i know it's called label and not name most of the times :D . first of all let's design the Form .

Add two text boxes and two labels and a button and make your look like this(if you believe in my UI design)
ui des
Now coming to the coding , hmm we need to add kernel32 to the project so add the namespace using System.Runtime.InteropServices;  , Now import the kernel32.dll to your project by adding these codes under or on top of 
public Form1()
        {
            InitializeComponent();
        }
The codes(kernel32)
        [DllImport("kernel32")]
        static extern long SetVolumeLabelA(string lpRootName, string lpVolumeName);
After that go to your button(rename) click codes and add these
            long lab;
            lab = SetVolumeLabelA(textBox1.Text, textBox2.Text);
Now test your project , if it didn't work for you please let me know by commenting on this post or else contact me via the contact page I hope explanations are not needed for this simple codes , Thank you.

How To : Check Internet Connection In C#

covert
Amm, i think i wrote something about connecting and disconnecting the internet in vb.net that's actually a simple matter(process commands) . We are going to use wininet.dll in this tutorial so first of all add this namespace using System.Runtime.InteropServices; after that add this codes after InitializeComponent();  }  
 [DllImport("wininet.dll")]
        private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
        bool IsConnectedToInternet()
        {
            bool a;
            int xs;
            a = InternetGetConnectedState(out xs, 0);
            return a;
        }
What those lines of codes does is , it first adds the dll and then creates a function to use the API,So now to check the state of your internet connection let's use a if condition(;).
            if (IsConnectedToInternet() == true) MessageBox.Show("Internet Is Working");
            if (IsConnectedToInternet() == false) MessageBox.Show("Internet Is Not Working");
Just add those lines for a event to check the internet . Thanks For Reading , Peace.

How To Put HTML,CSS,JAVASCRIPT Codes In Your Blogger Articles

covert
Yes this is my second blogger tutorial , actually this is something i had to do to solve a problem . i use alexgorbatchev.com/SyntaxHighlighter but it seems that if i use anything similar to class in any language then some span tags cover them so the code goes wrong so i was looking for something that will fix my big problem then i found prism.js so i tried it and it's really great those span tags were not there so i wanted to share this with you .

Details of the script

/**
 * prism.js default theme for JavaScript, CSS and HTML
 * Based on dabblet (http://dabblet.com)
 * @author Lea Verou
 */

So to use it in your blogger blog or normal website , just add these under your head tag

Usage :


replace markup with your language name :).

by the way they also provide themes and plugins also you can select the languages , just go to prismjs.com and then go to download there you will be able to select the languages and plugins finally download the css and js.

Hope you like this tutorial , peace.

How To Capture Entire Screen In Java


capture jn
Another quick tutorial on capturing your entire screen with java actually sometimes java makes me mad because sometimes i have to import loads of namespaces than c# or vb.net anyways , as usual to do something in system we import IO thingy yes we are using it here .

import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.*;

class Snap
{
 public static void main(String args[]) throws Exception
 {
     Robot awt_robot = new Robot();
  BufferedImage Entire_Screen = awt_robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
  ImageIO.write(Entire_Screen, "PNG", new File("Entire_Screen.png"));
 }
}

How To List Down Countries In Java

java countries
Java is something what really impressed me than other programming languages anyways today we'll see how to list down all the countries and their country code . I don't know whether you know theres a small library called Locale in java.util namspace so that's what i am using here to do the thing .

import java.util.*;
 /* Author : Mohamed Shimran
    Blog : http://ultimateprogrammingtutorials.blogspot.com
 */
class Countries {
    public static void main(String args[]) {
    String[] cntry = Locale.getISOCountries();
 for (String countryCode : cntry) {
  Locale obj = new Locale("", countryCode);
  System.out.println("Country Code = " + obj.getCountry() 
   + ", Country Name = " + obj.getDisplayCountry());
  }
    }
}
NOTE: i was using public class but i had to remove it because my class thingy goes mad still it works actually public class is not needed.

How To Get Mouse Location(X,Y) In C#

I know this is very basic but i am bored so writing this .
The program we are going to make will show you the mouse cursor location, okay first of all click your form and then go to event (the lightning icon in your properties tab) and then search for MouseMove and just double click on it.
How To Get Mouse Location(X,Y) In C#
After that you will fall into the mouse_move event , go to designer and add two labels and just write down the below codes in MouseMove
label1.Text = "X : "+e.X.ToString();
            label2.Text = "Y : "+e.Y.ToString();

Now debug and try moving your mouse .

How To Add Values To ListBox In C#

Adding values to a listbox is something really easy anyways if you don't know how to add values to a listbox then here you go.

You need to add these things to your project first of all
  1. Three buttons (add,show,clear)
  2. Listbox
  3. Textbox

Inter Process Communication in C#

Introduction

Alright, so you guys might know about the famous web-browser, Google Chrome. One remarkable thing in this (pretty) simple looking application is the use of a programming technique called IPC or Interprocess Communication; with IPC you can communicate with another process without invoking and other third party events. One of the most irritating about .Net is that the app freezes if it is trying to communicate with a web-service. With IPC we can eradicate this problem.

What can you do with it?

So, lets first take an example of what exactly we can do with this: suppose that you have a licensing application named LicMan.exe and a processing app called LicPro.exe. LicMan has the UI and every other part of standard human interference. And LicPro.exe just takes the License Key provided and then processes it and sends it back to LicMan.exe for display. This way the app would not hang and you have a happy customer :-)

Lots of bad ways of doing IPC:

  • Shared Memory: Difficult to manage and set-up.
  • Shared Files / Registry: Very slow doe to the writing & reading to/from disk. Difficult to manage as well.
  • SendMessage / PostMessage: Locks up the UI thread while the message is processed. Messages are limited to integer values. Can't communicate from a non-admin process to a admin process. Assumes that your process has a window. 

How To Make A Proxy Grabber In VB.NET

How To Make A Proxy Grabber In VB.NET
Okay now we are going to make a proxy grabber , so what is this proxy grabber thing ? first of all proxy is something that covers your ip address(it's like you put a jacket when snow falls lol ) and grabber ? grabber is  meant for something that will fetch you things or whatever it's called . For this tutorial we are using websites that provides proxies so we use httpwebrequest and grab the proxies from the website and we check for the right format by using regex .

Let's start ,
First go ahead and create a new project and we need a ListBox and Three Buttons so just add them . After adding them to your form arrange as you see in the below picture.
How To Make A Proxy Grabber In VB.NET
Now coming to the coding point , first add Imports System.Text.RegularExpressions namespace because we use regex as i said before , first open the button click event which is the grab button and add this codes.
 'creating our httpwebrequest target NOTE: you can use any websites that use to provide proxies directly
        Dim the_request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://proxy-ip-list.com")
        'creating the httpwebresponce
        Dim the_response As System.Net.HttpWebResponse = the_request.GetResponse
        'defining the stream reader to read the data from the httpwebresponse
        Dim stream_reader As System.IO.StreamReader = New System.IO.StreamReader(the_response.GetResponseStream())
        'defining a string to stream reader fisnished streaming
        Dim code As String = stream_reader.ReadToEnd
        'haha here we use the regex
        Dim expression As New System.Text.RegularExpressions.Regex("[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:[0-9]{1,4}")
        'adding the proxies to the listbox
        Dim mtac As MatchCollection = expression.Matches(code)
        For Each itemcode As Match In mtac
            ListBox1.Items.Add(itemcode)
        Next
After the first button we will see the second button which save.
   If ListBox1.Items.Count = (0) Then
            MessageBox.Show("Please click grab to grab proxies and then try saving", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Else
            'defining a streamwriter
            Dim S_W As IO.StreamWriter
            'converting listbox items to string
            Dim itms() As String = {ListBox1.Items.ToString}
            ''defining a savefiledialog
            Dim save As New SaveFileDialog
            Dim it As Integer
            save.FileName = "Grabbed Proxies"
            save.Filter = "Grabbed Proxies (*.txt)|*.txt|ALL Files (*.*)|*.*"
            save.CheckPathExists = True
            save.ShowDialog(Me)
            S_W = New IO.StreamWriter(save.FileName)
            For it = 0 To ListBox1.Items.Count - 1
                S_W.WriteLine(ListBox1.Items.Item(it))
            Next
            S_W.Close()
        End If
At last we need to add a line of code to clear the listbox which is
        ListBox1.Items.Clear()

Finally debug your program and test test .. How To Make A Proxy Grabber In VB.NET
YAY it's working ,I have explained the code by commenting over the codes and i hope this is helpful . thanks