簡體   English   中英

呼叫Windows計算器c#

[英]Call Windows Calculator c#

我用

System.Diagnostics.Process.Start("calc");

它在localhost上運行良好,但是在部署項目並訪問網站並調用計算器時,它不起作用,實際上沒有任何反應。 沒有錯誤左右。

我希望計算器能夠在客戶端計算機上啟動。 我怎樣才能做到這一點?

出於安全原因,不允許從瀏覽器直接從網站啟動進程。 您需要編寫一個瀏覽器插件才能執行此操作。

請嘗試一些客戶端代碼。 像下面這樣

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script language="JavaScript">
        function launchExecutable() {
            var shellActiveXObject = new ActiveXObject("WScript.Shell");

            shellActiveXObject.Run("C:\\Windows\\System32\\calc.exe", 1, false);
            shellActiveXObject = null;
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input id="Button1" type="button" onclick="launchExecutable();" value="button" />
    </div>
    </form>
</body>

</html>

代碼未經測試。 希望這對您有幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM