Skip to content

Commit 7479a60

Browse files
save file
1 parent 4c27707 commit 7479a60

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <napi.h>
2+
#include <windows.h>
3+
4+
Napi::Value SetAlwaysOnTop(const Napi::CallbackInfo& info) {
5+
Napi::Env env = info.Env();
6+
7+
HWND hwnd = GetForegroundWindow();
8+
if (!hwnd) return Napi::Boolean::New(env, false);
9+
10+
BOOL result = SetWindowPos(
11+
hwnd,
12+
HWND_TOPMOST,
13+
0, 0, 0, 0,
14+
SWP_NOMOVE | SWP_NOSIZE
15+
);
16+
17+
return Napi::Boolean::New(env, result);
18+
}
19+
20+
Napi::Object Init(Napi::Env env, Napi::Object exports) {
21+
exports.Set("setAlwaysOnTop", Napi::Function::New(env, SetAlwaysOnTop));
22+
return exports;
23+
}
24+
25+
NODE_API_MODULE(alwaysontop, Init)
26+
27+
28+
29+

0 commit comments

Comments
 (0)