forked from abhaybuch/node-mac-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwin_utils.cpp
More file actions
32 lines (25 loc) · 928 Bytes
/
Copy pathwin_utils.cpp
File metadata and controls
32 lines (25 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <napi.h>
#include <windows.h>
#include "AudioProcessMonitor.h"
// Gets a list of processes that are accessing input (microphone)
Napi::Value GetRunningInputAudioProcesses(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
try {
std::vector<std::string> processes = GetAudioInputProcesses();
Napi::Array result = Napi::Array::New(env);
for (size_t i = 0; i < processes.size(); i++) {
result.Set(i, Napi::String::New(env, processes[i]));
}
return result;
} catch (const std::exception& e) {
Napi::Error::New(env, e.what()).ThrowAsJavaScriptException();
return env.Null();
}
}
// Initialize the module exports
Napi::Object Init(Napi::Env env, Napi::Object exports) {
exports.Set(Napi::String::New(env, "getRunningInputAudioProcesses"),
Napi::Function::New(env, GetRunningInputAudioProcesses));
return exports;
}
NODE_API_MODULE(win_utils, Init)