요구 사항은 모든 창을 현재 데스크탑에서 열어 보는 것입니다. node-ffi modulenode-ffi - EnumWindows 콜백 추출
내 코드 조각 :
/**
@Name :Parthasarathy Balakrishnan
@Version : V0.1
@Date : 18/03/2013 */
var ffi = require('ffi'),
ref = require('ref'),
int = ref.types.int,
assert = require('assert'),
bindings = require('bindings'),
buffer = require('buffer')
var user32,Kernel32;
var lpEnumFunc;
var invokeCount=0;
/**EnumWindows API CALL
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc,_In_ LPARAM lParam);
Parameters
lpEnumFunc [in]
Type: WNDENUMPROC
A pointer to an application-defined callback function. For more information, see EnumWindowsProc.
lParam [in]
Type: LPARAM
An application-defined value to be passed to the callback function.
**/
user32 = new ffi.Library('user32', {'EnumWindows':[ 'bool', ['pointer','int32'] ], // BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc,_In_ LPARAM lParam);
'GetWindowTextW':[ 'int32', ['pointer','pointer','int32']]});
Kernel32 = new ffi.Library('kernel32', {'GetLastError':['bool', ['pointer','int32'] ]}); // Not required for this demo
lpEnumFunc = ffi.Callback('bool',['pointer','int32'],function (hwnd,lParam){
console.log("------------------START---------------------")
console.log(hwnd);
console.log(ref.getType(hwnd));
console.log("Is Buffer/Pointer NULL :\t"+ref.isNull(hwnd));
console.log("lParam :\t"+lParam)
console.log("EnumWindows Callback handler : \t "+hwnd.length);
//Pointer implementations-start
var buf = new Buffer(ref.sizeof.pointer);
ref.writePointer(buf, 0, hwnd);
var out = ref.readPointer(buf, 0, hwnd.length)
for (var i = 0, l = out.length; i < l; i++) {
console.log(out[i])
}
//Pointer implementations-end
console.log("ref address :\t"+ref.address(hwnd));
console.log("------------------END---------------------")
return true;
});
console.log("Calling EnumWindows init");
var bool = user32.EnumWindows(lpEnumFunc,0);
console.log("EnumWindows return value :\t"+bool);
// register the callback function
process.on('uncaughtException', function() {
console.error('uncaught:', arguments);
});
출력 :
Calling EnumWindows init
------------------START---------------------
{ size: 0,
indirection: 1,
get: [Function: get],
set: [Function: set],
name: 'void',
ffi_type: }
Is Buffer/Pointer NULL : false
lParam : 0
EnumWindows Callback handler : 0
ref address : 197424
------------------END---------------------
나는 0
노드 참조 링크로 핸들러 길이를 제공 노드 FFI에서 EnumWindows를 호출하는 것을 시도하고있다
출력에서 처리기 크기가 0으로 변경됩니다.
내가 뭘 잘못하고 있니?
이것을 모듈로 만들었습니다. [node-hide] (https://www.npmjs.com/package/node-hide) – Ducky