【发布时间】:2015-05-22 02:21:44
【问题描述】:
我的目标是制作一个模块,该模块提供对用户交互最后一次的访问(客户端应用程序 - 不是服务器应用程序)。 Windows API 有一个名为GetLastInputInfo (https://msdn.microsoft.com/en-us/library/windows/desktop/ms646302(v=vs.85).aspx) 的函数。下面是应该将时间信息加载到last_input 的代码,它返回 0/1 表示失败/成功。不幸的是,它每次都失败。
插件代码:
#include <node.h>
#include <v8.h>
#define WINDOWS_LEAN_AND_MEAN
#include <windows.h>
using namespace v8;
Handle<Value> TimeSinceInput(const Arguments& args) {
HandleScope scope;
LASTINPUTINFO last_input;
if (::GetLastInputInfo(&last_input)) {
return scope.Close(String::New("Success!"));
}
else {
return scope.Close(String::New("Failed for some reason!"));
}
}
void init(Handle<Object> exports) {
exports->Set(String::NewSymbol("time_since_input"), FunctionTemplate::New(TimeSinceInput)->GetFunction());
}
NODE_MODULE(addon, init)
有什么想法吗?
【问题讨论】:
-
嗨兰迪!你的插件是公开的吗? :-)
标签: c++ node.js node-gyp node.js-addon