找回密码
 加入
搜索
查看: 2761|回复: 5

如何把图片文件加到生成的exe文件中?

[复制链接]
发表于 2008-9-20 21:38:50 | 显示全部楼层 |阅读模式
如何把图片文件加到生成的exe文件中?
发表于 2008-9-21 00:16:42 | 显示全部楼层
FileInstall 函数,请阅读帮助文件
发表于 2008-9-21 00:30:54 | 显示全部楼层
FileInstall("图片的当前路径","图片的解压路径")
 楼主| 发表于 2008-9-21 12:08:10 | 显示全部楼层
我试试.谢谢!我在官方也找了一个方法
You can embed any binary data into your AutoIt compiled EXE files in it's resources at compile time.
As opposite to FileInstall() with resources you can use your embedded data directly without any temporary files on disk.
If you wish you can save resources to disk with _ResourceSaveToFile() however.

Adding data to resources can be done simply by #AutoIt3Wrapper directive:
#AutoIt3Wrapper_Res_File_Add=Filename [,Section [,ResName]]
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, test_1.txt, rcdata, TEST_TXT_1, 0

As data can be used for example images,cursors,texts,sounds,binary files etc.
For loading/using data from resources at run time I made this tiny helper resources UDF.

Functions inside UDF:
_ResourceGet($ResName, $ResType = $RT_RCDATA, $ResLang = 0, $DLL = -1)
_ResourceGetAsString($ResName, $ResType = $RT_RCDATA, $ResLang = 0, $DLL = -1)
_ResourceGetAsBytes($ResName, $ResType = $RT_RCDATA, $ResLang = 0, $DLL = -1)
_ResourceGetAsImage($ResName, $ResType = $RT_RCDATA, $DLL = -1)
_ResourceGetAsBitmap($ResName, $ResType = $RT_RCDATA, $DLL = -1)
_ResourceSaveToFile($FileName, $ResName, $ResType = $RT_RCDATA, $ResLang = 0, $CreatePath = 0, $DLL = -1)
_ResourceSetImageToCtrl($CtrlId, $ResName, $ResType = $RT_RCDATA, $DLL = -1)
_SetBitmapToCtrl($CtrlId, $hBitmap)
_ResourcePlaySound($ResName, $Flag = 0, $DLL = -1)

Notes:
* to compile all script examples you must have installed Scite4AutoIt3 also with reshacker.exe/upx.exe in "Windows search path" or script directory -> you must compile script by F7 from full Scite
* to compile all script examples must be apropriate resource data files in script directory (from resource_data.zip)
* _ResourceGet() always returns pointer to data (for RT_BITMAP returns hBitmap), returning other types can be done by additional wrapper functions like _ResourceGetAsString() or _ResourceGetAsBytes()
* general supported resource types are listed in UDF as constants ($RT_BITMAP, $RT_RCDATA, ...)
* more informations/examples about using animated GIFs from resources is here and here thanks smashly/ProgAndy

Known problems/limitations:
* _ResourceGet() returns resource size (in bytes) in @extended macro but not for resource type RT_BITMAP
* _ResourceSetImageToCtrl() works only with static controls (picture,label) - no support of buttons
* _ResourcePlaySound() plays only WAV files (not MP3 files)
* _ResourceGetAsBytes() doesn't work for RT_BITMAP type
because _ResourceGet() returns hBitmap instead of memory pointer in this case
there could be used _ResourceGetAsImage() as workaround
* _ResourceGet() has memory leak
releasing of resources UnlockResource,FreeResource (opposite of LoadResource,LockResource) is not done
because it must be done after using of resources at the end and not inside UDF
* _GDIPlus_Startup() is called once at start of whole include --> no _GDIPlus_Shutdown() is called


About UPX compression:
When used #AutoIt3Wrapper_Res_File_Add directive AutoIt3Wrapper automatically add --compress-resources=0 switch to UPX. If you wish to add large bitmaps or other big resources which can be compressed then use this:
CODE: AutoIt#AutoIt3Wrapper_useupx=n
#AutoIt3Wrapper_Res_File_Add=image1.bmp, bitmap, TEST_BMP_1
#AutoIt3Wrapper_run_after="c:Program FilesAutoIt3Aut2Exeupx.exe" --best "%out%"

TODO list:
- add _ResourceLoadDLL(),_ResourceFreeDLL() - thanks ProgAndy

