[トップ][編集][ノート][編集履歴][一覧][最近の更新][->English]

HSP3用llmodモジュール互換ライブラリ

誰でもどんどん編集(もちろん、改良も含みます)してください。

llmod.as

#ifndef __llmod__
#define __llmod__

#module "llmod"

; dllproc用
#enum global D_KERNEL = 0
#enum global D_USER
#enum global D_SHELL
#enum global D_COMCTL
#enum global D_COMDLG
#enum global D_GDI

; マクロ命令
#define global getptr(%1,%2) %1 = varptr(%2)
#define global _get_instance(%1) %1 = hinstance

; DLL関数
#uselib "kernel32.dll"
#func LoadLibrary "LoadLibraryA" sptr
#func GetProcAddress "GetProcAddress" int, sptr

#uselib "user32.dll"
#func GetActiveWindow "GetActiveWindow"
#func GetWindowLong "GetWindowLongA" int, int, int
#func SetWindowLong "SetWindowLongA" int, int, int
#func CreateWindowEx "CreateWindowExA" int, sptr, sptr, int, int, int, int, int, int, int, int, int
#func IsWindow "IsWindow" int
#func GetFocus "GetFocus"
#func SetFocus "SetFocus" int
#func global _charupper "CharUpperA" var
#func global _charlower "CharLowerA" var

#deffunc __llmod_init
mref _stat, 64
LoadLibrary "kernel32.dll": ptr_lcf(D_KERNEL) = stat
LoadLibrary "user32.dll": ptr_lcf(D_USER) = stat
LoadLibrary "shell32.dll":ptr_lcf(D_SHELL)= stat
LoadLibrary "comctl32.dll": ptr_lcf(D_COMCTL) = stat
LoadLibrary "comdlg32.dll": ptr_lcf(D_COMDLG) = stat
LoadLibrary "gdi32.dll":ptr_lcf(D_GDI)= stat
GetProcAddress ptr_lcf(D_USER), "SendMessageA":ptr_fcf.0 = stat
GetProcAddress ptr_lcf(D_USER), "CreateWindowExA": ptr_fcf.1 = stat
GetProcAddress ptr_lcf(D_USER), "GetActiveWindow": ptr_fcf.2 = stat
return

#deffunc dllproc str funcname, array prms, int prmnum, int dll_no
if dll_no & $FFFFFF00: hdll = dll_no: else: hdll = ptr_lcf(dll_no)
GetProcAddress hdll, funcname
func = stat
if func{
dllret@ = callfunc(prms, func, prmnum)
_stat = dllret@
} else {
dialog "can not find '"+funcname+"'\ndll="+dll_no
getkey a, 16 : if a : end
}
return

#deffunc getmjrdll var ret, int index
ret = ptr_lcf.index
return

#deffunc getmjrfunc var ret, int index
ret = ptr_fcf.index
return

#deffunc _get_active_window var ret
GetActiveWindow
dllret@ = stat
return

#deffunc _sendmsg array prms
sendmsg prms.0, prms.1, prms.2, prms.3
dllret@ = stat
return

#deffunc setwndlong var prms, int flag
if flag{
GetWindowLong prms.0, prms.1
} else {
SetWindowLong prms.0, prms.1, prms.2
}
dllret@ = _stat
return

#deffunc _null_sep_str var dest, int sep
        num = 0
        repeat strlen(dest)
                hex = peek(dest, cnt)
                if a = sep: poke dest, cnt, 0: num++
        loop
        _stat = num
        return

#deffunc _is_wnd int hdest
        IsWindow hdest
        dllret@ = stat
        return

#deffunc _hspobjhandle int objid
        mref bmscr, 67
        if 0 <= objid & objid < bmscr.72{
                _stat = objinfo(objid, 2)
        } else {
                _stat = 0
        }
        return

#deffunc _hspobjid int hobj
        mref bmscr, 67

        _stat = -1
        repeat bmscr.72 ; bmscr.objmax
                if hobj != objinfo(cnt, 2): _stat = cnt: break
        loop
        return

#deffunc _objsel int hobj
        if hobj = -1{
                GetFocus
                if stat = hwnd: _stat = -1: return
                tmp = stat
                _hspobjid tmp
                if stat ! -1: tmp = stat
                _stat = tmp
        }else{
                tmp = hobj
                _hspobjhandle tmp
                if stat: tmp = stat
                SetFocus tmp
        }
        return


#global
__llmod_init

#endif ; <- #ifndef __llmod__