移植串行守护进程 + PHP 到 Windows

发布于 2024-11-08 01:37:54 字数 237 浏览 2 评论 0原文

我有一个 Linux 系统,其中包含:

  • 一个通过 RS232 端口与另一个设备通信的守护程序。
  • 一个 php + javascript 网站,通过 a 与守护进程对话 插座。

现在老板想知道需要付出多大的努力才能将这些全部移植到Windowze上。

我以前从未真正在 Windows 上编程过,所以我想问一下这将是多么容易/困难以及有哪些选项。

谢谢,

I have a Linux system with:

  • a daemon that communicate with another device via RS232 port.
  • a php + javascript web site that talks to the daemon through a
    socket.

Now the boss wants to find out how much of an effort is required to port all these onto Windowze.

Having never really programmed on Windows before, I'd like to ask how easy/hard this is going to be and what the options are.

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゝ偶尔ゞ 2024-11-15 01:37:54

PHP 可能会按原样运行。 Javascript 在网络浏览器中运行,并且将按原样运行。你的守护进程是 Windows 上的一个服务。显然,它通过 javascript 在套接字上侦听来自网页的命令。

您没有说明您的服务目标语言是什么。某些语言(例如 C# dot Net)具有内置库,用于创建可以暂停、停止、启动以及与 Windows 服务控制系统交互的干净服务。 C# 将是一个很好的选择,可以创建一个可以轻松安装和删除自身的服务,并且它支持良好的高级套接字控制来侦听 PHP 和 javascript 代码。我使用过 perl、C#、C++,甚至 Visual Basic 作为服务运行,所以选择权在你。

如果您选择的 Windows 语言是编译为某些 .EXE,则添加服务的低级方法如下。您将需要 INSTSRV.exe 和 SRVANY.EXE,它们位于 Windows 资源工具包中,或者可以通过快速网络搜索轻松下载。

简短版本:

登录并调试后让服务器运行起来,将 APP 服务器正常安装到 C:\Program Files\APP 目录。这将是连接到串行端口并通过套接字执行您想要的操作的应用程序。

将 instsrv.exe 复制到 C:\WINDOWS\system32 目录/

将 SRVANY.EXE 复制到 C:\Program Files\YOURAPP

从命令提示符运行此命令 – INSTSRV YOURAPP "C:\Program Files\YOURAPP\srvany.exe"

Run注册表编辑器 (REGEDT.EXE)

在 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YOURAPP 下:创建一个“Parameters”键(文件夹)

在此键下,创建一个名为 Application 的 REG_SZ 字符串值,并添加此数据 C:\Program Files\YOURAPP\YOURAPP.exe

关闭 Regedit,然后在管理工具中打开服务控制台,或启动、运行服务.msc,确认已设置为自动启动且登录帐户为LocalSystem。然后取消单击“允许服务与桌面交互”。如果您单击此选项,则每当它写入屏幕时,它都会在 Windows 7 盒子上打断您。

启动服务,检查任务管理器,您将在其中看到 YOURAPP.exe,如果停止该服务则 YOURAPP.exe 将消失。

长版

详细信息位于 http://support.microsoft.com/kb/137890

PHP will probably run as is. Javascript runs in the web browser, and will run as is. Your daemon is a service on windows. Apparently it listens on a socket for commands from the web page via javascript.

You did not state what language you are targeting for the service. Some languages such as C# dot Net, have built-in libraries for making clean services that can pause, stop, start, and interact with the Windows Service Control system. C# would be a good choice to make a service that can install and remove itself easily, and it supports nice high level socket control to listen to the PHP and javascript code. I have used perl, C#, C++, and even Visual Basic running as a service, so the choice is yours.

If your choice of Windows language is that compiles to some .EXE, then a low-level way to add a service is as follows. You will need INSTSRV.exe and SRVANY.EXE, which come on the Windows Resource Kit, or can be downloaded easily with a quick web search.

The short version :

After you get the server runnign when you are logged in and debugged, install the APP server as normal to the C:\Program Files\APP directory. This would be the app that connects to the serial port and does what you want via sockets.

Copy instsrv.exe to your C:\WINDOWS\system32 directory/

Copy SRVANY.EXE to C:\Program Files\YOURAPP

From command prompt, run this command – INSTSRV YOURAPP "C:\Program Files\YOURAPP\srvany.exe"

Run the Registry Editor (REGEDT.EXE)

Under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YOURAPP: create a ‘Parameters‘ key (folder)

Under the this key, create a REG_SZ string value called Application and add in this data C:\Program Files\YOURAPP\YOURAPP.exe

Close Regedit, then open the services console in administrative tools, or start, run, services.msc, confirm it is set to start automatically and the logon account is LocalSystem. Then unclick the Allow Service to Interact with Desktop. If you click this, it will interrupt you on Windows 7 boxes whenever it writes to the screen.

Start the service, check in Task Manager, you will see YOURAPP.exe inthere, and if you stop the service then YOURAPP.exe will disappear.

The long version

Details on this are at http://support.microsoft.com/kb/137890

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文