npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@flowyai/mic_occupying

v0.0.4

Published

检测并获取占用 Windows 麦克风的进程 ID

Downloads

20

Readme

mic_occupying

项目简介

mic_occupying 是一个用 Go 语言编写的工具库,用于检测并获取当前占用 Windows 操作系统麦克风的进程 ID 列表。该库生成可被其他程序调用的 DLL 文件,支持 x64 和 ARM64 两种架构,同时提供了 npm 包形式的封装,方便在 Node.js 环境中使用。

功能特点

  • 检测并获取占用 Windows 麦克风的进程 ID
  • 支持 x64 和 ARM64 架构
  • 提供 C 语言兼容的 API 接口
  • 输出 JSON 格式的进程 ID 列表或错误信息
  • 支持自动构建和发布到 npm

技术栈

API 说明

C API

GetMicOccupyingProcessIds

const char* GetMicOccupyingProcessIds();

功能:获取当前占用麦克风的进程 ID 列表

返回值:JSON 格式的字符串

  • 成功时返回进程 ID 数组,如:[1234, 5678]
  • 失败时返回错误信息,如:{"error": "错误详情"}

构建指南

前提条件

  • 安装 Go 1.24.1 或更高版本
  • 安装 MinGW (用于 x64 构建)
  • 安装 LLVM-Mingw (用于 ARM64 构建)

使用提供的构建脚本

Windows 环境下使用 build.bat

build.bat

使用 Makefile

mingw32-make.exe build-all

手动构建

构建 x64 架构

export CGO_ENABLED=1
export GOARCH=amd64
export GOOS=windows
go build -ldflags="-s -w" -o ../../runtime/win32/x64/mic_occupying.dll -buildmode=c-shared ./

构建 ARM64 架构

export CGO_ENABLED=1
export GOARCH=arm64
export GOOS=windows
export CC=C:\llvm-mingw\bin\aarch64-w64-mingw32-clang.exe
export CXX=C:\llvm-mingw\bin\aarch64-w64-mingw32-clang++.exe
go build -ldflags="-s -w" -o ../../runtime/win32/arm64/mic_occupying.dll -buildmode=c-shared ./

使用示例

C/C++ 示例

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 声明外部函数
extern const char* GetMicOccupyingProcessIds();

int main() {
    const char* result = GetMicOccupyingProcessIds();
    printf("占用麦克风的进程 ID: %s\n", result);
    
    // 注意:在实际应用中,需要释放返回的字符串内存
    // free((void*)result);
    
    return 0;
}

自动发布说明

项目配置了 GitHub Actions 自动构建和发布流程,当代码推送到 main 分支时,会自动执行以下操作:

  1. 构建 x64 和 ARM64 架构的 DLL 文件
  2. 创建 GitHub Release,上传构建产物
  3. 发布 npm 包,包含构建的 DLL 文件和 JavaScript API

注意事项

  1. 该库依赖 Windows Core Audio API,仅适用于 Windows 操作系统
  2. 调用 C API 后,需要释放返回的字符串内存
  3. 构建时需要正确配置 Go 环境变量和编译器路径
  4. 运行时需要具备访问系统音频设备的权限

项目结构

├── .github/           # GitHub 相关配置
│   └── workflows/     # CI/CD 工作流
├── .gitignore         # Git 忽略文件配置
├── Makefile           # 构建脚本
├── README.md          # 项目说明文档
├── build.bat          # Windows 构建批处理脚本
├── go.mod             # Go 模块依赖配置
├── main.go            # 主要源代码
├── index.js           # npm 包入口文件
├── package.json       # npm 包配置