0

PHP から呼び出すことができ、実行時に特定のプログラムを終了できるクライアント側のアプリケーションを作成しようとしています。このためのexeファイルを開発しようとしましたが、クライアント側でphp経由でexeファイルを呼び出すことができません。PHPで呼び出すことができる、私が開発できる他の形式のアプリケーションはありますか? Windows サービスを開発して、代わりに php 経由で呼び出すことはできますか? ユーザーに何でもダウンロードしてインストールするように依頼できます。ただし、これを実現するためにjavascriptを使用することはできません。

4

2 に答える 2

2

理解できるように、質問を少し言い換えます。

サーバーで PHP スクリプトを使用して、ユーザー (クライアント) のコンピューターで EXE を呼び出すことはできますか?

それがあなたの質問なら、答えは次のとおりです。

いいえ。他の方法もありますが、一般に、許可された Web サイトやクライアント、または特殊なケースの非常に厳密なサブセット以外では機能しません。

ただし、質問の中で、ユーザーに何でもダウンロードしてインストールするように依頼できると述べています。ユーザーが Web サイトからファイル (実行可能ファイル) をダウンロードして、自分のコンピューターで実行できる場合、何が問題になっていると思われますか?

于 2012-10-31T01:30:11.583 に答える
0

私はなんとかこの問題を解決することができましたが、この問題に直面する可能性のある他の人にどれほど適用できるかわかりません。

PHPでCookieを設定し、クライアントのコンピューターでそのCookieの値を確認します。

私の場合、クライアントにブラウザクライアントとしてXULRunnerを使用するように強制しているため、Cookieが存在する場所は1つだけです。ブラウザが固定されていない場合は、すべてのブラウザのすべての場所を個別に処理する必要があります。

以下は、クライアントのコンピューターのアプリケーションに使用しているコードです。-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;

namespace beforeSEBstart
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a timer that polls once every 5 seconds
            string appdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            Console.WriteLine(appdata);
            string curFile = appdata+@"\ETH Zuerich\xul_seb\Profiles\cookies.sqlite-wal";
            System.IO.File.WriteAllText(curFile, string.Empty);
            var timer = new System.Threading.Timer(TimerProc, null, 5000, 5000);
            Console.WriteLine("Polling every 5 seconds.");
            Console.WriteLine("Press Enter when done:");
            Console.ReadLine();
            timer.Dispose();
        }

        static int TickCount = 0;
        static void TimerProc(object state)
        {
            ++TickCount;
            Boolean found = false;
            Console.WriteLine("tick {0}", TickCount);
            string appdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            Console.WriteLine(appdata);
            string curFile = appdata + @"\ETH Zuerich\xul_seb\Profiles\cookies.sqlite-wal";
            string line;
            Console.WriteLine(File.Exists(curFile) ? "File exists." : "File does not exist.");
            //Console.WriteLine(File.Exists(curFile) ? "File exists." : "File does not exist.");
            Stream stream = File.Open(curFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            StreamReader file = new StreamReader(stream);
            while ((line = file.ReadLine()) != null)
            {
                if (line.Contains("SEBClose2"))
                {
                    found = true;
                }
            }
            if (found)
            {
                Console.WriteLine("String exists in the file.");
                System.Diagnostics.Process.Start("ConsoleApplication1.exe");
                foreach (System.Diagnostics.Process myProc in System.Diagnostics.Process.GetProcesses())
                {
                    if (myProc.ProcessName == "beforeSEBstart.vshost" || myProc.ProcessName == "beforeSEBstart")
                    {
                        myProc.Kill();
                    }
                };
            }
            else
            {
                Console.WriteLine("String does not exist in the file.");
            }
            file.Close();
        }
    }
}

サーバー側では、クライアントが終了ボタンを押したときに、phpでSEBclose2という名前のCookieを設定しました。

于 2012-11-19T08:53:23.010 に答える