@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: The EnumResourceTypes API !!!!C# Signature: [DllImport("kernel32.dll")] static extern bool EnumResourceTypes(IntPtr hModule, EnumResTypeProc lpEnumFunc, IntPtr lParam); !!!!VB.NET Signature: <DllImport("kernel32.dll", SetLastError:=True)> _ Private Shared Function EnumResourceTypes(ByVal hModule As IntPtr, ByVal lpEnumFunc As EnumResTypeProc, ByVal lParam As IntPtr) As Boolean End Function !!!!User-Defined Types: EnumResTypeProc !!!!Notes: None. !!!!Tips & Tricks: Please add some! ' *********************************************************************************** Sample: The CallBack Delegates are defined within the method itself. They can be adapted to your liking. ''' <summary> ''' Enumerates a module for predefined resource types. ''' </summary> ''' <param name="fullPath">Address of a valid Win32 module.</param> ''' <param name="resources">If NULL, all resource types will be enumerated.</param> ''' <returns></returns> ''' <remarks></remarks> Public Shared Function GetResourceTypes(fullPath As String, _ resources() As ResourceType) As Dictionary(Of ResourceType, _ List(Of String)) Dim hMod As IntPtr = LoadLibraryEx(fullPath, IntPtr.Zero, LoadLibraryFlags.LOAD_LIBRARY_AS_DATAFILE) If IntPtr.Zero.Equals(hMod) Then Return Nothing If IsNothing(resources) OrElse resources.Length = 0 Then resources = _ CType([Enum].GetValues(GetType(ResourceType)), ResourceType()) Dim LS As New Dictionary(Of ResourceType, List(Of String)) Dim typeCallBack As New EnumResNameProcDelegate( _ Function(hmodule As IntPtr, lpType As IntPtr, lpzName As IntPtr, lParam As IntPtr) Dim SLst As List(Of String) = Nothing Dim rt = CType(CInt(lpType), ResourceType) Dim ResID = MAKEINTRESOURCE(lpzName) If LS.TryGetValue(rt, SLst) Then SLst.Add(ResID) Else SLst = New List(Of String)({ResID}) LS.Add(rt, SLst) End If Return True End Function) Dim callBack As New EnumResTypeProc( _ Function(hm As IntPtr, rType As IntPtr, lp As IntPtr) Dim rt = CType(CInt(rType), ResourceType) If Array.IndexOf(resources, rt) > -1 Then EnumResourceNames(hm, rType, typeCallBack, IntPtr.Zero) End If Return True End Function) EnumResourceTypesW(hMod, callBack, IntPtr.Zero) FreeLibrary(hMod) Return LS End Function ' Jens. 12/16/2012 ' *********************************************************************************** !!!!Alternative Managed API: Do you know one? Please contribute it! Documentation: EnumResourceTypes@msdn on MSDN
Edit kernel32.enumreso...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.