History:
CODE2008-08-14
   - change: _GDIPlus_Startup() is called once at start of whole include --> no _GDIPlus_Shutdown() is called
   - fixed support for animated GIFs in _ResourceGetAsImage() --> removed _MemGlobalFree($hData)
   - used simpler UDF syntax (from WinAPI) instead of DllCall() where possible
   - added new example for animated GIF image
  
  2008-07-08
    - just corrected some typos in this topic (no code changes)
  
  2008-06-25
   - big thanks to ProgAndy for ideas,improvements!
   - added _ResourceGetAsImage(), _ResourceGetAsBitmap()
   - added optional $DLL parameter to all functions - for loading resources from external EXE,DLL files
   - fixed previous limitation in _ResourceSaveToFile() - now supports also RT_BITMAP type
   - new examples in resource_test.au3
   
  2008-05-02
   - added new RT,SND constants
   - fixed bad order of parameters ResName x ResType in FindResourceExA (thanks SmOke_N)
   - added DeleteObject of oldBmp from STM_SETIMAGE in _SetBitmapToCtrl (thanks ProgAndy)
   - added settinng SS_BITMAP style to control before STM_SETIMAGE in _SetBitmapToCtrl (support for labels)
   
  2008-04-24
   - added support for JPG,GIF,PNG in _ResourceSetImageToCtrl() using GDI+ - thanks ProgAndy
   - reverted all examples back from #AutoIt3Wrapper_Res_File_Add= to #AutoIt3Wrapper_run_after=ResHacker.exe -add
   - updated both ZIP archives
        
  2007-10-16
   - added _ResourcePlaySound() - thanks Larry
   - corrected local declaration of $struxt - was problem when Opt("MustDeclareVars",1)
   - updated resource_test.au3 and resource.au3 in resource_au3.zip
  
  2007-09-14
   - added optional parameter $CreatePath in _ResourceSaveToFile()
   - updated resource_test.au3 and resource.au3 in resource_au3.zip
      
  2007-09-11
   - in examples used new AutoIt3Wrapper directive #AutoIt3Wrapper_Res_File_Add from latest Scite4AutoIt3
     (instead of #AutoIt3Wrapper_run_after=ResHacker.exe -add ...)
   - updated resource_test.au3 and resource_test_ie.au3 in resource_au3.zip
     
  2007-09-05
   - in #AutoIt3Wrapper_run_after=ResHacker.exe -add ... directive can be resource type in text form
     --> rcdata instead of 10, bitmap instead of 2 and so on (note: but for html must be used 23 still)
   - updated only resource_test.au3 in resource_au3.zip
     
  2007-09-04
   - added description at top of this topic
   - added _ResourceSaveToFile() - source is also example for using _ResourceGetAsBytes()
   - more error checking in UDF and error codes are now differrent to distinguish possible problem
   - default ResType = 10 ($RT_RCDATA) in all functions
   - updated both ZIP archives
   
  2007-08-29
   - added TODO list
   - removed not used local variables in _ResourceSetImageToCtrl() - zip archive not updated yet
   - revisited WWW links and TODO list and added list of functions
   
  2007-08-10
   - first version

resource_test.au3 - example script for using UDF
CODE: AutoIt#AutoIt3Wrapper_useupx=n
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, test_1.txt, rcdata, TEST_TXT_1, 0
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, image1.bmp, bitmap, TEST_BMP_1, 0
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, image2.bmp, bitmap, TEST_BMP_2, 0
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, image3.jpg, rcdata, TEST_JPG_3, 0
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, binary1.dat, rcdata, TEST_BIN_1, 0
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, C:WINDOWSMediatada.wav, sound, TEST_WAV_1, 0
#AutoIt3Wrapper_run_after=upx.exe --best --compress-resources=0 "%out%"

#include "resources.au3"

$gui = GUICreate("Data from resources example",820,400)
$pic1 = GUICtrlCreatePic("",0,0,400,300)
$pic2 = GUICtrlCreatePic("",400,0,400,150)
$pic3 = GUICtrlCreatePic("",400,150,400,150)
$pic4 = GUICtrlCreatePic("",600,320,400,100)
$label1 = GUICtrlCreateLabel("",20,320,380,100)
$label2 = GUICtrlCreateLabel("",400,320,200,100)
GUISetState(@SW_SHOW)

; get string from resource
$string = _ResourceGetAsString("TEST_TXT_1")
GUICtrlSetData($label1, $string)

; set BMP image to picture control from resource  bitmap
_ResourceSetImageToCtrl($pic1, "TEST_BMP_1", $RT_BITMAP)

; get bitmap from resource (as pointer)
$hBmp = _ResourceGet("TEST_BMP_2", $RT_BITMAP)
; and use it for whatever you like
_SetBitmapToCtrl($pic2, $hBmp)

; set JPG image to picture control from resource
_ResourceSetImageToCtrl($pic3, "TEST_JPG_3")

; set image to picture control from external DLL resource
_ResourceSetImageToCtrl($pic4, "#14355", $RT_BITMAP, @SystemDir & "shell32.dll")

; get/use picture from resources as hImage type
$size1 = _ResourceGetImageSize("TEST_BMP_1", $RT_BITMAP)
$size2 = _ResourceGetImageSize("TEST_JPG_3")
GUICtrlSetData($label2, $size1 & @CRLF & $size2)

; save binary data or another type (image) from resource to file and get its size in bytes
$size1 = _ResourceSaveToFile(@ScriptDir & "binary_data1.dat", "TEST_BIN_1")
$size2 = _ResourceSaveToFile(@ScriptDir & "binary_data2.bmp", "TEST_BMP_1", $RT_BITMAP)

; save binary data from resource to file (create not existing directory)
_ResourceSaveToFile("C:Dir1SubDir2binary_data1.dat", "TEST_BIN_1", $RT_RCDATA, 0, 1)
_ResourceSaveToFile("C:Dir1SubDir2binary_data2.bmp", "TEST_BMP_1", $RT_BITMAP, 0, 1)

; play WAV from resource (sync/async)
_ResourcePlaySound("TEST_WAV_1")
_ResourcePlaySound("TEST_WAV_1", $SND_ASYNC)

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd

Func _ResourceGetImageSize($ResName, $ResType = 10) ; $RT_RCDATA = 10
    ; get/use picture from resources as hImage type
    $hImage = _ResourceGetAsImage($ResName, $ResType)
    _GDIPlus_Startup()
    $width =  _GDIPlus_ImageGetWidth ($hImage)
    $height = _GDIPlus_ImageGetHeight($hImage)
    _GDIPlus_Shutdown()
   
    Return "Size of " & $ResName & " is: " & $width & "x" & $height
EndFunc

resource_test_ie.au3 - example script for using HTML resources with embeded IE COM object (without using UDF)
CODE: AutoIt#AutoIt3Wrapper_useupx=n
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, test_1.htm, 23, TEST_HTML_1, 0
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, test_1.gif, 23, TEST_GIF_1, 0
#AutoIt3Wrapper_run_after=upx.exe --best --compress-resources=0 "%out%"

$oIE = ObjCreate("Shell.Explorer.2")
$gui = GUICreate("HTML from resources example",500,400)
$ie_ctrl = GUICtrlCreateObj ($oIE, 0, 0 , 500, 400)
GUISetState(@SW_SHOW)

; image from resource (all HTML supported types)
$oIE.navigate("res://" & @AutoItExe & "/test_gif_1")
Sleep(3000)
; html from resource (with embeded image from resources)
$oIE.navigate("res://" & @AutoItExe & "/test_html_1")

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd


resources.au3 UDF - include UDF
CODE: AutoIt#include-once
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <Memory.au3>

_GDIPlus_Startup()

Global Const $RT_CURSOR = 1
Global Const $RT_BITMAP = 2
Global Const $RT_ICON = 3
Global Const $RT_MENU = 4
Global Const $RT_DIALOG = 5
Global Const $RT_STRING = 6
Global Const $RT_FONTDIR = 7
Global Const $RT_FONT = 8
Global Const $RT_ACCELERATOR = 9
Global Const $RT_RCDATA = 10
Global Const $RT_MESSAGETABLE = 11
Global Const $RT_GROUP_CURSOR = 12
Global Const $RT_GROUP_ICON = 14
Global Const $RT_VERSION = 16
Global Const $RT_DLGINCLUDE = 17
Global Const $RT_PLUGPLAY = 19
Global Const $RT_VXD = 20
Global Const $RT_ANICURSOR = 21
Global Const $RT_ANIICON = 22
Global Const $RT_HTML = 23
Global Const $RT_MANIFEST = 24

Global Const $SND_RESOURCE = 0x00040004
Global Const $SND_SYNC = 0x0
Global Const $SND_ASYNC = 0x1
Global Const $SND_MEMORY = 0x4
Global Const $SND_LOOP = 0x8
Global Const $SND_NOSTOP = 0x10
Global Const $SND_NOWAIT = 0x2000
Global Const $SND_PURGE = 0x40

Func _ResourceGet($ResName, $ResType = 10, $ResLang = 0, $DLL = -1) ; $RT_RCDATA = 10
    Local Const $IMAGE_BITMAP = 0
    Local $hInstance, $hBitmap, $InfoBlock, $GlobalMemoryBlock, $MemoryPointer, $ResSize
   
    If $DLL = -1 Then
      $hInstance = _WinAPI_GetModuleHandle("")
    Else
      $hInstance = _WinAPI_LoadLibrary($DLL)
    EndIf
    If $hInstance = 0 Then Return SetError(1, 0, 0)

    If $ResType = $RT_BITMAP Then
        $hBitmap = _WinAPI_LoadImage($hInstance, $ResName, $IMAGE_BITMAP, 0, 0, 0)
        If @error Then Return SetError(2, 0, 0)
        Return $hBitmap ; returns handle to Bitmap
    EndIf

    If $ResLang <> 0 Then
        $InfoBlock = DllCall("kernel32.dll", "int", "FindResourceExA", "int", $hInstance, "long", $ResType, "str", $ResName, "short", $ResLang)
    Else
        $InfoBlock = DllCall("kernel32.dll", "int", "FindResourceA", "int", $hInstance, "str", $ResName, "long", $ResType)
    EndIf
   
    If @error Then Return SetError(3, 0, 0)
    $InfoBlock = $InfoBlock[0]
    If $InfoBlock = 0 Then Return SetError(4, 0, 0)
   
    $ResSize = DllCall("kernel32.dll", "dword", "SizeofResource", "int", $hInstance, "int", $InfoBlock)
    If @error Then Return SetError(5, 0, 0)
    $ResSize = $ResSize[0]
    If $ResSize = 0 Then Return SetError(6, 0, 0)
   
    $GlobalMemoryBlock = DllCall("kernel32.dll", "int", "LoadResource", "int", $hInstance, "int", $InfoBlock)
    If @error Then Return SetError(7, 0, 0)
    $GlobalMemoryBlock = $GlobalMemoryBlock[0]
    If $GlobalMemoryBlock = 0 Then Return SetError(8, 0, 0)
   
    $MemoryPointer = DllCall("kernel32.dll", "int", "LockResource", "int", $GlobalMemoryBlock)
    If @error Then Return SetError(9, 0, 0)
    $MemoryPointer = $MemoryPointer[0]
    If $MemoryPointer = 0 Then Return SetError(10, 0, 0)
   
    If $DLL <> -1 Then _WinAPI_FreeLibrary($hInstance)
    If @error Then Return SetError(11, 0, 0)
   
    SetExtended($ResSize)
    Return $MemoryPointer
EndFunc

Func _ResourceGetAsString($ResName, $ResType = 10, $ResLang = 0, $DLL = -1) ; $RT_RCDATA = 10
    Local $ResPointer, $ResSize, $struct

    $ResPointer = _ResourceGet($ResName, $ResType, $ResLang, $DLL)
    If @error Then
        SetError(1, 0, 0)
        Return ''
    EndIf
    $ResSize = @extended
    $struct = DllStructCreate("char[" & $ResSize & "]", $ResPointer)
    Return DllStructGetData($struct, 1) ; returns string
EndFunc

; _ResourceGetAsBytes() doesn't work for RT_BITMAP type
; because _ResourceGet() returns hBitmap instead of memory pointer in this case
Func _ResourceGetAsBytes($ResName, $ResType = 10, $ResLang = 0, $DLL = -1) ; $RT_RCDATA = 10
    Local $ResPointer, $ResSize

    $ResPointer = _ResourceGet($ResName, $ResType, $ResLang, $DLL)
    If @error Then Return SetError(1, 0, 0)
    $ResSize = @extended
    Return DllStructCreate("byte[" & $ResSize & "]", $ResPointer) ; returns struct with bytes
EndFunc

; returned hImage can be used in many GDI+ functions:
; $width =  _GDIPlus_ImageGetWidth ($hImage)
; $height = _GDIPlus_ImageGetHeight($hImage)
Func _ResourceGetAsImage($ResName, $ResType = 10, $DLL = -1) ; $RT_RCDATA = 10
    Local $ResData, $nSize, $hData, $pData, $pStream, $pBitmap, $hBitmap

    $ResData = _ResourceGet($ResName, $ResType, 0, $DLL)
    If @error Then Return SetError(1, 0, 0)
    $nSize = @extended
   
    If $ResType = $RT_BITMAP Then
         ; $ResData is hBitmap type
        $hImage = _GDIPlus_BitmapCreateFromHBITMAP($ResData)
    Else
         ; $ResData is memory pointer
        ; thanks ProgAndy
        $hData = _MemGlobalAlloc($nSize,2)
        $pData = _MemGlobalLock($hData)
        _MemMoveMemory($ResData,$pData,$nSize)
        _MemGlobalUnlock($hData)
        $pStream = DllCall( "ole32.dll","int","CreateStreamOnHGlobal", "int",$hData, "long",1, "Int*",0)
        $pStream = $pStream[3]
        $hImage = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromStream", "ptr",$pStream, "int*",0)
        $hImage = $hImage[2]
        _WinAPI_DeleteObject($pStream)
        ; next line must be commented otherwise animated GIFs will not work
;~         _MemGlobalFree($hData)
    EndIf

    Return $hImage ; hImage type
EndFunc

Func _ResourceGetAsBitmap($ResName, $ResType = 10, $DLL = -1) ; $RT_RCDATA = 10
    $hImage = _ResourceGetAsImage($ResName, $ResType, $DLL)
    If @error Then Return SetError(1, 0, 0)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    Return $hBitmap ; hBitmap type
EndFunc

Func _ResourceSaveToFile($FileName, $ResName, $ResType = 10, $ResLang = 0, $CreatePath = 0, $DLL = -1) ; $RT_RCDATA = 10
    Local $ResStruct, $ResSize, $FileHandle
   
    If $CreatePath Then $CreatePath = 8 ; mode 8 = Create directory structure if it doesn't exist in FileOpen()

    If $ResType = $RT_BITMAP Then
        ; workaround: for RT_BITMAP _ResourceGetAsBytes() doesn't work so use _ResourceGetAsImage()
        $hImage = _ResourceGetAsImage($ResName, $ResType)
        If @error Then Return SetError(10, 0, 0)
        
        ; create filepath if doesn't exist
        $FileHandle = FileOpen($FileName, 2+16+$CreatePath)
        If @error Then Return SetError(11, 0, 0)
        FileClose($FileHandle)
        If @error Then Return SetError(12, 0, 0)
        
        _GDIPlus_ImageSaveToFile($hImage, $FileName)
        _GDIPlus_ImageDispose($hImage)

        $ResSize = FileGetSize($FileName)
    Else
        ; standard way
        $ResStruct = _ResourceGetAsBytes($ResName, $ResType, $ResLang, $DLL)
        If @error Then Return SetError(1, 0, 0)
        $ResSize = DllStructGetSize($ResStruct)
        
        $FileHandle = FileOpen($FileName, 2+16+$CreatePath)
        If @error Then Return SetError(2, 0, 0)
        FileWrite($FileHandle, DllStructGetData($ResStruct, 1))
        If @error Then Return SetError(3, 0, 0)
        FileClose($FileHandle)
        If @error Then Return SetError(4, 0, 0)
    EndIf

    Return $ResSize
EndFunc

Func _ResourceSetImageToCtrl($CtrlId, $ResName, $ResType = 10, $DLL = -1) ; $RT_RCDATA = 10
    Local $ResData, $nSize, $hData, $pData, $pStream, $pBitmap, $hBitmap
   
    $ResData = _ResourceGet($ResName, $ResType, 0, $DLL)
    If @error Then Return SetError(1, 0, 0)
    $nSize = @extended
   
    If $ResType = $RT_BITMAP Then
        _SetBitmapToCtrl($CtrlId, $ResData)
        If @error Then Return SetError(2, 0, 0)
    Else
        ; thanks ProgAndy
        ; for other types than BITMAP use GDI+ for converting to bitmap first
        $hData = _MemGlobalAlloc($nSize,2)
        $pData = _MemGlobalLock($hData)
        _MemMoveMemory($ResData,$pData,$nSize)
        _MemGlobalUnlock($hData)
        $pStream = DllCall( "ole32.dll","int","CreateStreamOnHGlobal", "int",$hData, "long",1, "Int*",0)
        $pStream = $pStream[3]
        $pBitmap = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromStream", "ptr",$pStream, "int*",0)
        $pBitmap = $pBitmap[2]
        $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($pBitmap)
        _SetBitmapToCtrl($CtrlId, $hBitmap)
        If @error Then SetError(3, 0, 0)
        _GDIPlus_BitmapDispose($pBitmap)
        _WinAPI_DeleteObject($pStream)
        _MemGlobalFree($hData)
    EndIf

    Return 1
EndFunc

; internal helper function
Func _SetBitmapToCtrl($CtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0xE
    Local Const $GWL_STYLE = -16

    Local $hWnd = GUICtrlGetHandle($CtrlId)
    If $hWnd = 0 Then Return SetError(1, 0, 0)
   
    ; set SS_BITMAP style to control
    Local $oldStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
    If @error Then Return SetError(2, 0, 0)
    _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitOR($oldStyle, $SS_BITMAP))
    If @error Then Return SetError(3, 0, 0)
   
    Local $oldBmp = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)
    If @error Then Return SetError(4, 0, 0)
    If $oldBmp <> 0 Then _WinAPI_DeleteObject($oldBmp)
    Return 1
