PAIP。JS调用DLL的解决方案

PAIP。JS调用DLL的解决方案 




作者Attilax ,  EMAIL:1466519819@qq.com 
来源:attilax的专栏
地址:http://blog.csdn.net/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
--------------------------------------









posted @ 2013-05-31 13:07  attilaxAti  阅读(36)  评论(0编辑  收藏  举报