Attribute VB_Name = "modMenus" Option Explicit Public Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long Public Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long Public Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long Public Declare Function GetMenuString Lib "user32" Alias "GetMenuStringA" (ByVal hMenu As Long, ByVal wIDItem As Long, ByVal lpString As String, ByVal nMaxCount As Long, ByVal wFlag As Long) As Long Public Declare Function OpenProcess Lib "KERNEL32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long Public Declare Function VirtualAllocEx Lib "KERNEL32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long Public Declare Function VirtualFreeEx Lib "KERNEL32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long Public Declare Function WriteProcessMemory Lib "KERNEL32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByVal lpBuffer As Long, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long Public Declare Function ReadProcessMemory Lib "KERNEL32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByVal lpBuffer As Long, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long Public Declare Function CloseHandle Lib "KERNEL32" (ByVal hObject As Long) As Long Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Public Const MEM_COMMIT = &H1000& Public Const MEM_RELEASE = &H8000& Public Const MEM_RESERVE = &H2000& Public Const PAGE_READWRITE = &H4 Public Const PROCESS_VM_OPERATION = &H8 Public Const PROCESS_VM_READ = &H10 Public Const PROCESS_VM_WRITE = &H20 Public Const MF_BYPOSITION = &H400& Public hProcess As Long Public Sub GetMenuList(hMenu As Long, SpcTab As Integer, colMenus As Collection) Dim MenuItemCount As Long Dim idxMenuItem As Long Dim strLen As Long Dim hMenuSub As Long Dim strText As String MenuItemCount = GetMenuItemCount(hMenu) For idxMenuItem = 0 To MenuItemCount - 1 hMenuSub = GetSubMenu(hMenu, idxMenuItem) strText = Space(256) strLen = GetMenuString(hMenu, idxMenuItem, strText, Len(strText), MF_BYPOSITION) strText = Left(strText, strLen) colMenus.Add Space(SpcTab) & strText GetMenuList hMenuSub, SpcTab + 4, colMenus Next idxMenuItem End Sub Public Function GetMenusListStr(hMenu As Long) As String Dim colMenus As New Collection Dim varItem As Variant Dim strMenus As String GetMenuList GetMenu(hMenu), 0, colMenus strMenus = "" For Each varItem In colMenus strMenus = strMenus & varItem & vbCrLf Next GetMenusListStr = strMenus End Function