wolf9228 Posted June 10, 2012 Posted June 10, 2012 (edited) Simple errors in the Res_PicCtrl.au3 fileNew_Resource.zipThe project combines advanced functions to use the resource applications, the projectSupports various image formats using the OleAut32 library It also allowsUsing the resources of executable files and Dll files in a manner indicated by a soft and easyRes_Example.au3expandcollapse popup#include "Res_PicCtrl.au3" #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> $Gui = GUICreate("Gui Example",500,500,0,0) MsgBox(0,AddRes(),"Success AddRes") $ClID1 = ModuleResCtrlCreatePicEx("Res.Dll","GIF","IMGES",10,10,200,100,"GIF",$WS_BORDER,0,0,14,800,0,"MS Sans Serif",2) $ClID2 = ModuleResCtrlCreatePicEx("Res.Dll","BMP","IMGES",290,10,200,100,"BMP",$WS_BORDER,0,0,14,800,0,"MS Sans Serif",2) $ClID3 = ModuleResCtrlCreatePicEx("Res.Dll","JPG","IMGES",10,120,200,100,"JPG",$WS_BORDER,0,0,14,800,0,"MS Sans Serif",2) $ClID4 = ModuleResCtrlCreatePicEx("Res.Dll","ICO","IMGES",290,120,200,100,"ICO",$WS_BORDER,0,0,14,800,0,"MS Sans Serif",2) $ClID5 = ModuleResCtrlCreatePicEx("Res.Dll","EMF","IMGES",10,230,480,160,"EMF",$WS_BORDER,0,0,14,800,0,"MS Sans Serif",2) $BOOL = ModuleResSetBackGroundBmp($Gui,"Res.Dll","BKGND","IMGES") $BOOL = ModuleResSndPlaySound("Res.Dll","WAV","IMGES",True); LOOP = True GUICtrlCreateLabel(ModuleStrResGet("Res.Dll","ANSI","STR"),10,400,480,40,BitOR($WS_BORDER,$SS_CENTER,$SS_CENTERIMAGE)) GUICtrlCreateLabel(ModuleStrResGet("Res.Dll","UNICODE","STR"),10,450,480,40,BitOR($WS_BORDER,$SS_CENTER,$SS_CENTERIMAGE)) GUISetState() Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE Func AddRes() if Not FileExists(@ScriptDir & "\Res.Dll") Then FileCopy(@SystemDir & "\ole32.dll",@ScriptDir & "\Res.Dll") $DataStruct = FileToByteStruct("Gif.gif") if @error Then Exit UpdateResource("Res.Dll",$DataStruct,"GIF","IMGES") if @error Then Exit $DataStruct = FileToByteStruct("Bmp.bmp") if @error Then Exit UpdateResource("Res.Dll",$DataStruct,"BMP","IMGES") if @error Then Exit $DataStruct = FileToByteStruct("jpg.jpg") if @error Then Exit UpdateResource("Res.Dll",$DataStruct,"JPG","IMGES") if @error Then Exit $DataStruct = FileToByteStruct("Ico.ico") if @error Then Exit UpdateResource("Res.Dll",$DataStruct,"ICO","IMGES") if @error Then Exit $DataStruct = FileToByteStruct("EMF.EMF") if @error Then Exit UpdateResource("Res.Dll",$DataStruct,"EMF","IMGES") if @error Then Exit $DataStruct = FileToByteStruct("BKGND.bmp") if @error Then Exit UpdateResource("Res.Dll",$DataStruct,"BKGND","IMGES") if @error Then Exit $DataStruct = FileToByteStruct("Wav.wav") if @error Then Exit UpdateResource("Res.Dll",$DataStruct,"WAV","IMGES") if @error Then Exit $DataStruct = DllStructCreate("CHAR[" & StringLen("ANSI String") & "]") if @error Then Exit DllStructSetData($DataStruct,1,"ANSI String") UpdateResource("Res.Dll",$DataStruct,"ANSI","STR") if @error Then Exit $DataStruct = DllStructCreate("WCHAR[" & StringLen("UNICODE Wide Character String") & "]") if @error Then Exit DllStructSetData($DataStruct,1,"UNICODE Wide Character String") UpdateResource("Res.Dll",$DataStruct,"UNICODE","STR") if @error Then Exit Return True EndFunc 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) EndFuncResource.au3expandcollapse popupGlobal Const $RT_ACCELERATOR = 9 Global Const $RT_ANICURSOR = 21 Global Const $RT_ANIICON = 22 Global Const $RT_BITMAP = 2 Global Const $RT_CURSOR = 1 Global Const $RT_DIALOG = 5 Global Const $RT_DLGINCLUDE = 17 Global Const $RT_FONT = 8 Global Const $RT_FONTDIR = 7 Global Const $RT_GROUP_CURSOR = ($RT_CURSOR + 11) Global Const $RT_ICON = 3 Global Const $RT_GROUP_ICON = ($RT_ICON + 11) Global Const $RT_HTML = 23 Global Const $RT_MANIFEST = 24 Global Const $RT_MENU = 4 Global Const $RT_MESSAGETABLE = 11 Global Const $RT_PLUGPLAY = 19 Global Const $RT_RCDATA = 10 Global Const $RT_STRING = 6 Global Const $RT_VERSION = 16 Global Const $RT_VXD = 20 Global $Global_BackGroundArray[1][5] Func ResGet($ResName,$ResType,$ResLanguage = -1,$HModule = 0) Local $DataType1 = "LONG",$DataType2 = "LONG" Local $LPVOID,$HRSRC,$ResSize,$HGLOBAL if IsString($ResName) Then $ResName = StringUpper($ResName) $DataType1 = "WSTR" EndIf If IsString($ResType) Then $ResType = StringUpper($ResType) $DataType2 = "WSTR" EndIf if ($HModule = 0) Then $HModule = GetModuleHandle(0) if ($ResLanguage <> -1) Then $HRSRC = DllCall("Kernel32.dll","ptr","FindResourceExW","ptr",$HModule,$DataType1,$ResName,$DataType2, _ $ResType,"WORD",$ResLanguage) if @error Or $HRSRC[0] = 0 Then Return SetError(1,0,0) Else $HRSRC = DllCall("Kernel32.dll","ptr","FindResourceW","ptr",$HModule,$DataType1,$ResName,$DataType2, _ $ResType) if @error Or $HRSRC[0] = 0 Then Return SetError(1,0,0) EndIf $HRSRC = $HRSRC[0] $ResSize = DllCall("Kernel32.dll","DWORD","SizeofResource","ptr",$HModule,"ptr",$HRSRC) if (@error Or $ResSize[0] = 0) Then Return SetError(2,0,0) $ResSize = $ResSize[0] $HGLOBAL = DllCall("Kernel32.dll","ptr","LoadResource","ptr",$HModule,"ptr",$HRSRC) if @error Or $HGLOBAL[0] = 0 Then Return SetError(3,0,0) $HGLOBAL = $HGLOBAL[0] $LPVOID = DllCall("Kernel32.dll","ptr","LockResource","ptr",$HGLOBAL) if @error Or $LPVOID[0] = 0 Then $BOOL = DllCall("Kernel32.dll","BOOL","FreeResource","ptr",$HGLOBAL) Return SetError(4,0,0) EndIf $LPVOID = $LPVOID[0] $BOOL = DllCall("Kernel32.dll","BOOL","FreeResource","ptr",$HGLOBAL) Return SetError(0,$ResSize,$LPVOID) EndFunc Func ModuleResGet($Dll_Exe_FileName,$ResName,$ResType,$ResLanguage = -1) $HModule = LoadLibrary($Dll_Exe_FileName) if @error Then Return SetError(1,0,0) $Rt = ResGet($ResName,$ResType,$ResLanguage,$HModule) if @error Then FreeLibrary($HModule) Return SetError(2,0,0) EndIf FreeLibrary($HModule) Return SetError(0,0,$Rt) EndFunc Func StrResGet($ResName,$ResType,$ResLanguage = -1,$HModule = 0) Local $DtatType = "CHAR" $LPVOID = ResGet($ResName,$ResType,$ResLanguage,$HModule) if @error Then Return SetError(1,0,0) $ResSize = @extended if (IsTextUnicode($LPVOID,$ResSize)) Then $DtatType = "WCHAR" $ResSize = Int($ResSize/2) EndIf $StrStruct = DllStructCreate($DtatType & "[" & $ResSize & "]",$LPVOID) if @error Then Return SetError(2,0,0) $Str = DllStructGetData($StrStruct,1) Return SetError(0,StringLen($Str),$Str) EndFunc Func ModuleStrResGet($Dll_Exe_FileName,$ResName,$ResType,$ResLanguage = -1) $HModule = LoadLibrary($Dll_Exe_FileName) if @error Then Return SetError(1,0,"") $Str = StrResGet($ResName,$ResType,$ResLanguage,$HModule) if @error Then FreeLibrary($HModule) Return SetError(2,0,"") EndIf FreeLibrary($HModule) Return SetError(0,@extended,$Str) EndFunc Func StrStructResGet($ResName,$ResType,$ResLanguage = -1,$HModule = 0) Local $DtatType = "CHAR" $LPVOID = ResGet($ResName,$ResType,$ResLanguage,$HModule) if @error Then Return SetError(1,0,0) $ResSize = @extended if (IsTextUnicode($LPVOID,$ResSize)) Then $DtatType = "WCHAR" $ResSize = Int($ResSize/2) EndIf $StrStruct = DllStructCreate($DtatType & "[" & $ResSize & "]",$LPVOID) if @error Then Return SetError(2,0,0) Return SetError(0,DllStructGetSize($StrStruct),$StrStruct) EndFunc Func ModuleStrStructResGet($Dll_Exe_FileName,$ResName,$ResType,$ResLanguage = -1) $HModule = LoadLibrary($Dll_Exe_FileName) if @error Then Return SetError(1,0,0) $StrStruct = StrStructResGet($ResName,$ResType,$ResLanguage,$HModule) if @error Then FreeLibrary($HModule) Return SetError(2,0,0) EndIf FreeLibrary($HModule) Return SetError(0,@extended,$StrStruct) EndFunc Func BinaryResGet($ResName,$ResType,$ResLanguage = -1,$HModule = 0) $LPVOID = ResGet($ResName,$ResType,$ResLanguage,$HModule) if @error Then Return SetError(1,0,0) $ResSize = @extended $BinaryStruct = DllStructCreate("BYTE[" & $ResSize & "]",$LPVOID) if @error Then Return SetError(2,0,0) $Binary = DllStructGetData($BinaryStruct,1) Return SetError(0,BinaryLen($Binary),$Binary) EndFunc Func ModuleBinaryResGet($Dll_Exe_FileName,$ResName,$ResType,$ResLanguage = -1) $HModule = LoadLibrary($Dll_Exe_FileName) if @error Then Return SetError(1,0,0) $BinaryData = BinaryResGet($ResName,$ResType,$ResLanguage,$HModule) if @error Then FreeLibrary($HModule) Return SetError(2,0,0) EndIf FreeLibrary($HModule) Return SetError(0,@extended,$BinaryData) EndFunc Func BinaryStructResGet($ResName,$ResType,$ResLanguage = -1,$HModule = 0) $LPVOID = ResGet($ResName,$ResType,$ResLanguage,$HModule) if @error Then Return SetError(1,0,0) $ResSize = @extended $BinaryStruct = DllStructCreate("BYTE[" & $ResSize & "]",$LPVOID) if @error Then Return SetError(2,0,0) Return SetError(0,DllStructGetSize($BinaryStruct),$BinaryStruct) EndFunc Func ModuleBinaryStructResGet($Dll_Exe_FileName,$ResName,$ResType,$ResLanguage = -1) $HModule = LoadLibrary($Dll_Exe_FileName) if @error Then Return SetError(1,0,0) $BinaryStruct = BinaryStructResGet($ResName,$ResType,$ResLanguage,$HModule) if @error Then FreeLibrary($HModule) Return SetError(2,0,0) EndIf FreeLibrary($HModule) Return SetError(0,@extended,$BinaryStruct) EndFunc Func ResToFile($FileName,$ResName,$ResType,$ResLanguage = -1,$HModule = 0,$Mode = 10) $BinaryData = BinaryResGet($ResName,$ResType,$ResLanguage,$HModule) if @error Then Return SetError(1,0,False) $OpeFile = FileOpen($FileName,$Mode) if @error Then Return SetError(2,0,False) FileWrite($OpeFile,Binary($BinaryData)) if @error Then Return SetError(3,0,False) FileClose($OpeFile) Return SetError(0,0,True) EndFunc Func ModuleResToFile($FileName,$Dll_Exe_FileName,$ResName,$ResType,$ResLanguage = -1,$Mode = 10) $HModule = LoadLibrary($Dll_Exe_FileName) if @error Then Return SetError(1,0,False) ResToFile($FileName,$ResName,$ResType,$ResLanguage,$HModule,$Mode) if @error Then FreeLibrary($HModule) Return SetError(2,0,False) EndIf FreeLibrary($HModule) Return SetError(0,0,True) EndFunc Func GetModuleHandle($lpModuleName = 0) Local $DataType = "WSTR" if IsInt($lpModuleName) Then $DataType = "PTR" $HMODULE = DllCall("Kernel32.dll","PTR","GetModuleHandleW",$DataType,$lpModuleName) if @error Or $HMODULE[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HMODULE[0]) EndFunc Func LoadLibrary($lpFileName) $HMODULE = DllCall("Kernel32.dll","PTR","LoadLibraryW","WSTR",$lpFileName) if @error Or $HMODULE[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HMODULE[0]) EndFunc Func FreeLibrary($hModule) $BOOL = DllCall("Kernel32.dll","BOOL","FreeLibrary","PTR",$hModule) if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$BOOL[0]) EndFunc Func IsTextUnicode($lpv,$iSize) $lpiResult = DllStructCreate("int") $BOOL = DllCall("Advapi32.dll","BOOL","IsTextUnicode","ptr",$lpv,"int",$iSize,"struct",$lpiResult) if @error Then Return SetError(1,0,0) Return SetError(0,DllStructGetData($lpiResult,1),$BOOL[0]) 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) EndFuncImages.au3expandcollapse popup#include "Resource.au3" Func ResGetImage($ResName,$ResType,$HModule = 0,$ReturnArray = False) if Not ($HModule) Then $HModule = GetModuleHandle(0) Switch $ResType Case $RT_BITMAP $Rt = LoadBitmap($HModule,$ResName) if @error Then Return SetError(1,0,0) Return SetError(0,1,$Rt) Case $RT_ICON $Rt = LoadIcon($HModule,$ResName) if @error Then Return SetError(1,0,0) Return SetError(0,3,$Rt) Case $RT_CURSOR $Rt = LoadCursor($HModule,$ResName) if @error Then Return SetError(1,0,0) Return SetError(0,5,$Rt) Case Else $LPVOID = ResGet($ResName,$ResType,-1,$HModule) $ResSize = @extended if @error Then Return SetError(1,0,0) $hMem = GlobalAlloc(0x0042,$ResSize) ;$GHND = 0x0042 if @error Then Return SetError(2,0,0) $hLock = GlobalLock($hMem) if @error Then GlobalFree($hMem) Return SetError(3,0,0) EndIf MoveMemory($LPVOID,$hLock,$ResSize) GlobalUnlock($hMem) if @error Then GlobalFree($hMem) Return SetError(4,0,0) EndIf $RtArray = ImageFromHGlobal($hMem) if @error Then GlobalFree($hMem) Return SetError(5,0,0) EndIf GlobalFree($hMem) if ($ReturnArray) Then Return SetError(0,0,$RtArray) $ImageHandle = $RtArray[0] $ImageType = $RtArray[1] Return SetError(0,$ImageType,$ImageHandle) EndSwitch EndFunc Func ModuleResGetImage($Dll_Exe_FileName,$ResName,$ResType) $HModule = LoadLibrary($Dll_Exe_FileName) if @error Then Return SetError(1,0,0) $Rt = ResGetImage($ResName,$ResType,$HModule) if @error Then FreeLibrary($HModule) Return SetError(2,0,0) EndIf $ImageType = @extended FreeLibrary($HModule) Return SetError(0,$ImageType,$Rt) EndFunc Func ImageFromByteStruct($ByteStruct) if Not IsDllStruct($ByteStruct) Then Return SetError(1,0,0) $StructSize = DllStructGetSize($ByteStruct) $LPVOID = DllStructGetPtr($ByteStruct) $hMem = GlobalAlloc(0x0042,$StructSize) ;$GHND = 0x0042 if @error Then Return SetError(2,0,0) $hLock = GlobalLock($hMem) if @error Then GlobalFree($hMem) Return SetError(3,0,0) EndIf MoveMemory($LPVOID,$hLock,$StructSize) GlobalUnlock($hMem) if @error Then GlobalFree($hMem) Return SetError(4,0,0) EndIf $RtArray = ImageFromHGlobal($hMem) if @error Then GlobalFree($hMem) Return SetError(5,0,0) EndIf GlobalFree($hMem) $ImageHandle = $RtArray[0] $ImageType = $RtArray[1] Return SetError(0,$ImageType,$ImageHandle) EndFunc Func ImageFromBinaryData($BinaryData) $ByteStruct = DllStructCreate("BYTE[" & BinaryLen($BinaryData) & "]") if @error Then Return SetError(1,0,0) DllStructSetData($ByteStruct,1,$BinaryData) $StructSize = DllStructGetSize($ByteStruct) $LPVOID = DllStructGetPtr($ByteStruct) $hMem = GlobalAlloc(0x0042,$StructSize) ;$GHND = 0x0042 if @error Then Return SetError(2,0,0) $hLock = GlobalLock($hMem) if @error Then GlobalFree($hMem) Return SetError(3,0,0) EndIf MoveMemory($LPVOID,$hLock,$StructSize) GlobalUnlock($hMem) if @error Then GlobalFree($hMem) Return SetError(4,0,0) EndIf $RtArray = ImageFromHGlobal($hMem) if @error Then GlobalFree($hMem) Return SetError(5,0,0) EndIf GlobalFree($hMem) $ImageHandle = $RtArray[0] $ImageType = $RtArray[1] Return SetError(0,$ImageType,$ImageHandle) EndFunc Func ImageFromHGlobal($hMem) Local $RtArray[4] $MemSize = GlobalSize($hMem) if @error Then Return SetError(1,0,0) $hLock = GlobalLock($hMem) if @error Then Return SetError(2,0,0) $lpstream = CreateStreamOnHGlobal($hLock,True) if @error Then Return SetError(3,0,0) $riid = IIDFromString("{7BF80981-BF32-101A-8BBB-00AA00300CAB}") if @error Then Return SetError(4,0,0) $HRESULT = DllCall("OleAut32.dll","LONG","OleLoadPicture","PTR",$lpstream,"LONG", _ $MemSize,"BOOL",True,"ptr",DllStructGetPtr($riid),"idispatch*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(5,0,0) $iPicture = $HRESULT[5] $RtArray[0] = Ptr($iPicture.Handle()) ;The Windows GDI handle of the picture ;--------------------------------------------------------------------------------------------------- $RtArray[1] = Int($iPicture.Type()) ;The type of picture (see PICTYPE). ;PICTYPE_UNINITIALIZED (-1) ;The picture object is currently uninitialized. This value is only valid as a return value ;from IPicture::get_Type and is not valid with the PICTDESC structure. ;PICTYPE_NONE = 0 ;A new picture object is to be created without an initialized state. This ;value is valid only in the PICTDESC structure. ;PICTYPE_BITMAP = 1 ;The picture type is a bitmap. When this value occurs in the PICTDESC structure, ;it means that the bmp field of that structure contains the relevant initialization parameters. ;PICTYPE_METAFILE = 2 ;The picture type is a metafile. When this value occurs in the PICTDESC structure, ;it means that the wmf field of that structure contains the relevant initialization parameters. ;PICTYPE_ICON = 3 ;The picture type is an icon. When this value occurs in the PICTDESC structure, ;it means that the icon field of that structure contains the relevant initialization parameters. ;PICTYPE_ENHMETAFILE = 4 ;The picture type is an enhanced metafile. When this value occurs in the PICTDESC structure, ;it means that the emf field of that structure contains the relevant initialization parameters. ;--------------------------------------------------------------------------------------------------- $RtArray[2] = $iPicture.Width();The width of the picture. $RtArray[3] = $iPicture.Height();The height of the picture. $RtArray[2] = MulDiv($RtArray[2],GetDeviceCaps(GetDC(0),88),2540); 88 => LOGPIXELSX $RtArray[3] = MulDiv($RtArray[3],GetDeviceCaps(GetDC(0),90),2540); 90 => LOGPIXELSY Return SetError(0,0,$RtArray) EndFunc Func LoadBitmap($hInstance,$lpBitmapName) Local $DataType = "LONG" if IsString($lpBitmapName) Then $lpBitmapName = StringUpper($lpBitmapName) $DataType = "WSTR" EndIf $HBITMAP = DllCall("User32.dll","PTR","LoadBitmapW","PTR",$hInstance,$DataType,$lpBitmapName) if @error Or $HBITMAP[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HBITMAP[0]) EndFunc Func LoadIcon($hInstance,$lpIconName) Local $DataType = "LONG" if IsString($lpIconName) Then $lpIconName = StringUpper($lpIconName) $DataType = "WSTR" EndIf $HICON = DllCall("User32.dll","PTR","LoadIconW","PTR",$hInstance,$DataType,$lpIconName) if @error Or $HICON[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HICON[0]) EndFunc Func LoadCursor($hInstance,$lpCursorName) Local $DataType = "LONG" if IsString($lpCursorName) Then $lpCursorName = StringUpper($lpCursorName) $DataType = "WSTR" EndIf $HCURSOR= DllCall("User32.dll","PTR","LoadCursorW","PTR",$hInstance,$DataType,$lpCursorName) if @error Or $HCURSOR[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HCURSOR[0]) EndFunc Func GlobalAlloc($uFlags,$dwBytes) $HGLOBAL = DllCall("Kernel32.dll","ptr","GlobalAlloc","UINT",$uFlags,"ULONG_PTR",$dwBytes) if @error Or $HGLOBAL[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HGLOBAL[0]) EndFunc Func GlobalLock($hMem) $LPVOID = DllCall("Kernel32.dll","ptr","GlobalLock","ptr",$hMem) if @error Or $LPVOID[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$LPVOID[0]) EndFunc Func GlobalUnlock($hMem) $BOOL = DllCall("Kernel32.dll","BOOL","GlobalUnlock","ptr",$hMem) if @error Or $BOOL[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$BOOL[0]) EndFunc Func GlobalSize($hMem) $Size = DllCall("Kernel32.dll","ULONG_PTR","GlobalSize","ptr",$hMem) if (@error Or GetLastError()) Then Return SetError(1,0,0) Return SetError(0,0,$Size[0]) EndFunc Func GlobalFree($hMem) $HGLOBAL = DllCall("Kernel32.dll","ULONG_PTR","GlobalFree","ptr",$hMem) if (@error Or ($HGLOBAL[0])) Then Return SetError(1,0,$HGLOBAL[0]) Return SetError(0,0,0) EndFunc Func IIDFromString($psz) $GUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]") $Oleerror = DllCall("Ole32.dll","int","IIDFromString","WSTR",$psz,"struct*",$GUID) if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$Oleerror[2]) EndFunc Func MoveMemory($Source,$Destination,$Length) DllCall("Kernel32.dll","none","RtlMoveMemory","PTR",$Destination,"PTR",$Source,"INT",$Length) EndFunc Func CreateStreamOnHGlobal($hGlobal,$fDeleteOnRelease) $WINOLE = DllCall("Ole32.dll","PTR","CreateStreamOnHGlobal","ptr",$hGlobal,"BOOL",$fDeleteOnRelease _ ,"PTR*",0) if @error Or $WINOLE[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$WINOLE[3]) EndFunc Func MulDiv($nNumber,$nNumerator,$nDenominator) $Rt = DllCall("Kernel32.dll","int","MulDiv","int",$nNumber,"int",$nNumerator,"int",$nDenominator) Return $Rt[0] EndFunc Func GetDeviceCaps($hdc,$nIndex) $Rt = DllCall("Gdi32.dll","int","GetDeviceCaps","ptr",$hdc,"int",$nIndex) Return $Rt[0] EndFunc Func GetDC($hWnd) $HDC = DllCall("User32.dll","ptr","GetDC","ptr",$hWnd) if @error Or $HDC[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HDC[0]) EndFunc Func GetLastError() $iErr = DllCall("Kernel32.dll","DWORD","GetLastError") if @error Then Return SetError(1,0,0) Return SetError(0,0,$iErr[0]) EndFuncRes_PicCtrl.au3expandcollapse popup#include "Images.au3" Func CtrlCreatePic($ImageHandle,$ImageType,$L,$T,$W,$H,$Style = 0,$ExStyle = 0) Local $SS_ICON_RES = 0x00000003,$SS_ENHMETAFILE_RES = 0x0000000F,$ImageStyle = 0 Local $SS_BITMAP_RES = 0x0000000E,$SS_REALSIZECONTROL_RES = 0x00000040 Switch $ImageType Case 1 ;BITMAP $ImageStyle = BitOR($Style,$SS_BITMAP_RES,$SS_REALSIZECONTROL_RES) Case 4 ;ENHMETAFILE $ImageStyle = BitOR($Style,$SS_ENHMETAFILE_RES,$SS_REALSIZECONTROL_RES) Case 3,5 ;INCON OR CURSOR $ImageStyle = BitOR($Style,$SS_ICON_RES,$SS_REALSIZECONTROL_RES) Case Else Return SetError(1,0,False) EndSwitch $ControlID = GUICtrlCreateLabel("",$L,$T,$W,$H,$ImageStyle,$ExStyle) CtrlSetPicImage($ControlID,$ImageHandle,$ImageType,True) if @error Then Return SetError(2,0,0) Return SetError(0,$ImageType,$ControlID) EndFunc Func ResCtrlCreatePic($ResName,$ResType,$L,$T,$W,$H,$Style = 0,$ExStyle = 0) $ImageHandle = ResGetImage($ResName,$ResType) if @error Then Return SetError(1,0,0) $ImageType = @extended $ControlID = CtrlCreatePic($ImageHandle,$ImageType,$L,$T,$W,$H,$Style,$ExStyle) if @error Then Return SetError(2,0,0) Return SetError(0,@extended,$ControlID) EndFunc Func ModuleResCtrlCreatePic($Dll_Exe_FileName,$ResName,$ResType,$L,$T,$W,$H,$Style = 0,$ExStyle = 0) $HModule = LoadLibrary($Dll_Exe_FileName) if @error Then Return SetError(1,0,0) $ImageHandle = ResGetImage($ResName,$ResType,$HModule) if @error Then FreeLibrary($HModule) Return SetError(2,0,0) EndIf $ImageType = @extended $ControlID = CtrlCreatePic($ImageHandle,$ImageType,$L,$T,$W,$H,$Style,$ExStyle) if @error Then FreeLibrary($HModule) Return SetError(3,0,0) EndIf FreeLibrary($HModule) Return SetError(0,@extended,$ControlID) EndFunc Func CtrlCreatePicEx($ImageHandle,$ImageType,$L,$T,$W,$H,$Text,$Style = 0,$ExStyle = 0, _ $FontColor=0,$FontSize=8.5,$FomtWeight=400,$FontAttribute=0,$Fontname="",$FontQuality=2) Local $SS_BITMAP_RES = 0x0000000E,$SS_REALSIZECONTROL_RES = 0x00000040 Local $SS_ICON_RES = 0x00000003,$SS_CENTER_RES = 0x01,$SS_CENTERIMAGE_RES = 0x0200 Local $SS_ENHMETAFILE_RES = 0x0000000F,$ImageStyle = 0 Switch $ImageType Case 1 ;BITMAP $ImageStyle = BitOR($Style,$SS_BITMAP_RES,$SS_REALSIZECONTROL_RES) Case 4 ;ENHMETAFILE $ImageStyle = BitOR($Style,$SS_ENHMETAFILE_RES,$SS_REALSIZECONTROL_RES) Case 3,5 ;INCON OR CURSOR $ImageStyle = BitOR($Style,$SS_ICON_RES,$SS_REALSIZECONTROL_RES) Case Else Return SetError(1,0,False) EndSwitch $ControlID1 = GUICtrlCreateLabel("",$L,$T,$W,$H,$ImageStyle,$ExStyle) CtrlSetPicImage($ControlID1,$ImageHandle,$ImageType,True) if @error Then Return SetError(2,0,0) $ControlID2 = GUICtrlCreateLabel($Text,$L,$T,$W,$H,BitOR($SS_CENTER_RES,$SS_CENTERIMAGE_RES)) GUICtrlSetColor(-1,$FontColor) GUICtrlSetBkColor(-1,-2);-2 $GUI_BKCOLOR_TRANSPARENT GUICtrlSetFont(-1,$FontSize,$FomtWeight,$FontAttribute,$Fontname,$FontQuality) Return SetError(0,$ImageType,$ControlID1) EndFunc Func ResCtrlCreatePicEx($ResName,$ResType,$L,$T,$W,$H,$Text,$Style = 0,$ExStyle = 0, _ $FontColor=0,$FontSize=8.5,$FomtWeight=400,$FontAttribute=2,$Fontname="",$FontQuality=2) $ImageHandle = ResGetImage($ResName,$ResType) if @error Then Return SetError(1,0,0) $ImageType = @extended $ControlID = CtrlCreatePicEx($ImageHandle,$ImageType,$L,$T,$W,$H,$Text,$Style, _ $ExStyle,$FontColor,$FontSize,$FomtWeight,$FontAttribute,$Fontname,$FontQuality) if @error Then Return SetError(2,0,0) Return SetError(0,$ImageType,$ControlID) EndFunc Func ModuleResCtrlCreatePicEx($Dll_Exe_FileName,$ResName,$ResType,$L,$T,$W,$H,$Text, _ $Style = 0,$ExStyle = 0,$FontColor=0,$FontSize=8.5,$FomtWeight=400,$FontAttribute=2, _ $Fontname="",$FontQuality=2) $HModule = LoadLibrary($Dll_Exe_FileName) if @error Then Return SetError(1,0,0) $ImageHandle = ResGetImage($ResName,$ResType,$HModule) if @error Then FreeLibrary($HModule) Return SetError(2,0,0) EndIf $ImageType = @extended $ControlID = CtrlCreatePicEx($ImageHandle,$ImageType,$L,$T,$W,$H,$Text,$Style, _ $ExStyle,$FontColor,$FontSize,$FomtWeight,$FontAttribute,$Fontname,$FontQuality) if @error Then FreeLibrary($HModule) Return SetError(3,0,0) EndIf FreeLibrary($HModule) Return SetError(0,$ImageType,$ControlID) EndFunc Func DeletePicEx($ControlID) GUICtrlDelete($ControlID) GUICtrlDelete($ControlID + 1) EndFunc Func SetPosPicEx($ControlID,$L,$T,$W,$H) GUICtrlSetPos($ControlID,$L,$T,$W,$H) GUICtrlSetPos($ControlID + 1,$L,$T,$W,$H) EndFunc Func SetStatePicEx($ControlID,$State) GUICtrlSetState($ControlID,$State) GUICtrlSetState($ControlID + 1,$State) EndFunc Func SetStylePicEx($ControlID,$Style,$ExStyle) GUICtrlSetStyle($ControlID,$Style,$ExStyle) EndFunc Func CtrlSetPicImage($ControlID,$ImageHandle,$ImageType,$DeletImage = False) ;$ImageType ;$ImageType = 1 ==> BITMAP ;$ImageType = 3 ==> ICON ;$ImageType = 4 ==> ENHMETAFILE ;$ImageType = 5 ==> CURSOR ;$ControlID Of STATIC Control Or Label Control Local $ControHandle = $ControlID,$STM_SETIMAGE_RES = 0x0172,$IMAGE_ENHMETAFILE_RES = 3 Local $IMAGE_BITMAP_RES = 0,$IMAGE_ICON_RES = 1,$IMAGE_CURSOR_RES = 2 if Not IsHWnd($ControlID) Then $ControHandle = GUICtrlGetHandle($ControlID) Local $Class = GetClassName($ControHandle) if @error Or Not(StringUpper($Class) == "STATIC") Then Return SetError(1,0,False) Switch $ImageType Case 1 ;BITMAP SendMessage($ControHandle,$STM_SETIMAGE_RES,$IMAGE_BITMAP_RES,$ImageHandle) if @error Then Return SetError(2,0,False) Case 4 ;ENHMETAFILE SendMessage($ControHandle,$STM_SETIMAGE_RES,$IMAGE_ENHMETAFILE_RES,$ImageHandle) if @error Then Return SetError(2,0,False) Case 3 ;ICON SendMessage($ControHandle,$STM_SETIMAGE_RES,$IMAGE_ICON_RES,$ImageHandle) if @error Then Return SetError(2,0,False) Case 5 ;CURSOR SendMessage($ControHandle,$STM_SETIMAGE_RES,$IMAGE_CURSOR_RES,$ImageHandle) if @error Then Return SetError(2,0,False) Case Else Return SetError(3,0,False) EndSwitch if ($DeletImage) Then DeleteObject($ImageHandle) Return SetError(0,0,True) EndFunc Func SetBackGroundBmp($hWnd,$hBmpImage,$BmpWidth,$BmpHeight,$DeletCurrentImage = True) Local $Test = False , $UBound = UBound($Global_BackGroundArray) For $i = 0 To $UBound - 1 if ($Global_BackGroundArray[$i][0] = $hWnd) Then $Test = True ExitLoop EndIf Next if ($Test = False) Then ReDim $Global_BackGroundArray[$UBound + 1][4] if ($DeletCurrentImage) And ($Global_BackGroundArray[$i][1]) _ Then DeleteObject($Global_BackGroundArray[$i][1]) $Global_BackGroundArray[$i][0] = $hWnd $Global_BackGroundArray[$i][1] = $hBmpImage $Global_BackGroundArray[$i][2] = $BmpWidth $Global_BackGroundArray[$i][3] = $BmpHeight GUIRegisterMsg(0x0014,"WM_ERASEBKGND") ; 0x0014 ==> WM_ERASEBKGND Msg RedrawWindow($hWnd,0,0,5) EndFunc Func ResSetBackGroundBmp($hWnd,$ResName,$ResType,$DeletCurrentImage = True) Local $Test = False , $UBound = UBound($Global_BackGroundArray) $RtArray = ResGetImage($ResName,$ResType,0,True) if @error Or $RtArray[1] <> 1 Then Return SetError(1,0,False) $hBmpImage = $RtArray[0] $BmpWidth = $RtArray[2] $BmpHeight = $RtArray[3] SetBackGroundBmp($hWnd,$hBmpImage,$BmpWidth,$BmpHeight,$DeletCurrentImage) if @error Then Return SetError(2,0,False) Return SetError(0,0,True) EndFunc Func ModuleResSetBackGroundBmp($hWnd,$Dll_Exe_FileName,$ResName,$ResType,$DeletCurrentImage = True) Local $Test = False , $UBound = UBound($Global_BackGroundArray) $HModule = LoadLibrary($Dll_Exe_FileName) if @error Then Return SetError(1,0,0) $RtArray = ResGetImage($ResName,$ResType,$HModule,True) if @error Or $RtArray[1] <> 1 Then Return SetError(2,0,False) $hBmpImage = $RtArray[0] $BmpWidth = $RtArray[2] $BmpHeight = $RtArray[3] SetBackGroundBmp($hWnd,$hBmpImage,$BmpWidth,$BmpHeight,$DeletCurrentImage) if @error Then FreeLibrary($HModule) Return SetError(3,0,False) EndIf FreeLibrary($HModule) Return SetError(0,0,True) EndFunc Func WM_ERASEBKGND($hWnd, $Msg, $wParam, $lParam) Local $Test = False , $UBound = UBound($Global_BackGroundArray) Local $BGhWnd = WindowFromDC($wParam) if Not @error Then For $i = 0 To $UBound - 1 if ($Global_BackGroundArray[$i][0] = $BGhWnd) Then $Test = True ExitLoop EndIf Next if ($Test) Then $Pos = WinGetClientSize($BGhWnd) $hdc = CreateCompatibleDC($wParam) $HGDIOBJ = SelectObject($hdc,$Global_BackGroundArray[$i][1]) StretchBlt($wParam,0,0,$Pos[0],$Pos[1],$hdc,0,0,$Global_BackGroundArray[$i][2], _ $Global_BackGroundArray[$i][3],0x00CC0020) ;0x00CC0020 ==> SRCCOPY $HGDIOBJ = SelectObject($hdc,$HGDIOBJ) Return True EndIf EndIf EndFunc Func SndPlaySound($Ptr,$LOOP = False) ;File Type Or Format File.wav Local $SND_MEMORY = 4, $SND_ASYNC = 1 ,$SND_SYNC = 0,$SND_NODEFAULT = 2 , _ $SND_LOOP = 0x0008 , $SND_NOSTOP = 0x0010 ,$SND_FILENAME = 0x00020000 Local $fuSound = BitOR($SND_MEMORY,$SND_ASYNC,$SND_NODEFAULT) if ($LOOP) Then $fuSound = BitOR($fuSound,$SND_LOOP) $BOOL = DllCall("winmm.dll", "int", "sndPlaySound","ptr",$Ptr,"UINT",$fuSound) If @error Or $BOOL[0] = 0 Then Return SetError(1,0,False) Return SetError(0,0,True) EndFunc Func ResSndPlaySound($ResName,$ResType,$LOOP = False) $LPVOID = ResGet($ResName,$ResType) if @error Then Return SetError(1,0,False) SndPlaySound($LPVOID,$LOOP) if @error Then Return SetError(2,0,False) Return SetError(0,0,True) EndFunc Func ModuleResSndPlaySound($Dll_Exe_FileName,$ResName,$ResType,$LOOP = False) $HModule = LoadLibrary($Dll_Exe_FileName) if @error Then Return SetError(1,0,0) $LPVOID = ResGet($ResName,$ResType,-1,$HModule) if @error Then FreeLibrary($HModule) Return SetError(2,0,False) EndIf SndPlaySound($LPVOID,$LOOP) if @error Then FreeLibrary($HModule) Return SetError(3,0,False) EndIf FreeLibrary($HModule) Return SetError(0,0,True) EndFunc Func SendMessage($hWnd,$Msg,$wParam,$lParam) $Rt = DllCall("User32.dll","LRESULT","SendMessageW","HWND",$hWnd,"UINT",$Msg,"WPARAM", _ $wParam,"LPARAM",$lParam) if @error Then Return SetError(1,0,0) Return SetError(0,0,$Rt[0]) EndFunc Func GetClassName($hWnd) $Rt = DllCall("User32.dll","int","GetClassNameW","HWND",$hWnd,"wstr","","int",5000) if @error Or $Rt[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$Rt[2]) EndFunc Func StretchBlt($hdcDest,$nXOriginDest,$nYOriginDest,$nWidthDest,$nHeightDest,$hdcSrc,$nXOriginSrc, _ $nYOriginSrc,$nWidthSrc,$nHeightSrc,$dwRop) $Rt = DllCall("Gdi32.dll" ,"BOOL","StretchBlt","ptr",$hdcDest,"int",$nXOriginDest,"int",$nYOriginDest,"int",$nWidthDest , _ "int",$nHeightDest,"ptr",$hdcSrc,"int",$nXOriginSrc,"int",$nYOriginSrc,"int",$nWidthSrc,"int",$nHeightSrc,"DWORD",$dwRop) if @error Or $Rt[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$Rt[0]) EndFunc Func CreateCompatibleDC($hdc) $HDC = DllCall("Gdi32.dll" ,"ptr","CreateCompatibleDC","ptr",$hdc) if @error Or $HDC[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HDC[0]) EndFunc Func SelectObject($hdc,$hgdiobj) $HGDIOBJ = DllCall("Gdi32.dll" ,"ptr","SelectObject","ptr",$hdc,"ptr",$hgdiobj) if @error Or $HGDIOBJ[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HGDIOBJ[0]) EndFunc Func DeleteObject($hObject) $Rt = DllCall("Gdi32.dll","BOOL","DeleteObjectW","ptr",$hObject) if @error Or $Rt[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$Rt[0]) EndFunc Func WindowFromDC($hDC) $HWND = DllCall("User32.dll","ptr","WindowFromDC","ptr",$hdc) if @error Or $HWND[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HWND[0]) EndFunc Func RedrawWindow($hWnd,$lprcUpdate,$hrgnUpdate,$flags) $BOOL = DllCall("User32.dll","BOOL","RedrawWindow","ptr",$hWnd,"ptr",$lprcUpdate _ ,"ptr",$hrgnUpdate,"UINT",$flags) if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$BOOL[0]) EndFunc Edited June 16, 2012 by wolf9228 ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا Â
rchockxm Posted June 10, 2012 Posted June 10, 2012 (edited) nice jobs!! win7 x86 worked fine. thanks. Edited June 10, 2012 by rchockxm
mesale0077 Posted June 10, 2012 Posted June 10, 2012 hi mp3 play add and flash and video play,call res.dll ,ı think ,why not? expandcollapse popup#include <Memory.au3> #include <WinApi.au3> #include <GDIPlus.au3> Global $bSoundEnabled = True Global $hBassDll = DllOpen(@ScriptDir & "BASS.dll") Global $hBassFXDll = DllOpen(@ScriptDir & "BASS_FX.dll") Func _ResourceLoadSound($DLL, $ResName, $Loop = 0, $Tempo = False) Local $hInstance, $InfoBlock, $GlobalMemoryBlock, $MemoryPointer, $ResSize, $SampleLoop = 0, $StreamHandle, $TempoHandle If $Loop Then $SampleLoop = 4 $hInstance = DllCall("kernel32.dll", "int", "LoadLibrary", "str", $DLL) $InfoBlock = DllCall("kernel32.dll", "int", "FindResourceA", "int", $hInstance[0], "str", $ResName, "long", 10) $ResSize = DllCall("kernel32.dll", "dword", "SizeofResource", "int", $hInstance[0], "int", $InfoBlock[0]) $GlobalMemoryBlock = DllCall("kernel32.dll", "int", "LoadResource", "int", $hInstance[0], "int", $InfoBlock[0]) $MemoryPointer = DllCall("kernel32.dll", "int", "LockResource", "int", $GlobalMemoryBlock[0]) DllCall("Kernel32.dll", "int", "FreeLibrary", "str", $hInstance[0]) Switch $Tempo Case True $StreamHandle = _BASS_StreamCreateFile($hBassDll, True, $MemoryPointer[0], 0, $ResSize[0], 0x200000); Decoding Channel $TempoHandle = _BASS_FX_TempoCreate($hBassDll, $hBassFXDll, $StreamHandle, BitOR($SampleLoop, 0x10000)); Free StreamHandle as well SetExtended($MemoryPointer[0]) Return $TempoHandle Case Else $StreamHandle = _BASS_StreamCreateFile($hBassDll, True, $MemoryPointer[0], 0, $ResSize[0], $SampleLoop); Decoding Channel SetExtended($MemoryPointer[0]) Return $StreamHandle EndSwitch EndFunc ;==>_ResourceLoadSound Func _BASS_StreamCreateFile($bass_dll, $mem, $file, $offset, $length, $flags) If $hBassDll < 0 Then Return $BASS_ret_ = DllCall($bass_dll, "dword", "BASS_StreamCreateFile", "int", $mem, "ptr", $file, "uint64", $offset, "uint64", $length, "DWORD", $flags) Return SetError(0, "", $BASS_ret_[0]) EndFunc ;==>_BASS_StreamCreateFile Func _BASS_FX_TempoCreate($bass_dll, $bassfx_dll, $chan, $flags) If $hBassDll < 0 Or $bassfx_dll < 0 Then Return Local $BASS_ret_ = DllCall($bassfx_dll, "dword", "BASS_FX_TempoCreate", "dword", $chan, "dword", $flags) Local $BS_ERR = _BASS_ErrorGetCode($bass_dll) If $BS_ERR <> 0 Then Return SetError($BS_ERR, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_FX_TempoCreate Func _BASS_ChannelSetAttribute($bass_dll, $handle, $attrib, $value) If Not $bSoundEnabled Or $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_ChannelSetAttribute", "DWORD", $handle, "DWORD", $attrib, "float", $value) EndFunc ;==>_BASS_ChannelSetAttribute Func _BASS_ChannelPlay($bass_dll, $handle, $restart) If Not $bSoundEnabled Or $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_ChannelPlay", "DWORD", $handle, "int", $restart) EndFunc ;==>_BASS_ChannelPlay Func _BASS_ChannelStop($bass_dll, $handle) If $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_ChannelStop", "DWORD", $handle) EndFunc ;==>_BASS_ChannelStop Func _BASS_StreamFree($bass_dll, $handle) If $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_StreamFree", "dword", $handle) EndFunc ;==>_BASS_StreamFree Func _BASS_SetVolume($bass_dll, $volume) If $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_SetVolume", "float", $volume) EndFunc ;==>_BASS_SetVolume Func _BASS_GetVolume($bass_dll) If $hBassDll < 0 Then Return Local $BASS_ret_ = DllCall($bass_dll, "float", "BASS_GetVolume") Return $BASS_ret_[0] EndFunc ;==>_BASS_GetVolume Func _BASS_ChannelGetPosition($bass_dll, $handle, $mode) If $hBassDll < 0 Then Return -1 $BASS_ret_ = DllCall($bass_dll, "UINT", "BASS_ChannelGetPosition", "DWORD", $handle, "DWORD", $mode) $bass_error = _BASS_ErrorGetCode($bass_dll) If $bass_error <> 0 Then Return SetError($bass_error, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_ChannelGetPosition Func _BASS_ChannelSetPosition($bass_dll, $handle, $pos, $mode) If Not $bSoundEnabled Or $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_ChannelSetPosition", "DWORD", $handle, "UINT64", $pos, "DWORD", $mode) EndFunc ;==>_BASS_ChannelSetPosition Func _BASS_ChannelIsActive($bass_dll, $handle) If $hBassDll < 0 Then Return 0 Local $BASS_ret_ = DllCall($bass_dll, "int", "BASS_ChannelIsActive", "DWORD", $handle) Local $bass_error = _BASS_ErrorGetCode($bass_dll) If $bass_error <> 0 Then Return SetError($bass_error, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_ChannelIsActive Func _BASS_Init($bass_dll, $flags, $device = -1, $freq = 44100, $win = 0, $clsid = "") If $hBassDll < 0 Then Return SetError(1, 0, 0) Local $BASS_ret_ = DllCall($bass_dll, "int", "BASS_Init", "int", $device, "dword", $freq, "dword", $flags, "hwnd", $win, "hwnd", $clsid) Local $bass_error = _BASS_ErrorGetCode($bass_dll) If $bass_error <> 0 Then Return SetError($bass_error, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_Init Func _BASS_ErrorGetCode($bass_dll) If Not $bSoundEnabled Or $hBassDll < 0 Then Return Local $BASS_ret_ = DllCall($bass_dll, "int", "BASS_ErrorGetCode") Return SetError(0, "", $BASS_ret_[0]) EndFunc ;==>_BASS_ErrorGetCode Func _BASS_Free($bass_dll) If $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_Free") EndFunc ;==>_BASS_Free Func _ResourceFree($handle) If $handle = 0 Then Return DllCall("kernel32.dll", "int", "FreeResource", "int", $handle) EndFunc ;==>_ResourceFree Func _ResourceLoadImage($DLL, $ResName); THX to Progandy, Zedna Local $hInstance, $InfoBlock, $GlobalMemoryBlock, $MemoryPointer, $ResSize, $hData, $pData, $pStream, $dll2, $pBitmap $hInstance = DllCall("kernel32.dll", "int", "LoadLibrary", "str", $DLL) $InfoBlock = DllCall("kernel32.dll", "int", "FindResourceA", "int", $hInstance[0], "str", $ResName, "long", 10) $ResSize = DllCall("kernel32.dll", "dword", "SizeofResource", "int", $hInstance[0], "int", $InfoBlock[0]) $GlobalMemoryBlock = DllCall("kernel32.dll", "int", "LoadResource", "int", $hInstance[0], "int", $InfoBlock[0]) $MemoryPointer = DllCall("kernel32.dll", "int", "LockResource", "int", $GlobalMemoryBlock[0]) DllCall("Kernel32.dll", "int", "FreeLibrary", "str", $hInstance[0]) $hData = _MemGlobalAlloc($ResSize[0], 2) $pData = _MemGlobalLock($hData) _MemMoveMemory($MemoryPointer[0], $pData, $ResSize[0]) _MemGlobalUnlock($hData) $pStream = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "int", $hData, "long", 1, "Int*", 0) $pBitmap = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromStream", "ptr", $pStream[3], "int*", 0) $DLL = DllStructCreate("Uint", $pStream[3]) $dll2 = DllStructCreate("uInt", DllStructGetData($DLL, 1) + 8) DllCall("", "UInt", DllStructGetData($dll2, 1), "UInt", $pStream[3]) _WinAPI_DeleteObject($pStream[3]) $pStream[3] = 0 _MemGlobalFree($hData) Return $pBitmap[2] EndFunc ;==>_ResourceLoadImage
wolf9228 Posted June 10, 2012 Author Posted June 10, 2012 nice jobs!!win7 x86 worked fine.thanks.Good comment, thank you ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا Â
wolf9228 Posted June 10, 2012 Author Posted June 10, 2012 (edited) hi mp3 play add and flash and video play,call res.dll ,ı think ,why not? expandcollapse popup#include <memory.au3> #include <winapi.au3> #include <gdiplus.au3> Global $bSoundEnabled = True Global $hBassDll = DllOpen(@ScriptDir & "\BASS.dll") Global $hBassFXDll = DllOpen(@ScriptDir & "\BASS_FX.dll") Func _ResourceLoadSound($DLL, $ResName, $Loop = 0, $Tempo = False) Local $hInstance, $InfoBlock, $GlobalMemoryBlock, $MemoryPointer, $ResSize, $SampleLoop = 0, $StreamHandle, $TempoHandle If $Loop Then $SampleLoop = 4 $hInstance = DllCall("kernel32.dll", "int", "LoadLibrary", "str", $DLL) $InfoBlock = DllCall("kernel32.dll", "int", "FindResourceA", "int", $hInstance[0], "str", $ResName, "long", 10) $ResSize = DllCall("kernel32.dll", "dword", "SizeofResource", "int", $hInstance[0], "int", $InfoBlock[0]) $GlobalMemoryBlock = DllCall("kernel32.dll", "int", "LoadResource", "int", $hInstance[0], "int", $InfoBlock[0]) $MemoryPointer = DllCall("kernel32.dll", "int", "LockResource", "int", $GlobalMemoryBlock[0]) DllCall("Kernel32.dll", "int", "FreeLibrary", "str", $hInstance[0]) Switch $Tempo Case True $StreamHandle = _BASS_StreamCreateFile($hBassDll, True, $MemoryPointer[0], 0, $ResSize[0], 0x200000); Decoding Channel $TempoHandle = _BASS_FX_TempoCreate($hBassDll, $hBassFXDll, $StreamHandle, BitOR($SampleLoop, 0x10000)); Free StreamHandle as well SetExtended($MemoryPointer[0]) Return $TempoHandle Case Else $StreamHandle = _BASS_StreamCreateFile($hBassDll, True, $MemoryPointer[0], 0, $ResSize[0], $SampleLoop); Decoding Channel SetExtended($MemoryPointer[0]) Return $StreamHandle EndSwitch EndFunc ;==>_ResourceLoadSound Func _BASS_StreamCreateFile($bass_dll, $mem, $file, $offset, $length, $flags) If $hBassDll < 0 Then Return $BASS_ret_ = DllCall($bass_dll, "dword", "BASS_StreamCreateFile", "int", $mem, "ptr", $file, "uint64", $offset, "uint64", $length, "DWORD", $flags) Return SetError(0, "", $BASS_ret_[0]) EndFunc ;==>_BASS_StreamCreateFile Func _BASS_FX_TempoCreate($bass_dll, $bassfx_dll, $chan, $flags) If $hBassDll < 0 Or $bassfx_dll < 0 Then Return Local $BASS_ret_ = DllCall($bassfx_dll, "dword", "BASS_FX_TempoCreate", "dword", $chan, "dword", $flags) Local $BS_ERR = _BASS_ErrorGetCode($bass_dll) If $BS_ERR <> 0 Then Return SetError($BS_ERR, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_FX_TempoCreate Func _BASS_ChannelSetAttribute($bass_dll, $handle, $attrib, $value) If Not $bSoundEnabled Or $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_ChannelSetAttribute", "DWORD", $handle, "DWORD", $attrib, "float", $value) EndFunc ;==>_BASS_ChannelSetAttribute Func _BASS_ChannelPlay($bass_dll, $handle, $restart) If Not $bSoundEnabled Or $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_ChannelPlay", "DWORD", $handle, "int", $restart) EndFunc ;==>_BASS_ChannelPlay Func _BASS_ChannelStop($bass_dll, $handle) If $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_ChannelStop", "DWORD", $handle) EndFunc ;==>_BASS_ChannelStop Func _BASS_StreamFree($bass_dll, $handle) If $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_StreamFree", "dword", $handle) EndFunc ;==>_BASS_StreamFree Func _BASS_SetVolume($bass_dll, $volume) If $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_SetVolume", "float", $volume) EndFunc ;==>_BASS_SetVolume Func _BASS_GetVolume($bass_dll) If $hBassDll < 0 Then Return Local $BASS_ret_ = DllCall($bass_dll, "float", "BASS_GetVolume") Return $BASS_ret_[0] EndFunc ;==>_BASS_GetVolume Func _BASS_ChannelGetPosition($bass_dll, $handle, $mode) If $hBassDll < 0 Then Return -1 $BASS_ret_ = DllCall($bass_dll, "UINT", "BASS_ChannelGetPosition", "DWORD", $handle, "DWORD", $mode) $bass_error = _BASS_ErrorGetCode($bass_dll) If $bass_error <> 0 Then Return SetError($bass_error, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_ChannelGetPosition Func _BASS_ChannelSetPosition($bass_dll, $handle, $pos, $mode) If Not $bSoundEnabled Or $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_ChannelSetPosition", "DWORD", $handle, "UINT64", $pos, "DWORD", $mode) EndFunc ;==>_BASS_ChannelSetPosition Func _BASS_ChannelIsActive($bass_dll, $handle) If $hBassDll < 0 Then Return 0 Local $BASS_ret_ = DllCall($bass_dll, "int", "BASS_ChannelIsActive", "DWORD", $handle) Local $bass_error = _BASS_ErrorGetCode($bass_dll) If $bass_error <> 0 Then Return SetError($bass_error, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_ChannelIsActive Func _BASS_Init($bass_dll, $flags, $device = -1, $freq = 44100, $win = 0, $clsid = "") If $hBassDll < 0 Then Return SetError(1, 0, 0) Local $BASS_ret_ = DllCall($bass_dll, "int", "BASS_Init", "int", $device, "dword", $freq, "dword", $flags, "hwnd", $win, "hwnd", $clsid) Local $bass_error = _BASS_ErrorGetCode($bass_dll) If $bass_error <> 0 Then Return SetError($bass_error, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_Init Func _BASS_ErrorGetCode($bass_dll) If Not $bSoundEnabled Or $hBassDll < 0 Then Return Local $BASS_ret_ = DllCall($bass_dll, "int", "BASS_ErrorGetCode") Return SetError(0, "", $BASS_ret_[0]) EndFunc ;==>_BASS_ErrorGetCode Func _BASS_Free($bass_dll) If $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_Free") EndFunc ;==>_BASS_Free Func _ResourceFree($handle) If $handle = 0 Then Return DllCall("kernel32.dll", "int", "FreeResource", "int", $handle) EndFunc ;==>_ResourceFree Func _ResourceLoadImage($DLL, $ResName); THX to Progandy, Zedna Local $hInstance, $InfoBlock, $GlobalMemoryBlock, $MemoryPointer, $ResSize, $hData, $pData, $pStream, $dll2, $pBitmap $hInstance = DllCall("kernel32.dll", "int", "LoadLibrary", "str", $DLL) $InfoBlock = DllCall("kernel32.dll", "int", "FindResourceA", "int", $hInstance[0], "str", $ResName, "long", 10) $ResSize = DllCall("kernel32.dll", "dword", "SizeofResource", "int", $hInstance[0], "int", $InfoBlock[0]) $GlobalMemoryBlock = DllCall("kernel32.dll", "int", "LoadResource", "int", $hInstance[0], "int", $InfoBlock[0]) $MemoryPointer = DllCall("kernel32.dll", "int", "LockResource", "int", $GlobalMemoryBlock[0]) DllCall("Kernel32.dll", "int", "FreeLibrary", "str", $hInstance[0]) $hData = _MemGlobalAlloc($ResSize[0], 2) $pData = _MemGlobalLock($hData) _MemMoveMemory($MemoryPointer[0], $pData, $ResSize[0]) _MemGlobalUnlock($hData) $pStream = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "int", $hData, "long", 1, "Int*", 0) $pBitmap = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromStream", "ptr", $pStream[3], "int*", 0) $DLL = DllStructCreate("Uint", $pStream[3]) $dll2 = DllStructCreate("uInt", DllStructGetData($DLL, 1) + 8) DllCall("", "UInt", DllStructGetData($dll2, 1), "UInt", $pStream[3]) _WinAPI_DeleteObject($pStream[3]) $pStream[3] = 0 _MemGlobalFree($hData) Return $pBitmap[2] EndFunc ;==>_ResourceLoadImage Really possible Load images from the resources of executable files through the library GDIPlus and by the GdipLoadImageFromStream function However, the Load images using the GDIPlus Library slow somewhat as the use of GDIPlus library requires start and shut down, thanks Edited June 10, 2012 by wolf9228 ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا Â
wolf9228 Posted June 10, 2012 Author Posted June 10, 2012 hi mp3 play add and flash and video play,call res.dll ,ı think ,why not? expandcollapse popup#include <Memory.au3> #include <WinApi.au3> #include <GDIPlus.au3> Global $bSoundEnabled = True Global $hBassDll = DllOpen(@ScriptDir & "BASS.dll") Global $hBassFXDll = DllOpen(@ScriptDir & "BASS_FX.dll") Func _ResourceLoadSound($DLL, $ResName, $Loop = 0, $Tempo = False) Local $hInstance, $InfoBlock, $GlobalMemoryBlock, $MemoryPointer, $ResSize, $SampleLoop = 0, $StreamHandle, $TempoHandle If $Loop Then $SampleLoop = 4 $hInstance = DllCall("kernel32.dll", "int", "LoadLibrary", "str", $DLL) $InfoBlock = DllCall("kernel32.dll", "int", "FindResourceA", "int", $hInstance[0], "str", $ResName, "long", 10) $ResSize = DllCall("kernel32.dll", "dword", "SizeofResource", "int", $hInstance[0], "int", $InfoBlock[0]) $GlobalMemoryBlock = DllCall("kernel32.dll", "int", "LoadResource", "int", $hInstance[0], "int", $InfoBlock[0]) $MemoryPointer = DllCall("kernel32.dll", "int", "LockResource", "int", $GlobalMemoryBlock[0]) DllCall("Kernel32.dll", "int", "FreeLibrary", "str", $hInstance[0]) Switch $Tempo Case True $StreamHandle = _BASS_StreamCreateFile($hBassDll, True, $MemoryPointer[0], 0, $ResSize[0], 0x200000); Decoding Channel $TempoHandle = _BASS_FX_TempoCreate($hBassDll, $hBassFXDll, $StreamHandle, BitOR($SampleLoop, 0x10000)); Free StreamHandle as well SetExtended($MemoryPointer[0]) Return $TempoHandle Case Else $StreamHandle = _BASS_StreamCreateFile($hBassDll, True, $MemoryPointer[0], 0, $ResSize[0], $SampleLoop); Decoding Channel SetExtended($MemoryPointer[0]) Return $StreamHandle EndSwitch EndFunc ;==>_ResourceLoadSound Func _BASS_StreamCreateFile($bass_dll, $mem, $file, $offset, $length, $flags) If $hBassDll < 0 Then Return $BASS_ret_ = DllCall($bass_dll, "dword", "BASS_StreamCreateFile", "int", $mem, "ptr", $file, "uint64", $offset, "uint64", $length, "DWORD", $flags) Return SetError(0, "", $BASS_ret_[0]) EndFunc ;==>_BASS_StreamCreateFile Func _BASS_FX_TempoCreate($bass_dll, $bassfx_dll, $chan, $flags) If $hBassDll < 0 Or $bassfx_dll < 0 Then Return Local $BASS_ret_ = DllCall($bassfx_dll, "dword", "BASS_FX_TempoCreate", "dword", $chan, "dword", $flags) Local $BS_ERR = _BASS_ErrorGetCode($bass_dll) If $BS_ERR <> 0 Then Return SetError($BS_ERR, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_FX_TempoCreate Func _BASS_ChannelSetAttribute($bass_dll, $handle, $attrib, $value) If Not $bSoundEnabled Or $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_ChannelSetAttribute", "DWORD", $handle, "DWORD", $attrib, "float", $value) EndFunc ;==>_BASS_ChannelSetAttribute Func _BASS_ChannelPlay($bass_dll, $handle, $restart) If Not $bSoundEnabled Or $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_ChannelPlay", "DWORD", $handle, "int", $restart) EndFunc ;==>_BASS_ChannelPlay Func _BASS_ChannelStop($bass_dll, $handle) If $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_ChannelStop", "DWORD", $handle) EndFunc ;==>_BASS_ChannelStop Func _BASS_StreamFree($bass_dll, $handle) If $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_StreamFree", "dword", $handle) EndFunc ;==>_BASS_StreamFree Func _BASS_SetVolume($bass_dll, $volume) If $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_SetVolume", "float", $volume) EndFunc ;==>_BASS_SetVolume Func _BASS_GetVolume($bass_dll) If $hBassDll < 0 Then Return Local $BASS_ret_ = DllCall($bass_dll, "float", "BASS_GetVolume") Return $BASS_ret_[0] EndFunc ;==>_BASS_GetVolume Func _BASS_ChannelGetPosition($bass_dll, $handle, $mode) If $hBassDll < 0 Then Return -1 $BASS_ret_ = DllCall($bass_dll, "UINT", "BASS_ChannelGetPosition", "DWORD", $handle, "DWORD", $mode) $bass_error = _BASS_ErrorGetCode($bass_dll) If $bass_error <> 0 Then Return SetError($bass_error, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_ChannelGetPosition Func _BASS_ChannelSetPosition($bass_dll, $handle, $pos, $mode) If Not $bSoundEnabled Or $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_ChannelSetPosition", "DWORD", $handle, "UINT64", $pos, "DWORD", $mode) EndFunc ;==>_BASS_ChannelSetPosition Func _BASS_ChannelIsActive($bass_dll, $handle) If $hBassDll < 0 Then Return 0 Local $BASS_ret_ = DllCall($bass_dll, "int", "BASS_ChannelIsActive", "DWORD", $handle) Local $bass_error = _BASS_ErrorGetCode($bass_dll) If $bass_error <> 0 Then Return SetError($bass_error, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_ChannelIsActive Func _BASS_Init($bass_dll, $flags, $device = -1, $freq = 44100, $win = 0, $clsid = "") If $hBassDll < 0 Then Return SetError(1, 0, 0) Local $BASS_ret_ = DllCall($bass_dll, "int", "BASS_Init", "int", $device, "dword", $freq, "dword", $flags, "hwnd", $win, "hwnd", $clsid) Local $bass_error = _BASS_ErrorGetCode($bass_dll) If $bass_error <> 0 Then Return SetError($bass_error, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_Init Func _BASS_ErrorGetCode($bass_dll) If Not $bSoundEnabled Or $hBassDll < 0 Then Return Local $BASS_ret_ = DllCall($bass_dll, "int", "BASS_ErrorGetCode") Return SetError(0, "", $BASS_ret_[0]) EndFunc ;==>_BASS_ErrorGetCode Func _BASS_Free($bass_dll) If $hBassDll < 0 Then Return DllCall($bass_dll, "int", "BASS_Free") EndFunc ;==>_BASS_Free Func _ResourceFree($handle) If $handle = 0 Then Return DllCall("kernel32.dll", "int", "FreeResource", "int", $handle) EndFunc ;==>_ResourceFree Func _ResourceLoadImage($DLL, $ResName); THX to Progandy, Zedna Local $hInstance, $InfoBlock, $GlobalMemoryBlock, $MemoryPointer, $ResSize, $hData, $pData, $pStream, $dll2, $pBitmap $hInstance = DllCall("kernel32.dll", "int", "LoadLibrary", "str", $DLL) $InfoBlock = DllCall("kernel32.dll", "int", "FindResourceA", "int", $hInstance[0], "str", $ResName, "long", 10) $ResSize = DllCall("kernel32.dll", "dword", "SizeofResource", "int", $hInstance[0], "int", $InfoBlock[0]) $GlobalMemoryBlock = DllCall("kernel32.dll", "int", "LoadResource", "int", $hInstance[0], "int", $InfoBlock[0]) $MemoryPointer = DllCall("kernel32.dll", "int", "LockResource", "int", $GlobalMemoryBlock[0]) DllCall("Kernel32.dll", "int", "FreeLibrary", "str", $hInstance[0]) $hData = _MemGlobalAlloc($ResSize[0], 2) $pData = _MemGlobalLock($hData) _MemMoveMemory($MemoryPointer[0], $pData, $ResSize[0]) _MemGlobalUnlock($hData) $pStream = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "int", $hData, "long", 1, "Int*", 0) $pBitmap = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromStream", "ptr", $pStream[3], "int*", 0) $DLL = DllStructCreate("Uint", $pStream[3]) $dll2 = DllStructCreate("uInt", DllStructGetData($DLL, 1) + 8) DllCall("", "UInt", DllStructGetData($dll2, 1), "UInt", $pStream[3]) _WinAPI_DeleteObject($pStream[3]) $pStream[3] = 0 _MemGlobalFree($hData) Return $pBitmap[2] EndFunc ;==>_ResourceLoadImage Sorry I did not see all the code, with respect to BASS Library , by libraries in C + + can do things very special but to use the DLL libraries marred security risks, but when you get the code of these libraries can then Used without risk, thanks ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا Â
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now