Namespaces of .Net

Thursday, April 30, 2009

System: Includes essential classes and base classes for commonly used data types, events, exceptions and so on
System.Collections: Includes classes and interfaces that define various collection of objects such as list, queues,
hash tables, arrays, etc
System.Data: Includes classes which lets us handle data from data sources
System.Data.OleDb: Includes classes that support the OLEDB .NET provider
System.Data.SqlClient: Includes classes that support the SQL Server .NET provider
System.Diagnostics: Includes classes that allow to debug our application and to step through our code
System.Drawing: Provides access to drawing methods
System.Globalization: Includes classes that specify culture-related information
System.IO: Includes classes for data access with Files
System.Net: Provides interface to protocols used on the internet
System.Reflection: Includes classes and interfaces that return information about types, methods and fields
System.Security: Includes classes to support the structure of common language runtime security system
System.Threading: Includes classes and interfaces to support multithreaded applications
System.Web: Includes classes and interfaces that support browser-server communication
System.Web.Services: Includes classes that let us build and use Web Services
System.Windows.Forms: Includes classes for creating Windows based forms
System.XML: Includes classes for XML support

Extract the icon From Exe

Wednesday, April 29, 2009

______________________ Class Definition_____________________




Imports System
Imports System.Drawing
Imports System.Runtime.InteropServices

Public Class ClsExtractIcon

'=====================================================================================
' Enumerations
'=====================================================================================
Private Enum SHGFI
SmallIcon = &H1
LargeIcon = &H0
Icon = &H100
DisplayName = &H200
Typename = &H400
SysIconIndex = &H4000
UseFileAttributes = &H10
End Enum

Public Enum IconSize
SmallIcon = 1
LargeIcon = 0
End Enum

'=====================================================================================
' Structures
'=====================================================================================
_
Private Structure SHFILEINFO
Public hIcon As IntPtr
Public iIcon As Integer
Public dwAttributes As Integer
Public szDisplayName As String
Public szTypeName As String

Public Sub New(ByVal B As Boolean)
hIcon = IntPtr.Zero
iIcon = 0
dwAttributes = 0
szDisplayName = vbNullString
szTypeName = vbNullString
End Sub
End Structure

'=====================================================================================
' API Calls
'=====================================================================================
Private Declare Auto Function SHGetFileInfo Lib "shell32" (ByVal pszPath As String, ByVal dwFileAttributes As Integer, ByRef psfi As SHFILEINFO, ByVal cbFileInfo As Integer, ByVal uFlagsn As SHGFI) As Integer

'=====================================================================================
' Functions and Procedures...
'=====================================================================================
Public Shared Function GetDefaultIcon(ByVal Path As String, Optional ByVal IconSize As IconSize = IconSize.SmallIcon, Optional ByVal SaveIconPath As String = "") As Icon
Dim info As New SHFILEINFO(True)
Dim cbSizeInfo As Integer = Marshal.SizeOf(info)
Dim flags As SHGFI = SHGFI.Icon Or SHGFI.UseFileAttributes
flags = flags + IconSize
SHGetFileInfo(Path, 256, info, cbSizeInfo, flags)
GetDefaultIcon = Icon.FromHandle(info.hIcon)
If SaveIconPath <> "" Then
Dim FileStream As New IO.FileStream(SaveIconPath, IO.FileMode.Create)
GetDefaultIcon.Save(FileStream)
FileStream.Close()
End If
End Function 'GetDefaultIcon(ByVal Path As String, Optional ByVal IconSize As IconSize = IconSize.SmallIcon, Optional ByVal SaveIconPath As String = "") As Icon

Public Shared Function GetDefaultImage(ByVal Path As String, Optional ByVal IconSize As IconSize = IconSize.SmallIcon) As Image
Dim info As New SHFILEINFO(True)
Dim cbSizeInfo As Integer = Marshal.SizeOf(info)
Dim flags As SHGFI = SHGFI.Icon Or SHGFI.UseFileAttributes
flags = flags + IconSize
SHGetFileInfo(Path, 256, info, cbSizeInfo, flags)
GetDefaultImage = Icon.FromHandle(info.hIcon).ToBitmap
End Function 'GetDefaultIcon(ByVal Path As String, Optional ByVal IconSize As IconSize = IconSize.SmallIcon, Optional ByVal SaveIconPath As String = "") As Icon

'=====================================================================================
Public Shared Function ImageToIcon(ByVal SourceImage As Image) As Icon
' converts an image into an icon
Dim TempBitmap As New Bitmap(SourceImage)
ImageToIcon = Icon.FromHandle(TempBitmap.GetHicon())
TempBitmap.Dispose()
End Function 'ImageToIcon(ByVal SourceImage As Image) As Icon
'=====================================================================================

