PAIP。JS调用DLL的解决方案

本文介绍了两种从JavaScript调用DLL的方法。第一种方法是通过使用COM对象APIWrapper.dll,包括注册DLL、创建对象并导入DLL函数的过程。第二种方法是通过CLI接口调用AutoHotkey(AHK)的DllCall函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

PAIP。JS调用DLL的解决方案 




作者Attilax ,  EMAIL:1466519819@qq.com 
来源:attilax的专栏
地址:http://blog.youkuaiyun.com/attilax






1.使用COM对象APIWARPPER.DLL...
--------------------------------
先注册.
regsvr32 ApiWrapper.dll




然后...






const MAX_CLASS_NAME=260


Set fn = CreateObject("ApiWrapper")
fn.DllImport "user32","RealGetWindowClassA","r=l|f=s|i=lpl"
fn.DllImport "user32","FindWindowExA","f=s|r=l|i=llss"
fn.DllImport "user32","IsWindow","f=s|r=l|i=l"
fn.CScriptMode






szClass=fn.ArrayCreate(MAX_CLASS_NAME)








Function JumpWeb
dim hwnd:hwnd=0
do
hwnd=fn.FindWindowExA(0,hwnd,0,0)
if hwnd=0 then exit do

r=fn.RealGetWindowClassA(hwnd,szClass,MAX_CLASS_NAME)
if fn.A2W(szClass)="IEFrame" then
WScript.Echo hwnd & "=" & fn.IsWindow(hwnd)
end if
loop
End Function




do
WScript.Echo "----------------------------"
JumpWeb
WScript.Sleep 1000
loop








'*********************** f 的定义(函数调用约定) *****************************************
'     m -> DC_MICROSOFT      b -> DC_BORLAND
'     s -> DC_CALL_STD       c -> DC_CALL_CDECL
'     4 -> DC_RETVAL_MATH4   8 -> DC_RETVAL_MATH8
'*********************** i 和 r 的定义(参数类型) ****************************************
'     c -> signed char    t -> short          s -> string        w -> wide string 
'     l -> long           u -> unsigned int   f -> 4 byte real   d -> 8 byte real
'     h -> HANDLE         p -> PVOID          a -> IDispatch*    k -> IUnknown* or PVOID
'****************************************************************************************


Set fn = CreateObject("ApiWrapper")
fn.DllImport "user32","MessageBoxW","r=l|f=s|i=lwwl"
fn.DllImport "user32","MessageBoxA","f=s|r=l|i=lssl"


WScript.Echo fn.Help


msg = "Hello world !"


if 1=fn.MessageBoxW(0,msg,3.14 ,1) then fn.MessageBoxA 0,msg,0,0




2.通过CLI接口调用AHK的DllCall
--------------------------------------









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值