方法一:
Code: Select all
OnExit() {
static handler := {__Delete: "OnExit"}
static _ := new handler
MsgBox, bye
}
MsgBox, hi
Code: Select all
class test
{
__Delete() {
static _ := new test
MsgBox, bye
}
}
MsgBox, hi
Code: Select all
; xd2txlib.dll 下载地址: http://www31.ocn.ne.jp/~h_ishida/xdoc2txt.html
MsgBox, % xdoc2txt("test.doc")
xdoc2txt(fileName) {
; 脚本启动时自动载入 dll
static hModule := DllCall("LoadLibrary", "Str", "xd2txlib.dll")
; 脚本退出时自动释放 dll
static handler := {__Delete: "xdoc2txt"}
static _______ := new handler
If A_ExitReason {
DllCall("FreeLibrary", "Ptr", hModule)
Return
}
; 这里是函数的功能代码
fileLength := DllCall("xd2txlib\ExtractText", "Str", fileName, "Int", False, "Int*", fileText)
Return StrGet( fileText, fileLength / 2 )
}