Code: Select all
;Ahk2Exe-AddResource *6 TestTextFile.txt, 33
Code: Select all
;Ahk2Exe-AddResource *6 TestTextFile.txt, 33
Code: Select all
;@Ahk2Exe-AddResource *6 G:\testfile.txt, testdata
Size := ResRead(Data, "testdata")
MsgBox, [%Size%] [%Data%]
ExitApp
; ResRead() By SKAN, from http://www.autohotkey.com/board/topic/57631-crazy-scripting-resource-only-dll-for-dummies-36l-v07/?p=609282
; adapted to change Uint to Ptr in pointer arguments
; adapted to use 6 for RC_STRING, rather than 10 for RC_DATA (either will work) in call to FindResource
; adapted to return a translated string
ResRead( ByRef Var, Key )
{
VarSetCapacity( Var, 128 ), VarSetCapacity( Var, 0 )
If ! ( A_IsCompiled )
{
FileGetSize, nSize, %Key%
FileRead, Var, *c %Key%
Return nSize
}
If hMod := DllCall( "GetModuleHandle", UPtr,0 , Ptr)
If hRes := DllCall( "FindResource", Uptr,hMod, Str,Key, UInt,6 , Ptr)
If hData := DllCall( "LoadResource", UInt,hMod, UPtr,hRes , Ptr)
If pData := DllCall( "LockResource", UInt,hData, Ptr )
{
VarSetCapacity( Var, nSize := DllCall( "SizeofResource", UInt,hMod, UInt,hRes ) )
DllCall( "RtlMoveMemory", Str,Var, UInt,pData, UInt,nSize )
Var := StrGet(&Var, nsize, "UTF-8")
Var := StrReplace(strreplace(Var, "`n",""), "`r", "")
Return, StrLen(Var)
}
Return 0
}