Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
enumresourcetypes (kernel32)
 
.
Summary

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

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions