Originally Posted by jambo View Post
hmm thx for replies Jabbir but I can't succeed in writing this in VB
I have also tried to rewrite the code in VB and made everything correct but some function fail. I guess that this FindResource is not compatible with VB, or the declarations are not correct, maybe for this RT_ICON. I have started writing this code in c++ console application and it works now for me. But this example that is in MFC does not work. I dont understand why.

This is my VB code with declarations:

//Those are examples where i know my icon name is #1, but it can be #20000 also so you shold loop from 1 to ... 65536 maybe. Just guessing.

This is C++ code:
hRes = FindResource(hSrc, MAKEINTRESOURCE(1), RT_ICON); //Works!
lpName = "#1" 
hRes = FindResource(hSrc, lpName, RT_ICON); //Works
And this is Visual Basic code that doesn work:
Private Declare Function FindResource Lib "kernel32.dll" Alias "FindResourceA" ( _
     ByVal hInstance As Long, _
     ByVal lpName As String, _
     ByVal lpType As String) As Long
Private Const RT_ICON As Long = 3&
Dim hRes as Long
hRes = FindResource(hSrc, "#1", RT_ICON)