Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How we can Call Perform for OS Operations Using VB.Net

Author: Zunnair
Download Source Code : 740_Sample.zip

This article shows you the way in which you Perform Your OS Operations. This Article is use full in professional Aplications Because Some application basic requirement is Control OS by User Defined

For the better Understanding  Follow these Steps.

 

Start visual studio and create a new window application.

Set the following properties of your form.

 

FormBoarderStyle = FixedSingle

Maximize = False

 

Drop a label control and set the following properties.

Text = Click on the button to empty your recycle bin.

Drop a button control on your form and set its following properties.

 

Name = btEmpty

Text = Empty Recycle Bin

 

Now open your code window and write the following code in the code window.

The following code is to be placed just before the statement of your form designer. For example, code generated by the form designer.

Your code which is given below.

Code is as follows:

 

 

   Private Shared m_vb6FormDefInstance As frmMain

        Private Shared m_InitializingDefInstance As Boolean

        Public Shared Property DefInstance() As frmMain

 

        Get

            If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then

                m_InitializingDefInstance = True

                m_vb6FormDefInstance = New frmMain

                m_InitializingDefInstance = False

            End If

            DefInstance = m_vb6FormDefInstance

        End Get

        Set(ByVal Value As frmMain)

            m_vb6FormDefInstance = Value

        End Set

    End Property

 

Now declare the following function to call API’s.

Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hWnd As Integer, ByVal pszRootPath As String, ByVal dwFlags As Integer) As Integer

 

Const SHERB_NOPROGRESSUI As Short = &H2S

 

In the click event of your button write the following code which will call the API function declare above to empty recycle bin.

 

Dim retvaL As Object

retvaL = SHEmptyRecycleBin

(frmMain.DefInstance.Handle.ToInt32, "", SHERB_NOPROGRESSUI)

Dim ret As Object

ret = SHEmptyRecycleBin

m_InitializingDefInstance = True

m_vb6FormDefInstance = New frmMain

m_InitializingDefInstance = False

 

This is a simple article .i hope u will like and enjoying this Article. If you feel any difficulty then reference the source code.because Source code is given with this Article for your proper understanding.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< working with other application using System.Diagnostics.Process Name Space in VB.net 2.0.

Disclaimer - Privacy
© 2002-2017 DevASP.net