dongshao6591 2014-03-17 09:16
浏览 41
已采纳

转到-如何检测用户PC是否正在运行某些必备工具(例如Google Chrome)

How can i be 100% sure and check with Go execution of my application that 1, 2 gives me true or false

1) Operating system Windows XP, Vista, 7, 8, 32/64-bit OK if that PC already have Google Chrome browser installed or not?

2) Operating system Mac/Apple, does it has Google Chrome browser Yes or not?

package main
import "os/exec"
import "runtime"
import "fmt"
import "net/http"
const url = "http://localhsot:9090"

func main() {  
  myos := runtime.GOOS // linux, freebsd, netbsd, openbsd, plan9, darwin, windows
  fmt.Println (runtime.GOARCH) // 386, amd64, arm

  if myos == "windows" {
    if myarch == "386" {
      chrome := "C:/Program Files/Google/Chrome/Application/chrome.exe"
    } else {
      chrome := "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
    }          
    cmd := exec.Command(chrome, "--chrome-frame", url)
    err := cmd.Start()
    if err != nil {
      println("Failed to start chrome:", err)
    } 

  } else if myos == "darwin" {
    if myarch == "386" {
      cmd := exec.Command("open", "-b" , "com.google.Chrome", "--args", "--chrome-frame", url)
    } else {
      cmd := exec.Command("open", "-b" , "com.google.Chrome", "--args", "--chrome-frame", url)
    }
    err := cmd.Start()
    if err != nil {
      fmt.Println("failed")
    } 

  } else {
    if myarch == "386" {
      chrome := "google-chrome"
    } else {
      chrome := "google-chrome"
    }   

    cmd := exec.Command(chrome, "--chrome-frame", url)
    err := cmd.Start()
    if err != nil {
      fmt.Println("failed")
    }

  }

}
  • 写回答

1条回答 默认 最新

  • dongqu9917 2014-03-17 09:59
    关注

    In Windows,

    Win 7 and high:

    You can use "HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\Google Chrome" to find out install path. This actually coming from "Google Chrome" key found at "HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications".

    Win XP to vista:

    You could read from "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome". This location i have not verified, please do check if you have xp machine.

    For Mac:

    You can find chrome install location using chrome's bundle identifier (you could find this from info.plist).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP