写了个例子,不需要另外下载 resources UDF ,使用内置API UDF
将测试用的 test.txt 文件和本脚本放在一起,编译后再运行。
#AutoIt3Wrapper_Res_File_Add = test.txt, RT_RCdata, txt
#include <WinAPIRes.au3>
Local $str = _Res_GetTxt('txt')
If Not @error Then MsgBox(0, '', $str)
Func _Res_GetTxt($sRcName)
Local $hInstance = _WinAPI_LoadLibraryEx(@AutoItExe, $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then Return SetError(1)
Local $hResource = _WinAPI_FindResource($hInstance, 10, $sRcName)
If Not $hResource Then Return SetError(2)
Local $iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
Local $hData = _WinAPI_LoadResource($hInstance, $hResource)
Local $pData = _WinAPI_LockResource($hData)
Local $tData = DllStructCreate('byte[' & $iSize & ']', $pData)
Local $str = BinaryToString(DllStructGetData($tData, 1))
_WinAPI_FreeLibrary($hInstance)
Return $str
EndFunc ;==>_Res_GetTxt
|