Jump to content

Search the Community

Showing results for tags '_rcdata_getresasbytes'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. In my code optimization work, I only work with these 2 functions so I share it: ; # Dao Van Trong - TRONG.LIVE # ======================================================= ; Title .........: Resource UDF for RCDATA ; ; _RCDATA_GetResAsBytes($sResNameOrID, $iResLang = 0) ; _RCDATA_GetResAsString($sResNameOrID, $iResLang = 0) ; ; ================================================================ #Region - # FUNCTION # Func _RCDATA_GetResAsBytes($sResNameOrID, $iResLang = 0) Local $hRes, $hInstance = __WinAPI_GetModuleHandle(Null) If ($iResLang <> 0) Then $hRes = __WinAPI_FindResourceEx($hInstance, 10, $sResNameOrID, $iResLang) ;$RT_RCDATA = 10 Else $hRes = __WinAPI_FindResource($hInstance, 10, $sResNameOrID) EndIf If @error Or Not $hRes Then Return SetError(1, 0, 0) Local $dSize = __WinAPI_SizeOfResource($hInstance, $hRes) If @error Or Not $dSize Then Return SetError(2, 0, 0) Local $hLoad = __WinAPI_LoadResource($hInstance, $hRes) If @error Or Not $hLoad Then Return SetError(3, 0, 0) Local $pData = __WinAPI_LockResource($hLoad) If @error Or Not $pData Then Return SetError(4, 0, 0) Local $tBuffer = DllStructCreate("byte[" & $dSize & "]") __WinAPI_MoveMemory(DllStructGetPtr($tBuffer), $pData, $dSize) Return DllStructGetData($tBuffer, 1) EndFunc ;==>_RCDATA_GetResAsBytes Func _RCDATA_GetResAsString($sResNameOrID, $iResLang = 0) Local $pResource = _RCDATA_GetResAsBytes($sResNameOrID, $iResLang) If @error Then Return SetError(1, 0, 0) Local $iError = @error, $iLength = @extended Local Enum $BINARYTOSTRING_NONE, $BINARYTOSTRING_ANSI, $BINARYTOSTRING_UTF16LE, $BINARYTOSTRING_UTF16BE, $BINARYTOSTRING_UTF8 Local $iStart = $BINARYTOSTRING_NONE, $iUTFEncoding = $BINARYTOSTRING_ANSI Local Const $sUTF8 = '0xEFBBBF', $sUTF16BE = '0xFEFF', $sUTF16LE = '0xFFFE', $sUTF32BE = '0x0000FEFF', $sUTF32LE = '0xFFFE0000' Local $iUTF8 = BinaryLen($sUTF8), $iUTF16BE = BinaryLen($sUTF16BE), $iUTF16LE = BinaryLen($sUTF16LE), $iUTF32BE = BinaryLen($sUTF32BE), $iUTF32LE = BinaryLen($sUTF32LE) Select Case BinaryMid($pResource, 1, $iUTF32BE) = $sUTF32BE $iStart = $iUTF32BE $iUTFEncoding = $BINARYTOSTRING_ANSI Case BinaryMid($pResource, 1, $iUTF32LE) = $sUTF32LE $iStart = $iUTF32LE $iUTFEncoding = $BINARYTOSTRING_ANSI Case BinaryMid($pResource, 1, $iUTF16BE) = $sUTF16BE $iStart = $iUTF16BE $iUTFEncoding = $BINARYTOSTRING_UTF16BE Case BinaryMid($pResource, 1, $iUTF16LE) = $sUTF16LE $iStart = $iUTF16LE $iUTFEncoding = $BINARYTOSTRING_UTF16LE Case BinaryMid($pResource, 1, $iUTF8) = $sUTF8 $iStart = $iUTF8 $iUTFEncoding = $BINARYTOSTRING_UTF8 EndSelect $iStart += 1 $iLength = $iLength + 1 - $iStart Local $sString = BinaryToString(BinaryMid($pResource, $iStart), $iUTFEncoding) $pResource = 0 Return SetError($iError, $iLength, $sString) EndFunc ;==>_RCDATA_GetResAsString #EndRegion - # FUNCTION # #Region ; #INTERNAL_USE_ONLY# # Dao Van Trong - TRONG.LIVE ;#include <WinAPIRes.au3> ;#include <WinAPIInternals.au3> Func __WinAPI_GetModuleHandle($sModuleName) If $sModuleName = "" Then $sModuleName = Null Local $aCall = DllCall("kernel32.dll", "handle", "GetModuleHandleW", "wstr", $sModuleName) If @error Then Return SetError(@error, @extended, 0) Return $aCall[0] EndFunc ;==>__WinAPI_GetModuleHandle Func __WinAPI_IsBadReadPtr($pAddress, $iLength) Local $aCall = DllCall('kernel32.dll', 'bool', 'IsBadReadPtr', 'struct*', $pAddress, 'uint_ptr', $iLength) If @error Then Return SetError(@error, @extended, False) Return $aCall[0] EndFunc ;==>__WinAPI_IsBadReadPtr Func __WinAPI_IsBadWritePtr($pAddress, $iLength) Local $aCall = DllCall('kernel32.dll', 'bool', 'IsBadWritePtr', 'struct*', $pAddress, 'uint_ptr', $iLength) If @error Then Return SetError(@error, @extended, False) Return $aCall[0] EndFunc ;==>__WinAPI_IsBadWritePtr Func __WinAPI_MoveMemory($pDestination, $pSource, $iLength) If __WinAPI_IsBadReadPtr($pSource, $iLength) Then Return SetError(10, @extended, 0) If __WinAPI_IsBadWritePtr($pDestination, $iLength) Then Return SetError(11, @extended, 0) DllCall('ntdll.dll', 'none', 'RtlMoveMemory', 'struct*', $pDestination, 'struct*', $pSource, 'ulong_ptr', $iLength) If @error Then Return SetError(@error, @extended, 0) Return 1 EndFunc ;==>__WinAPI_MoveMemory Func __WinAPI_FindResource($hInstance, $sType, $sName) Local $sTypeOfType = 'int', $sTypeOfName = 'int' If IsString($sType) Then $sTypeOfType = 'wstr' EndIf If IsString($sName) Then $sTypeOfName = 'wstr' EndIf Local $aCall = DllCall('kernel32.dll', 'handle', 'FindResourceW', 'handle', $hInstance, $sTypeOfName, $sName, $sTypeOfType, $sType) If @error Then Return SetError(@error, @extended, 0) Return $aCall[0] EndFunc ;==>__WinAPI_FindResource Func __WinAPI_FindResourceEx($hInstance, $sType, $sName, $iLanguage) Local $sTypeOfType = 'int', $sTypeOfName = 'int' If IsString($sType) Then $sTypeOfType = 'wstr' EndIf If IsString($sName) Then $sTypeOfName = 'wstr' EndIf Local $aCall = DllCall('kernel32.dll', 'handle', 'FindResourceExW', 'handle', $hInstance, $sTypeOfType, $sType, $sTypeOfName, $sName, 'ushort', $iLanguage) If @error Then Return SetError(@error, @extended, 0) Return $aCall[0] EndFunc ;==>__WinAPI_FindResourceEx Func __WinAPI_LoadResource($hInstance, $hResource) Local $aCall = DllCall('kernel32.dll', 'handle', 'LoadResource', 'handle', $hInstance, 'handle', $hResource) If @error Then Return SetError(@error, @extended, 0) Return $aCall[0] EndFunc ;==>__WinAPI_LoadResource Func __WinAPI_LockResource($hData) Local $aCall = DllCall('kernel32.dll', 'ptr', 'LockResource', 'handle', $hData) If @error Then Return SetError(@error, @extended, 0) Return $aCall[0] EndFunc ;==>__WinAPI_LockResource Func __WinAPI_SizeOfResource($hInstance, $hResource) Local $aCall = DllCall('kernel32.dll', 'dword', 'SizeofResource', 'handle', $hInstance, 'handle', $hResource) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) Return $aCall[0] EndFunc ;==>__WinAPI_SizeOfResource #EndRegion ; #INTERNAL_USE_ONLY# # Dao Van Trong - TRONG.LIVE ;# Dao Van Trong - TRONG.LIVE
×
×
  • Create New...