i want compile a .rc file to .res (with rc.exe or porc.exe) and then embedded it to my compiled exe.
some body know any way to this ? i search net but find nothing.
Thanks.
Embedded Compiled Resource file to Compiled Exe
Embedded Compiled Resource file to Compiled Exe
Sorry for my bad english.
Re: Embedded Compiled Resource file to Compiled Exe
An example which loads an icon from a resource and displays it in a window:
1. Copy an icon (for example C:\Programs\PureBasic\Examples\Data\CDPlayer.Ico) to a temporary directory (for example C:\Temp)
2. Open Notepad and create a new file, for example C:\Temp\Resources.RC
3. Resources.RC should contain the following line (terminated with Return):4. Save this file
5. Copy the following code into your IDE:6. Open "Compiler" / "Compiler Options..." in the title menu of the IDE
7. Select the tab "Resources"
8. Click onto the button "..." at the bottom above the Cancel button
9. Select the file Resources.RC in the folder C:\Temp
10. Click onto the Add button (the file "C:\Temp\Resources.RC" should be displayed in the list now)
11. Click onto OK
12. Run the program and the CDPlayer icon should be loaded from your resource and be displayed in a window.
1. Copy an icon (for example C:\Programs\PureBasic\Examples\Data\CDPlayer.Ico) to a temporary directory (for example C:\Temp)
2. Open Notepad and create a new file, for example C:\Temp\Resources.RC
3. Resources.RC should contain the following line (terminated with Return):
Code: Select all
1 ICON C:\Temp\CDPlayer.Ico
5. Copy the following code into your IDE:
Code: Select all
#WindowHeight = 72
#WindowWidth = 220
If FindResource_(GetModuleHandle_(0), 1, #RT_ICON) <> 0
If OpenWindow(0, 0, 0, #WindowWidth, #WindowHeight, "Icon contained in resource", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 6, #WindowWidth - 12, #WindowHeight - 12, "", 60)
SetGadgetAttribute(0, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)
IconHandle = LoadIcon_(GetModuleHandle_(0), @"#1")
If IconHandle
AddGadgetItem(0, -1, "#1", IconHandle)
EndIf
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
EndIf
EndIf
7. Select the tab "Resources"
8. Click onto the button "..." at the bottom above the Cancel button
9. Select the file Resources.RC in the folder C:\Temp
10. Click onto the Add button (the file "C:\Temp\Resources.RC" should be displayed in the list now)
11. Click onto OK
12. Run the program and the CDPlayer icon should be loaded from your resource and be displayed in a window.
Last edited by Shardik on Fri Nov 12, 2010 10:58 am, edited 1 time in total.
Re: Embedded Compiled Resource file to Compiled Exe
Why OpenLibrary? Simple use: GetModuleHandle_(0)
Re: Embedded Compiled Resource file to Compiled Exe
You are right, Thomas. GetModuleHandle_(0) is shorter because OpenLibrary()ts-soft wrote:Why OpenLibrary? Simple use: GetModuleHandle_(0)
isn't necessary anymore. I have updated my above code example. I had used
one of my older examples. My newer ones are aready using GetModuleHandle_(0)

Thank you for your hint.

Re: Embedded Compiled Resource file to Compiled Exe
thanks ts-soft and Shardik, but i want embedded a compiled resource file to a Compiled exe, first i want create my exe then embedded my compiled resource to it.
Sorry for my bad english.
Re: Embedded Compiled Resource file to Compiled Exe
thanks it works, i can use it like this :
its work but anybody know a command line program that just do this job ?
Code: Select all
ResHacker.exe -addskip myExe.exe, myExe.exe, Myresource.res ,,,
Sorry for my bad english.