#include "Res_Ctrl.au3" #include #include #include #include MsgBox(0,AddRes(),"Success AddRes") $Gui = GUICreate("Gui Example",500,500,0,0) $ClID1 = ResCtrlCreatePicEx(10,10,200,100,"GIF","IMGES","GIF",-1,"Res.Dll",$WS_BORDER,0,0,14,800,0,"MS Sans Serif",2) $ClID2 = ResCtrlCreatePicEx(295,10,200,100,"BMP","IMGES","BMP",-1,"Res.Dll",$WS_BORDER,0,0,14,800,0,"MS Sans Serif",2) $ClID3 = ResCtrlCreatePicEx(10,120,200,100,"JPG","IMGES","JPG",-1,"Res.Dll",$WS_BORDER,0,0,14,800,0,"MS Sans Serif",2) $ClID4 = ResCtrlCreatePicEx(295,120,200,100,"ICO","IMGES","ICO",-1,"Res.Dll",$WS_BORDER,0,0,14,800,0,"MS Sans Serif",2) $ClID5 = ResCtrlCreatePicEx(10,230,480,160,"EMF","IMGES","EMF",-1,"Res.Dll",$WS_BORDER,0,0,14,800,0,"MS Sans Serif",2) $ClID6 = ResCtrlCreate_Button(214,100,-1,-1,"IMGES","BUTTON",-1,"Res.Dll",0,0,True) ;$W = -1 $H = -1 // $ReSize = True $BOOL = ResSetBackGroundBmp($Gui,"IMGES","BKGND",-1,"Res.Dll") $BOOL = ResSndPlaySound("IMGES","WAV",-1,"Res.Dll",True); LOOP = True GUICtrlCreateLabel(StringResGet("STR","ANSI",-1,False,"Res.Dll"),10,400,480,40,BitOR($WS_BORDER,$SS_CENTER,$SS_CENTERIMAGE)) GUICtrlCreateLabel(StringResGet("STR","UNICODE",-1,True,"Res.Dll"),10,450,480,40,BitOR($WS_BORDER,$SS_CENTER,$SS_CENTERIMAGE)) GUISetState() Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE Func FileToByteStruct($FileName) Local $nBytes $FileSize = FileGetSize($FileName) $FileStruct = DllStructCreate("byte[" & $FileSize & "]") if @error Then Return SetError(1,0,0) $hFile = _WinAPI_CreateFile($FileName,2,2) if @error Then Return SetError(2,0,0) _WinAPI_ReadFile($hFile,DllStructGetPtr($FileStruct),$FileSize,$nBytes) if @error Then Return SetError(3,0,0) _WinAPI_CloseHandle($hFile) Return SetError(0,0,$FileStruct) EndFunc Func AddRes() if Not FileExists(@ScriptDir & "\Res.Dll") Then FileCopy(@SystemDir & "\ole32.dll",@ScriptDir & "\Res.Dll") $DataStruct = FileToByteStruct("Gif.gif") if @error Then Exit(MsgBox(0,"MsgError1","Error ==> " & @error)) UpdateResource("Res.Dll",$DataStruct,"GIF","IMGES") if @error Then Exit(MsgBox(0,"MsgError2","Error ==> " & @error)) $DataStruct = FileToByteStruct("Bmp.bmp") if @error Then Exit(MsgBox(0,"MsgError3","Error ==> " & @error)) UpdateResource("Res.Dll",$DataStruct,"BMP","IMGES") if @error Then Exit(MsgBox(0,"MsgError4","Error ==> " & @error)) $DataStruct = FileToByteStruct("jpg.jpg") if @error Then Exit(MsgBox(0,"MsgError5","Error ==> " & @error)) UpdateResource("Res.Dll",$DataStruct,"JPG","IMGES") if @error Then Exit(MsgBox(0,"MsgError6","Error ==> " & @error)) $DataStruct = FileToByteStruct("Ico.ico") if @error Then Exit(MsgBox(0,"MsgError7","Error ==> " & @error)) UpdateResource("Res.Dll",$DataStruct,"ICO","IMGES") if @error Then Exit(MsgBox(0,"MsgError8","Error ==> " & @error)) $DataStruct = FileToByteStruct("EMF.EMF") if @error Then Exit(MsgBox(0,"MsgError9","Error ==> " & @error)) UpdateResource("Res.Dll",$DataStruct,"EMF","IMGES") if @error Then Exit(MsgBox(0,"MsgError10","Error ==> " & @error)) $DataStruct = FileToByteStruct("BKGND.bmp") if @error Then Exit(MsgBox(0,"MsgError11","Error ==> " & @error)) UpdateResource("Res.Dll",$DataStruct,"BKGND","IMGES") if @error Then Exit(MsgBox(0,"MsgError12","Error ==> " & @error)) $DataStruct = FileToByteStruct("Wav.wav") if @error Then Exit(MsgBox(0,"MsgError13","Error ==> " & @error)) UpdateResource("Res.Dll",$DataStruct,"WAV","IMGES") if @error Then Exit(MsgBox(0,"MsgError14","Error ==> " & @error)) $DataStruct = DllStructCreate("CHAR[" & StringLen("ANSI String") & "]") if @error Then Exit(MsgBox(0,"MsgError15","Error ==> " & @error)) DllStructSetData($DataStruct,1,"ANSI String") UpdateResource("Res.Dll",$DataStruct,"ANSI","STR") if @error Then Exit(MsgBox(0,"MsgError16","Error ==> " & @error)) $DataStruct = DllStructCreate("WCHAR[" & StringLen("UNICODE Wide Character String") & "]") if @error Then Exit(MsgBox(0,"MsgError17","Error ==> " & @error)) DllStructSetData($DataStruct,1,"UNICODE Wide Character String") UpdateResource("Res.Dll",$DataStruct,"UNICODE","STR") if @error Then Exit(MsgBox(0,"MsgError18","Error ==> " & @error)) $DataStruct = FileToByteStruct("Button.bmp") if @error Then Exit(MsgBox(0,"MsgError19","Error ==> " & @error)) UpdateResource("Res.Dll",$DataStruct,"BUTTON","IMGES") if @error Then Exit(MsgBox(0,"MsgError20","Error ==> " & @error)) Return True EndFunc Func UpdateResource($Dll_Exe_FileName,$DataStruct,$lpName,$lpType,$wLanguage = 0) if Not IsDllStruct($DataStruct) Then Return SetError(1,0,False) Local $lpData = DllStructGetPtr($DataStruct),$cbData = DllStructGetSize($DataStruct) $HANDLE = DllCall("kernel32.dll","ptr","BeginUpdateResourceW","wstr",$Dll_Exe_FileName,"BOOL",False) if @error Or $HANDLE[0] = 0 Then Return SetError(2,0,False) $hUpdate = $HANDLE[0] if IsString($lpType) Then $DataType1 = "wstr" $lpType = StringUpper($lpType) ELSE $DataType1 = "long" EndIf if IsString($lpName) Then $DataType2 = "wstr" $lpName = StringUpper($lpName) ELSE $DataType2 = "long" EndIf $BOOL = DllCall("kernel32.dll","BOOL","UpdateResourceW","ptr",$hUpdate,$DataType1 _ ,$lpType,$DataType2,$lpName,"WORD",$wLanguage,"ptr",$lpData,"DWORD",$cbData) if @error Or $BOOL[0] = 0 Then Return SetError(3,0,False) $BOOL = DllCall("kernel32.dll","BOOL","EndUpdateResourceW","HANDLE",$hUpdate,"BOOL",False) if @error Or $BOOL[0] = 0 Then Return SetError(4,0,False) Return SetError(0,0,True) EndFunc