|
다른 프로그램이 타 개발툴이 아니라....... 말그대로 다른 응용프로그램입니다. ㅠ.ㅠ
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <windows.h>
#pragma pack(push, 2)
typedef struct {
WORD Reserved1; // reserved, must be 0
WORD ResourceType; // type is 1 for icons
WORD ImageCount; // number of icons in structure (1)
BYTE Width; // icon width (32)
BYTE Height; // icon height (32)
BYTE Colors; // colors (0 means more than 8 bits per pixel)
BYTE Reserved2; // reserved, must be 0
WORD Planes; // color planes
WORD BitsPerPixel; // bit depth
DWORD ImageSize; // size of structure
WORD ResourceID; // resource ID
} GROUPICON;
#pragma pack(pop)
void InjectMainIcon(char *Where, char *What)
{
HANDLE hWhere = BeginUpdateResource(Where, FALSE);
char *buffer; // buffer to store raw icon data
long buffersize; // length of buffer
int hFile; // file handle
hFile = open(What, O_RDONLY | O_BINARY);
if (hFile == -1)
return; // if file doesn't exist, can't be opened etc.
// calculate buffer length and load file into buffer
buffersize = filelength(hFile);
buffer = (char *)malloc(buffersize);
read(hFile, buffer, buffersize);
close(hFile);
UpdateResource(
hWhere, // Handle to executable
RT_ICON, // Resource type - icon
MAKEINTRESOURCE(1), // Make the id 1
MAKELANGID(LANG_ENGLISH,
SUBLANG_DEFAULT), // Default language
(buffer+22),
// skip the first 22 bytes because this is the
// icon header&directory entry (if the file
// contains multiple images the directory entries
// will be larger than 22 bytes
buffersize-22 // length of buffer
);
// Again, we use this structure for educational purposes.
// The icon header and directory entries can be read from
// the file.
GROUPICON grData;
// This is the header
grData.Reserved1 = 0; // reserved, must be 0
grData.ResourceType = 1; // type is 1 for icons
grData.ImageCount = 1; // number of icons in structure (1)
// This is the directory entry
grData.Width = 32; // icon width (32)
grData.Height = 32; // icon height (32)
grData.Colors = 0; // colors (256)
grData.Reserved2 = 0; // reserved, must be 0
grData.Planes = 2; // color planes
grData.BitsPerPixel = 32; // bit depth
grData.ImageSize = buffersize - 22; // size of image
grData.ResourceID = 1; // resource ID is 1
UpdateResource(
hWhere,
RT_GROUP_ICON,
// RT_GROUP_ICON resources contain information
// about stored icons
"MAINICON",
// MAINICON contains information about the
// application's displayed icon
MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
&grData,
// Pointer to this structure
sizeof(GROUPICON)
);
delete buffer; // free memory
// Perform the update, don't discard changes
EndUpdateResource(hWhere, FALSE);
}
지금 이방법으로 아이콘을 바꾸는데, 256*256 아이콘은 들어가지가 않네요 작은 사이즈만 들어가고...
왜 그럴까요 ㅠ.ㅠ
앗 님이 쓰신 글 :
: 비쥬얼C++로 확장명이 .rc 인 파일을 편집하면 되던데요...
: 박진수 님이 쓰신 글 :
: : 안녕하세요 초보 빌더 유저입니다. 질문 하나 하겠습니다 ㅠ.ㅠ
: :
: : 빌더에서 컴파일된 a.exe란 파일이 있습니다.
: :
: : 이 파일의 아이콘을 바꿔야 하는데요, 빌더의 프로젝트 옵션에서 바꿔주는것이 아니라.
: :
: : 다른 프로그램에서 아이콘을 바꿔야 합니다.
: :
: : 예를 들면, Icon이라는 프로그램에서 a라는 파일을 바탕화면에 복사를 하는데,
: :
: : 복사된 파일은 아이콘 모양이 컴파일 될때의 모습이겠죠?
: :
: : 그 아이콘을 사용자가 지정한 아이콘으로 변경 시키려고 하는데요.
: :
: : a.exe에서 아이콘 로드하는 방법을 사용하면 안되고,
: :
: : 복사하고 나서 아이콘 디자인을 a.exe라는 파일 안에 넣어야 합니다.
: :
: : 이건 어떻게 해야 하나요?
|