EndFunc

; thanks Larry,ProgAndy
; MSDN: http://msdn2.microsoft.com/en-us/library/ms712879.aspx
; default flag is $SND_SYNC = 0
Func _ResourcePlaySound($ResName, $Flag = 0, $DLL = -1)
    If $DLL = -1 Then
      $hInstance = 0
    Else
      $hInstance = _WinAPI_LoadLibrary($DLL)
    EndIf
  
    Local $ret = DllCall("winmm.dll", "int", "PlaySound", "str", $ResName, "hwnd", $hInstance, "int", BitOr($SND_RESOURCE,$Flag))
    If @error Then Return SetError(1, 0, 0)

    If $DLL <> -1 Then _WinAPI_FreeLibrary($hInstance)
    If @error Then Return SetError(2, 0, 0)
  
    Return $ret[0]
EndFunc

resource_au3.zip - all au3 sources: UDF and examples

QUOTE
resource_test.au3
resource_test_ani_gif.au3
resource_test_ie.au3
resources.au3

resource_data.zip - sample resource data for examples:

QUOTE
binary1.dat
gif-Green-UFO.gif
image1.bmp
image2.bmp
image3.jpg
test_1.gif
test_1.htm
test_1.txt


EDIT: 2008-03-10
In AutoIt3Wrapper from latest Scite4AutoIt3 (2008-03-08) is changed behaviour in placing resources into wrong sections and also with different ResNames. It's always placed into RCData section and ResNames are assigned as numbers 1,2,3,...
This is reason why I reverted back from simpler

