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 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看