End Class


_________________________ Class Definition End Here________________________

Now create an object of the class

Dim ObjGetIcon As New ClsExtractIcon
ContronName.Image = ObjGetIcon.GetDefaultImage("Path of Exe", ClsExtractIcon.IconSize.LargeIcon)

Programatically Open DSN Window in VB.Net

System.Diagnostics.Process.Start("ODBCad32")

Send SMS in VB.Net

For Sending a SMS

you have to purchase the SMS gateway and correspondingly you will get the url for that


Example URL= "http://.xyz/default.aspx/sendSMSusername=???password=????
Dim TempURL As String = URL
For Sending a SMS you have to purchase the SMS gateway and correspondingly you will get the url for that


________________________Code________________________________

Dim useMsg As String
Dim i As Integer
Dim c As String
Try
' Convert characters in the message text
useMsg = ""
For i = 1 To Len(URL)
c = Mid(URL, i, 1)
Select Case c
Case vbCrLf : c = "%0A"
Case vbLf : c = "%0D"
Case " " : c = "%20"
Case "+" : c = "%2B"
Case """" : c = "%22"
Case "#" : c = "%23"
Case "%" : c = "%25"
Case "&" : c = "%26"
Case "," : c = "%2C"
Case "." : c = "%2E"
Case "/" : c = "%2F"
Case ":" : c = "%3A"
Case ";" : c = "%3B"
Case "<" : c = "%3C"
Case "=" : c = "%3D"
Case ">" : c = "%3E"
Case "?" : c = "%3F"
Case "¡" : c = "%A1"
Case "£" : c = "%A3"
Case "#" : c = "%A4"
Case "¥" : c = "%A5"
Case "§" : c = "%A7"
Case "Ä" : c = "%C4"
Case "Å" : c = "%C5"
Case "à" : c = "%E0"
Case "ä" : c = "%E4"
Case "å" : c = "%E5"
Case "Æ" : c = "%C6"
Case "Ç" : c = "%C7"
Case "É" : c = "%C9"
Case "è" : c = "%E8"
Case "é" : c = "%E9"
Case "ì" : c = "%EC"
Case "Ñ" : c = "%D1"
Case "ñ" : c = "%F1"
Case "ò" : c = "%F2"
Case "ö" : c = "%F6"
Case "Ø" : c = "%D8"
Case "Ö" : c = "%D6"
Case "Ü" : c = "%DC"
Case "ù" : c = "%F9"
Case "ü" : c = "%FC"
Case "ß" : c = "%DF"
End Select
useMsg = useMsg + c
Next

Dim Query As String
Dim qLen As Integer
' Construct the HTTP query string
' qLen = Len(Query)
' Request and Response objects
Dim objReq As System.Net.HttpWebRequest
Dim objRes As System.Net.HttpWebResponse

Dim sr As System.IO.StreamReader
Dim sw As System.IO.StreamWriter
Dim ResultantString As String = ""
Dim ret As String = "1"
Dim MAXID As Long

objReq = System.Net.WebRequest.Create(URL)
objReq.Method = "POST"
objReq.ContentType = "application/x-www-form-urlencoded; charset=""utf-8"""
objReq.ContentLength = qLen

sw = New System.IO.StreamWriter(objReq.GetRequestStream())
sw.Write(Query)
sw.Close()
objRes = objReq.GetResponse()
sr = New System.IO.StreamReader(objRes.GetResponseStream())
ret = sr.ReadToEnd()
________________ End Here________________________________
And Finally you can store the responce either in Database or File

Check the table whether it exist or not

Private Function fcheckTable(ByVal sDatabaseName As String, ByVal Tablename As String) As Boolean
Try
fcheckTable = False
Dim sSQL As String = "show tables in " & sDatabaseName
objCmd = New OdbcCommand(sSQL, ObjCon)
Dim oRS As Odbc.OdbcDataReader = objCmd.ExecuteReader
Do While oRS.Read
If Trim(UCase(Tablename)) = Trim(UCase(oRS(0))) Then fcheckTable = True
Loop
oRS.Close()


Catch ex As Exception
MsgBox(Err.Description)
End Try
End Function

Get The Tables List From a database

Private Sub GetTables(ByVal sDatabaseName As String)
Try

Dim sSQL As String = "show tables in " & sDatabaseName
objCmd = New OdbcCommand(sSQL, ObjCon)
'Cmd = CN.CreateCommand
'Cmd.CommandText = sSQL

Dim oRS As Odbc.OdbcDataReader = objCmd.ExecuteReader
'Do While oRS.Read
cbotablename.Items.Add(oRS(0))
Loop
oRS.Close()


Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub