douwo6738 2016-03-31 12:45
浏览 2759

golang如何通过进程名称获取进程ID?

I want to get the process id by the process name in windows environment?

I find golang only has the api os.FindProcess(id),but no by name.

  • 写回答

3条回答 默认 最新

  • douzhicong5965 2016-03-31 13:54
    关注

    You can list all the processes and match them with the name you want to find, by using the updated sys call package, https://godoc.org/golang.org/x/sys, it has most of the windows api.

    func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error)
    func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error)
    

    also see the msdn docs: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684834(v=vs.85).aspx

    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试