Click here to Skip to main content
15,884,388 members
Articles / Programming Languages / Visual Basic

SmartLink

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
16 Dec 2006CPOL2 min read 58.5K   1.2K   31  
SmartLink allows to group together the files across the network in logical folders, Groups
Imports System.IO
Imports System.Xml
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Threading

Module modMain

#Region "Variable Declaration"
    Const Add_Link As Integer = 0
    Const Linked_Files As Integer = 1
    Const Remove_Link As Integer = 2

    Public MODNAME As String
    Public FILENAME As String
    Public XMLFILEPATH As String

    Public XMLDOC As XmlDocument
#End Region

#Region "DLL Imports"
    Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias _
"ExtractAssociatedIconA" (ByVal hInst As IntPtr, ByVal lpIconPath As _
String, ByRef lpiIcon As Integer) As IntPtr

    <DllImport("user32", CallingConvention:=CallingConvention.Cdecl)> _
Public Function DestroyIcon(ByVal hIcon As IntPtr) As Boolean
    End Function
#End Region

#Region "Main"


    Sub Main()
        Dim ArgArray() As String
        Dim cmdLine As String = Microsoft.VisualBasic.Command()

        'If cmdLine.Length = 0 Then
        '    End
        'End If

        ArgArray = cmdLine.Split(",")
        MODNAME = ArgArray(0)
        FILENAME = ArgArray(1)

        XMLFILEPATH = Application.StartupPath & "\Data.xml"

        'Select Case MODNAME
        '    Case Add_Link
        '        Dim frm As New frmLink
        '        frm.ShowDialog()

        '    Case Linked_Files
        '        Dim frm As New frmLinkedFiles
        '        frm.ShowDialog()

        '    Case Remove_Link
        '        Dim frm As New frmRemoveLink
        '        frm.ShowDialog()

        'End Select

        FILENAME = "D:\DOCUME~1\SHIRIS~1\Desktop\donsrk05.rm"
        Dim frm As New frmLink
        frm.ShowDialog()
    End Sub
#End Region

#Region "Common Procedures & Functions"
    Public Sub LoadXML()
        Try
            If Not XMLDOC Is Nothing Then
                XMLDOC = Nothing
            End If

            XMLDOC = New XmlDocument

            If File.Exists(XMLFILEPATH) Then
                XMLDOC.Load(XMLFILEPATH)
            Else
                Dim xmlString As String

                xmlString = "<Data><Group><GroupName></GroupName></Group></Data>"
                XMLDOC.LoadXml(xmlString)
            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Public Function GetIconFileType(ByVal FileName As String) As Bitmap
        Try
            Dim hIcon As IntPtr
            Dim IconPic As Bitmap

            hIcon = ExtractAssociatedIcon(Process.GetCurrentProcess().Handle, FileName, 1)

            IconPic = Icon.FromHandle(hIcon).ToBitmap
            Call DestroyIcon(hIcon)

            Return IconPic

        Catch ex As Exception
            MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Function
#End Region

End Module

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
India India
Hey, this is Shirish a software guy by profession. Along with my hectic job schedule, I like to work on different ideas. I am in total love with all the GUI related things. I also like to work with the databases. I enjoy, to develop some simple tools which can be useful to other software professionls like me as well the normal users.

Please feel free to contact me with suggestions/ideas, at mentioned email address.
shirish.wagh@yahoo.com

Comments and Discussions