CODE#AutoIt3Wrapper_Res_File_Add=test_1.txt, rcdata, TEST_TXT_1; Filename,Section,ResName
        #AutoIt3Wrapper_Res_File_Add=image1.bmp, bitmap, TEST_BMP_1
        #AutoIt3Wrapper_Res_File_Add=image2.bmp, bitmap, TEST_BMP_2
        #AutoIt3Wrapper_Res_File_Add=binary1.dat, rcdata, TEST_BIN_1
        #AutoIt3Wrapper_Res_File_Add=C:WINDOWSMediatada.wav, sound, TEST_WAV_1

to
CODE#AutoIt3Wrapper_useupx=n
        #AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, test_1.txt, rcdata, TEST_TXT_1, 0
        #AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, image1.bmp, bitmap, TEST_BMP_1, 0
        #AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, image2.bmp, bitmap, TEST_BMP_2, 0
        #AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, binary1.dat, rcdata, TEST_BIN_1, 0
        #AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, C:WINDOWSMediatada.wav, sound, TEST_WAV_1, 0
          #AutoIt3Wrapper_run_after=upx.exe --compress-resources=0 "%out%"

This may be fixed in some next version of AutoIt3Wrapper/Scite4AutoIt3 ...
发表于 2008-9-27 22:33:39 | 显示全部楼层
源码实在太长,眼晕了
发表于 2008-12-4 19:49:20 | 显示全部楼层
4楼的方法有没有人成功过啊?分享一下经验好不好?

同楼上的,源码那么长,都看晕了。。。。还是没看懂。。。。。。。。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-17 01:49 , Processed in 0.081676 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表