Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
කිතුල් තලප
Manoj Suranga Bandara
Updated:
Yesterday at 7:04 PM
Ad icon
ව්යාපාර, Tuition පන්ති සහ Personal Portfolios සඳහා Web Setup එකක් රු. 9,099/- කට (වාර්ෂික renewal ර
thathsilura
Updated:
Thursday at 6:17 PM
AWS Certified Solutions Architect-Associate + AWS Certified Cloud Practitioner
Sanjeewani95
Updated:
Aug 19, 2026
🚀 එක පැකේජ් එකයි - මාසෙටම Unlimited Internet! 🌐
sayuru bandara
Updated:
Aug 18, 2026
🎬 CapCut Pro 1 Month Access! LKR 600
sayuru bandara
Updated:
Aug 18, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
Computers & Internet
Software Development
මෘදුකාංගයක් සෑදීමට උපකාරයක් දෙන්න.
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="visula kavinda" data-source="post: 30470648" data-attributes="member: 577973"><p>මෙන්න කේතය</p><p>Imports System.Diagnostics</p><p>Imports System.Drawing</p><p>Imports System.Windows.Forms</p><p></p><p>'Imports Microsoft.VisualBasic.FileIO</p><p>Module Module1</p><p> Function GetShortcutIcon(ByVal shortcutPath As String) As Icon</p><p> Try</p><p> ' Get the target path of the shortcut</p><p> Dim targetPath As String = GetShortcutTarget(shortcutPath)</p><p></p><p> ' Extract the icon associated with the target file</p><p> If targetPath IsNot Nothing AndAlso IO.File.Exists(targetPath) Then</p><p> Return Icon.ExtractAssociatedIcon(targetPath)</p><p> Else</p><p> Return Nothing</p><p> End If</p><p> Catch ex As Exception</p><p> ' Handle exceptions here</p><p> Return Nothing</p><p> End Try</p><p> End Function</p><p></p><p></p><p> Function GetShortcutTarget(ByVal shortcutPath As String) As String</p><p> Try</p><p> Dim shortcut As Shell32.Shell = New Shell32.Shell()</p><p> Dim folder As Shell32.Folder = shortcut.NameSpace(System.IO.Path.GetDirectoryName(shortcutPath))</p><p> Dim folderItem As Shell32.FolderItem = folder.ParseName(System.IO.Path.GetFileName(shortcutPath))</p><p> If folderItem IsNot Nothing Then</p><p> Dim link As Shell32.ShellLinkObject = CType(folderItem.GetLink, Shell32.ShellLinkObject)</p><p> Return link.Path</p><p> Else</p><p> Return Nothing</p><p> End If</p><p> Catch ex As Exception</p><p> Return Nothing</p><p> End Try</p><p> End Function</p><p></p><p></p><p> '' Structure for the WIN32_FIND_DATA structure returned by FindFirstFile and others</p><p> '<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)></p><p> 'Structure WIN32_FIND_DATA</p><p> ' Public dwFileAttributes As Integer</p><p> ' Public ftCreationTime As Long</p><p> ' Public ftLastAccessTime As Long</p><p> ' Public ftLastWriteTime As Long</p><p> ' Public nFileSizeHigh As Integer</p><p> ' Public nFileSizeLow As Integer</p><p> ' Public dwReserved0 As Integer</p><p> ' Public dwReserved1 As Integer</p><p> ' <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public cFileName As String</p><p> ' <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=14)> Public cAlternateFileName As String</p><p> 'End Structure</p><p></p><p> '' Function declarations</p><p> 'Declare Function FindFirstFile Lib "kernel32.dll" Alias "FindFirstFileA" (ByVal lpFileName As String, ByRef lpFindFileData As WIN32_FIND_DATA) As IntPtr</p><p> 'Declare Function FindClose Lib "kernel32.dll" (ByVal hFindFile As IntPtr) As Boolean</p><p> 'Declare Unicode Function PathCombine Lib "shlwapi.dll" Alias "PathCombineW" (ByVal pszDest As System.Text.StringBuilder, ByVal pszDir As String, ByVal pszFile As String) As IntPtr</p><p></p><p> '' Function to retrieve target path of a shortcut</p><p> 'Function GetShortcutTarget(ByVal shortcutPath As String) As String</p><p> ' Dim WIN32_FILE_ATTRIBUTE_DIRECTORY As Integer = &H10</p><p> ' Dim FILE_ATTRIBUTE_REPARSE_POINT As Integer = &H400</p><p></p><p> ' Try</p><p> ' Dim findData As New WIN32_FIND_DATA()</p><p> ' Dim handle As IntPtr = FindFirstFile(shortcutPath, findData)</p><p></p><p> ' If handle.ToInt64() <> -1 Then</p><p> ' If (findData.dwFileAttributes And WIN32_FILE_ATTRIBUTE_DIRECTORY) <> 0 AndAlso (findData.dwFileAttributes And FILE_ATTRIBUTE_REPARSE_POINT) <> 0 Then</p><p> ' Dim targetPathBuilder As New System.Text.StringBuilder(260)</p><p> ' PathCombine(targetPathBuilder, shortcutPath, findData.cFileName)</p><p> ' Return targetPathBuilder.ToString()</p><p> ' End If</p><p> ' End If</p><p></p><p> ' FindClose(handle)</p><p> ' Catch ex As Exception</p><p> ' ' Handle exceptions here</p><p> ' Return Nothing</p><p> ' End Try</p><p></p><p> ' Return Nothing</p><p> 'End Function</p><p></p><p></p><p> Class ToolStripMenuItemEX</p><p> Inherits ToolStripMenuItem</p><p> Friend ID As Integer</p><p> End Class</p><p> Dim ls() As String</p><p> Function make_ITEM(ByRef s As String, i As Integer) As ToolStripMenuItemEX</p><p> Dim targetPath As String = GetShortcutTarget(ls(i))</p><p></p><p></p><p> Dim cx As New ToolStripMenuItemEX()</p><p> cx.Text = s</p><p> cx.ID = i</p><p></p><p> If IO.File.Exists(targetPath) = True Then</p><p> cx.Image = Icon.ExtractAssociatedIcon(targetPath).ToBitmap</p><p> ls(i) = targetPath</p><p> Else</p><p> ' MsgBox("|" + targetPath + "|")</p><p> If targetPath.Contains("\Program Files (x86)\") Then</p><p> targetPath = targetPath.Replace("\Program Files (x86)\", "\Program Files\")</p><p> If IO.File.Exists(targetPath) Then</p><p> cx.Image = Icon.ExtractAssociatedIcon(targetPath).ToBitmap</p><p> ls(i) = targetPath</p><p> Else</p><p> cx.Enabled = False</p><p> End If</p><p> Else</p><p> cx.Enabled = False</p><p> End If</p><p> End If</p><p></p><p> AddHandler cx.Click, AddressOf OnClickEX</p><p> Return cx</p><p> End Function</p><p> Sub Main()</p><p> ' Create a new ContextMenuStrip</p><p> Dim contextMenu As New ContextMenuStrip()</p><p> contextMenu.Items.Add("වසන්න X ", Nothing, AddressOf Close_OnClick)</p><p></p><p></p><p> If IO.Directory.Exists(Application.StartupPath + "\කෙටි මං") Then</p><p> ls = IO.Directory.GetFiles(Application.StartupPath + "\කෙටි මං", "*.lnk", IO.SearchOption.TopDirectoryOnly)</p><p> Else</p><p> ls = IO.Directory.GetFiles(Application.StartupPath, "*.lnk", IO.SearchOption.TopDirectoryOnly)</p><p> End If</p><p></p><p></p><p> ' Array.Sort(ls)</p><p></p><p> Dim i As Integer</p><p> Dim Fc As Char = Chr(0)</p><p> Dim fcc As Char = Chr(0)</p><p> Dim s As String</p><p> Dim cI As ToolStripMenuItem</p><p></p><p> Dim cX As ToolStripMenuItemEX</p><p> For i = 0 To ls.Length - 1</p><p> s = IO.Path.GetFileNameWithoutExtension(ls(i))</p><p> fcc = Char.ToLower(s(0))</p><p> If Fc = fcc Then</p><p> cX = make_ITEM(s, i)</p><p></p><p> cI.DropDownItems.Add(cX)</p><p> Else</p><p> If i = ls.Length - 1 Then</p><p> cX = make_ITEM(s, i)</p><p></p><p> contextMenu.Items.Add(cX)</p><p> ' Fc = s(0)</p><p></p><p> ElseIf Char.ToLower(ls(i + 1)(0)) = Fc Then</p><p> ' MsgBox(Fc + vbCrLf + s)</p><p> cX = make_ITEM(s, i)</p><p></p><p> cI.DropDownItems.Add(cX)</p><p> ' Fc = s(0)</p><p> Else</p><p> cI = New ToolStripMenuItem(Char.ToUpper(s(0)))</p><p> contextMenu.Items.Add(cI)</p><p></p><p> cX = make_ITEM(s, i)</p><p></p><p> cI.DropDownItems.Add(cX)</p><p> ' Fc = s(0)</p><p> End If</p><p> End If</p><p> Fc = fcc</p><p> ' contextMenu.Items.Add(IO.Path.GetFileNameWithoutExtension(s))</p><p> Next</p><p></p><p> contextMenu.Items.Add(" <img class="smilie smilie--emoji" loading="lazy" alt="⚙️" title="Gear :gear:" src="https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/2699.png" data-shortname=":gear:" /> ", Nothing, AddressOf Settings_OnClick)</p><p></p><p></p><p></p><p> '=======================================================================================</p><p> ' Handle the LostFocus event to close the application when focus is lost</p><p></p><p> AddHandler contextMenu.LostFocus, Sub(sender, e) Application.Exit()</p><p></p><p> ' Show the context menu</p><p> contextMenu.Show(Control.MousePosition)</p><p> ' Run the application message loop manually to prevent premature exit</p><p> Application.Run()</p><p> End Sub</p><p></p><p> Friend Sub OnClickEX(sender As ToolStripMenuItemEX, e As EventArgs)</p><p> '' This event handler does nothing</p><p> '' MsgBox(ls(sender.ID))</p><p> ''MsgBox(ls(sender.ID) + vbCrLf + GetShortcutTarget(ls(sender.ID)))</p><p> 'Dim exe_ As String = GetShortcutTarget(ls(sender.ID))</p><p> 'If IO.File.Exists(exe_) = True Then</p><p> ' Dim processInfo As New ProcessStartInfo(exe_)</p><p> ' Process.Start(processInfo)</p><p> ' Application.Exit()</p><p> 'Else</p><p> ' sender.Enabled = False</p><p> 'End If</p><p></p><p></p><p> Dim processInfo As New ProcessStartInfo(ls(sender.ID))</p><p> Process.Start(processInfo)</p><p> Application.Exit()</p><p> End Sub</p><p> Sub Close_OnClick(sender As Object, e As EventArgs)</p><p> ' This event handler does nothing</p><p> ' MsgBox("sadfdsad")</p><p> Application.Exit()</p><p> End Sub</p><p> Sub Settings_OnClick(sender As Object, e As EventArgs)</p><p> ' This event handler does nothing</p><p> ' MsgBox("sadfdsad")</p><p> Application.Exit()</p><p> End Sub</p><p>End Module</p></blockquote><p></p>
[QUOTE="visula kavinda, post: 30470648, member: 577973"] මෙන්න කේතය Imports System.Diagnostics Imports System.Drawing Imports System.Windows.Forms 'Imports Microsoft.VisualBasic.FileIO Module Module1 Function GetShortcutIcon(ByVal shortcutPath As String) As Icon Try ' Get the target path of the shortcut Dim targetPath As String = GetShortcutTarget(shortcutPath) ' Extract the icon associated with the target file If targetPath IsNot Nothing AndAlso IO.File.Exists(targetPath) Then Return Icon.ExtractAssociatedIcon(targetPath) Else Return Nothing End If Catch ex As Exception ' Handle exceptions here Return Nothing End Try End Function Function GetShortcutTarget(ByVal shortcutPath As String) As String Try Dim shortcut As Shell32.Shell = New Shell32.Shell() Dim folder As Shell32.Folder = shortcut.NameSpace(System.IO.Path.GetDirectoryName(shortcutPath)) Dim folderItem As Shell32.FolderItem = folder.ParseName(System.IO.Path.GetFileName(shortcutPath)) If folderItem IsNot Nothing Then Dim link As Shell32.ShellLinkObject = CType(folderItem.GetLink, Shell32.ShellLinkObject) Return link.Path Else Return Nothing End If Catch ex As Exception Return Nothing End Try End Function '' Structure for the WIN32_FIND_DATA structure returned by FindFirstFile and others '<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> 'Structure WIN32_FIND_DATA ' Public dwFileAttributes As Integer ' Public ftCreationTime As Long ' Public ftLastAccessTime As Long ' Public ftLastWriteTime As Long ' Public nFileSizeHigh As Integer ' Public nFileSizeLow As Integer ' Public dwReserved0 As Integer ' Public dwReserved1 As Integer ' <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public cFileName As String ' <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=14)> Public cAlternateFileName As String 'End Structure '' Function declarations 'Declare Function FindFirstFile Lib "kernel32.dll" Alias "FindFirstFileA" (ByVal lpFileName As String, ByRef lpFindFileData As WIN32_FIND_DATA) As IntPtr 'Declare Function FindClose Lib "kernel32.dll" (ByVal hFindFile As IntPtr) As Boolean 'Declare Unicode Function PathCombine Lib "shlwapi.dll" Alias "PathCombineW" (ByVal pszDest As System.Text.StringBuilder, ByVal pszDir As String, ByVal pszFile As String) As IntPtr '' Function to retrieve target path of a shortcut 'Function GetShortcutTarget(ByVal shortcutPath As String) As String ' Dim WIN32_FILE_ATTRIBUTE_DIRECTORY As Integer = &H10 ' Dim FILE_ATTRIBUTE_REPARSE_POINT As Integer = &H400 ' Try ' Dim findData As New WIN32_FIND_DATA() ' Dim handle As IntPtr = FindFirstFile(shortcutPath, findData) ' If handle.ToInt64() <> -1 Then ' If (findData.dwFileAttributes And WIN32_FILE_ATTRIBUTE_DIRECTORY) <> 0 AndAlso (findData.dwFileAttributes And FILE_ATTRIBUTE_REPARSE_POINT) <> 0 Then ' Dim targetPathBuilder As New System.Text.StringBuilder(260) ' PathCombine(targetPathBuilder, shortcutPath, findData.cFileName) ' Return targetPathBuilder.ToString() ' End If ' End If ' FindClose(handle) ' Catch ex As Exception ' ' Handle exceptions here ' Return Nothing ' End Try ' Return Nothing 'End Function Class ToolStripMenuItemEX Inherits ToolStripMenuItem Friend ID As Integer End Class Dim ls() As String Function make_ITEM(ByRef s As String, i As Integer) As ToolStripMenuItemEX Dim targetPath As String = GetShortcutTarget(ls(i)) Dim cx As New ToolStripMenuItemEX() cx.Text = s cx.ID = i If IO.File.Exists(targetPath) = True Then cx.Image = Icon.ExtractAssociatedIcon(targetPath).ToBitmap ls(i) = targetPath Else ' MsgBox("|" + targetPath + "|") If targetPath.Contains("\Program Files (x86)\") Then targetPath = targetPath.Replace("\Program Files (x86)\", "\Program Files\") If IO.File.Exists(targetPath) Then cx.Image = Icon.ExtractAssociatedIcon(targetPath).ToBitmap ls(i) = targetPath Else cx.Enabled = False End If Else cx.Enabled = False End If End If AddHandler cx.Click, AddressOf OnClickEX Return cx End Function Sub Main() ' Create a new ContextMenuStrip Dim contextMenu As New ContextMenuStrip() contextMenu.Items.Add("වසන්න X ", Nothing, AddressOf Close_OnClick) If IO.Directory.Exists(Application.StartupPath + "\කෙටි මං") Then ls = IO.Directory.GetFiles(Application.StartupPath + "\කෙටි මං", "*.lnk", IO.SearchOption.TopDirectoryOnly) Else ls = IO.Directory.GetFiles(Application.StartupPath, "*.lnk", IO.SearchOption.TopDirectoryOnly) End If ' Array.Sort(ls) Dim i As Integer Dim Fc As Char = Chr(0) Dim fcc As Char = Chr(0) Dim s As String Dim cI As ToolStripMenuItem Dim cX As ToolStripMenuItemEX For i = 0 To ls.Length - 1 s = IO.Path.GetFileNameWithoutExtension(ls(i)) fcc = Char.ToLower(s(0)) If Fc = fcc Then cX = make_ITEM(s, i) cI.DropDownItems.Add(cX) Else If i = ls.Length - 1 Then cX = make_ITEM(s, i) contextMenu.Items.Add(cX) ' Fc = s(0) ElseIf Char.ToLower(ls(i + 1)(0)) = Fc Then ' MsgBox(Fc + vbCrLf + s) cX = make_ITEM(s, i) cI.DropDownItems.Add(cX) ' Fc = s(0) Else cI = New ToolStripMenuItem(Char.ToUpper(s(0))) contextMenu.Items.Add(cI) cX = make_ITEM(s, i) cI.DropDownItems.Add(cX) ' Fc = s(0) End If End If Fc = fcc ' contextMenu.Items.Add(IO.Path.GetFileNameWithoutExtension(s)) Next contextMenu.Items.Add(" ⚙️ ", Nothing, AddressOf Settings_OnClick) '======================================================================================= ' Handle the LostFocus event to close the application when focus is lost AddHandler contextMenu.LostFocus, Sub(sender, e) Application.Exit() ' Show the context menu contextMenu.Show(Control.MousePosition) ' Run the application message loop manually to prevent premature exit Application.Run() End Sub Friend Sub OnClickEX(sender As ToolStripMenuItemEX, e As EventArgs) '' This event handler does nothing '' MsgBox(ls(sender.ID)) ''MsgBox(ls(sender.ID) + vbCrLf + GetShortcutTarget(ls(sender.ID))) 'Dim exe_ As String = GetShortcutTarget(ls(sender.ID)) 'If IO.File.Exists(exe_) = True Then ' Dim processInfo As New ProcessStartInfo(exe_) ' Process.Start(processInfo) ' Application.Exit() 'Else ' sender.Enabled = False 'End If Dim processInfo As New ProcessStartInfo(ls(sender.ID)) Process.Start(processInfo) Application.Exit() End Sub Sub Close_OnClick(sender As Object, e As EventArgs) ' This event handler does nothing ' MsgBox("sadfdsad") Application.Exit() End Sub Sub Settings_OnClick(sender As Object, e As EventArgs) ' This event handler does nothing ' MsgBox("sadfdsad") Application.Exit() End Sub End Module [/QUOTE]
Insert quotes…
Verification
Asuwa dahayen wadi kalama keeyada?
Post reply
Top
Bottom