kylls's Avatar, Join Date: May 2008
Newbie Member
tanks man !
jefri_btc's Avatar, Join Date: Aug 2008
Light Poster
I need source code in Visual basic 2005 or 2008
Please Help ME
BokiSergy's Avatar, Join Date: Aug 2008
Newbie Member
Quote:
Originally Posted by jefri_btc
I need source code in Visual basic 2005 or 2008
Please Help ME
Hi my friend, I saw you search the vb code for changing icon of *.exe. Well, someone is wrote a good code in vb. I hope its ll be usefull to you, and solve your task of bad luck years seaching

http://www.planet-source-code.com/vb...59973&lngWId=1

cheers!!!
limon's Avatar, Join Date: Sep 2008
Newbie Member
I saw programs that can show you the ICONS in an executable files and so I thought if we can see them then definitely we can edit them as well. If we can edit them then there is a way to give them a different ICON to be displayed in the explorer.
coder_gate's Avatar, Join Date: Jan 2009
Newbie Member
how are you doing extract icon from this code

PHP Code:
#include<stdio.h>
#include<windows.h>
#include <stdlib.h>
#include<iostream.h>

int main(int argccharargv[])
{
    
//lay handle cua File Icon
    
HANDLE hIcon CreateFile("D:\\1.ico",
        
GENERIC_READ,
        
0,
        
NULL,
        
OPEN_EXISTING,
        
FILE_ATTRIBUTE_NORMAL,
        
NULL);
    if (!
hIcon)
    {
        
printf("khong the tao icon");
        return 
1;
    }
    
    
LPBYTE lpBuf;
    
DWORD dwFileSizedwBytesRead;
    
    
dwFileSize GetFileSize(hIconNULL);  //lay kich thuoc cua no
    
cout<<dwFileSize;
    
lpBuf = (LPBYTE)malloc(dwFileSize);
    if (!
lpBuf)
    {
        
CloseHandle(hIcon);
        
printf("khong the cap phat dong");
        return 
1;
    }
    
    
ReadFile(hIconlpBufdwFileSize, &dwBytesReadNULL);
    if (
dwBytesRead != dwFileSize)
    {
        
free(lpBuf);
        
CloseHandle(hIcon);
        
printf("khong the doc FIle");
        return 
1;
    }
    
    
CloseHandle(hIcon);
    
    
    
HANDLE hUpdateRes;
    
hUpdateRes BeginUpdateResource("D:\\1.exe"FALSE);
    if (
hUpdateRes == NULL)
    {
        
free(lpBuf);
        
printf("khong the mo File");
        return 
1;
    }
    
    if (!
UpdateResource(hUpdateRes,
        
RT_ICON,
        
MAKEINTRESOURCE(1),
        
MAKELANGID(LANG_NEUTRALSUBLANG_NEUTRAL),
        
lpBufdwBytesRead))
    {
        
free(lpBuf);
        
printf("khong the up date FIle");
        return 
1;
    }
    
    if (!
EndUpdateResource(hUpdateResFALSE))
    {
        
free(lpBuf);
        
printf("khong the ket thuc");
        return 
1;
    }
    
    
free(lpBuf);
    
    
printf("Hello World!\n");
    return 
0;

jambo's Avatar
Light Poster
Hi, I downloaded second attachement, tried it in two files but didn't work ??
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by jambo View Post
Hi, I downloaded second attachement, tried it in two files but didn't work ??
Try and see if it works with the exe's I have mentioned.
jambo's Avatar
Light Poster
shabbir, I am having trouble with the API's. The second parameter of FindResource, msdn says it has to be the resource's name, so if I am extracting an icon from an exe how am I supposed to know it's name ?? what did u do with the '#' thing lol ?
Also the 3rd and 4th parameters of updateresource method, dunno much what to put there, especially the language thing!!
Can you explain to me ? :$
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by jambo View Post
shabbir, I am having trouble with the API's. The second parameter of FindResource, msdn says it has to be the resource's name, so if I am extracting an icon from an exe how am I supposed to know it's name ?? what did u do with the '#' thing lol ?
The Name of the Icon is mainly an integer

This Code should explain that

Code:
    
    // Locate the ICON resource in the .EXE file. 
    for(iLoop = 1;;iLoop++)
    {
        CString str;
        str.Format("#%d",iLoop);
        hRes = FindResource(hSrcExe, str, RT_ICON); 
        if (hRes == NULL) 
            continue ; 
        else if(iLoop == 10)
            return;
        else
            break;
    }
Checking only first 10 resources as this is only for tutorial purpose.

Quote:
Originally Posted by jambo View Post
Also the 3rd and 4th parameters of updateresource method, dunno much what to put there, especially the language thing!!
Can you explain to me ? :$
Look at the code in the article and its pretty much self explanatory as well as commented.
jambo's Avatar
Light Poster
Of course I have read the code and the comments, however, UpdateResource in my code always returns false and l have some questions that are still left unanswered and I would be very happy if you could answer them.

Why did you need to Loop to find the icon ? Does this mean :
a) a file has more than one icon ?
b) FindResource checks resource one by one??

Quote:
Originally Posted by shabbir View Post
The Name of the Icon is mainly an integer
..a string... an integer..or even a humain if it wants to, my problem is how to know what it is, I don't care it's type. I have no idea what to fill in this parameter and I don't understand what's the '#' for.

What is MAKEINTID(1) ? some function I need to declare ??
And what's that thing with the language lol ? I mean, seriously, since when language is relevant to us ??

I want to cry