Code: Select all
#persistent
ahkmini("
(
#include <testlib>
msgbox
)")
Code: Select all
;@Ahk2Exe-AddResource LIB FULL/PATH/TO/testlib.ahk
Code: Select all
Directive_AddResource(state, UseCompression, UsePassword, rsrc, resName := "")
{
global IncludedResource
resType := "" ; auto-detect
if RegExMatch(rsrc, "^\s*(\w+|d+)\s+(.+)$", o)
resType := o1, rsrc := o2
if !FileExist(resFile := Util_GetFullPath(rsrc)) && !FileExist(resFile := Util_GetFullPath(A_ScriptDir "\..\Lib\" rsrc))
Util_Error("Error: specified resource does not exist: " rsrc)
ToolTip % resFile
SplitPath, resFile, resFileName,, resExt
if !resName
resName := resFileName, defResName := true
StringUpper, resName, resName
if (resType = "")
{
; Auto-detect resource type
if InStr(".bmp.dib.","." resExt ".")
resType := 2 ; RT_BITMAP
else if (resExt = "ico")
Util_Error("Error: Icon resource adding is not supported yet!")
else if (resExt = "cur")
Util_Error("Error: Cursor resource adding is not supported yet!")
else if InStr(".htm.html.mht.js.css.","." resExt ".")
resType := 23 ; RT_HTML
else if resExt = manifest
{
resType := 24 ; RT_MANIFEST
if defResName
resName := 1
} else
resType := 10 ; RT_RCDATA
}
typeType := "str"
nameType := "str"
if resType is integer
if resType between 0 and 0xFFFF
typeType := "PTR"
if resName is integer
if resName between 0 and 0xFFFF
nameType := "PTR"
If UseCompression && resType=10{
FileRead, tempdata, *c %resFile%
FileGetSize, tempsize, %resFile%
If !fSize := ZipRawMemory(&tempdata, tempsize, fData)
Util_Error("Error: Could not compress the file to: " file)
} else {
FileGetSize, fSize, %resFile%
FileRead, fData, *c %resFile%
}
pData := &fData
if resType = 2
{
; Remove BM header in order to make it a valid bitmap resource
if fSize < 14
Util_Error("Error: Impossible BMP file!")
pData += 14, fSize -= 14
}
if !DllCall("UpdateResource", "ptr", state.module, typeType, resType, nameType, resName
, "ushort", state.resLang, "ptr", pData, "uint", fSize, "uint")
Util_Error("Error adding resource:`n`n" rsrc)
VarSetCapacity(fData, 0)
IncludedResource[resFile]:=true
includes:=ListIncludes(resFile, "|")
Loop,Parse,includes,|
if !IncludedResource.haskey(A_LoopField)
Directive_AddResource(state, UseCompression, UsePassword, "LIB " A_LoopField, resName := "")
}