如何在 Visual Studio 2010 中创建 C++ Windows 服务并与之通信? [英] How to create and communicate with a C++ Windows Service in Visual Studio 2010?

查看:91
本文介绍了如何在 Visual Studio 2010 中创建 C++ Windows 服务并与之通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个(某种)用 C++ 实现的数据库.现在我想创建一个用于查询它的 Windows 服务,因为 P 调用它不是一个选项,因为每个查询都必须加载数据库,这需要几分钟.

I have a (kind of) database implemented in C++. Now I want to create a Windows service for querying it, because P-invoking it is not an option, as the database would have to be loaded with every query, which takes several minutes.

但我面临几个问题:

  1. 如何在 VS2010 中创建 C++ Windows 服务?模板已被删除(为什么???),我可以使用 2008 模板并转换它吗?如果是:我在哪里可以找到这样的模板?

  1. How can I create a C++ Windows Service in VS2010? The template has been removed (why???), can I use a 2008 template and convert it? If yes: where do I find such a template?

假设我设法创建了一个 C++ Windows 服务:我有哪些选项可以与该服务进行通信(来自 CSharp)?有哪些优点/缺点?

Supposed I manage to create a C++ Windows service: what are my options to communicate with this sevice (from c sharp)? What are the advantages/disadvantages?

如果有任何提示,我会很高兴!

I'd be glad for any hint!

推荐答案

不知道为什么,模板真的没了.

I don't know why, but the template is really gone.

对于您的应用程序和服务 WCF 之间的通信将是一个选项.WCF 的优点之一是,您可以轻松切换传输层(HTTP、TCP、共享内存)

For communicating between your application and the service WCF would be an option. One advantage of WCF is, that you can easily switch the transport layer (HTTP, TCP, Shared Memory)

查看此 MSDN 页面.它准确描述了您要实现的目标:在 Windows 服务中托管 WCF 服务.它甚至在最后包含一个简单的 Windows 服务实现.不幸的是没有 C++ 而是 C#.

Have a look at this MSDN page. It describes exactly what you are trying to achieve: Host a WCF Service in a Windows Service. It even contains a simple Windows Service implementation at the end. Unfortunately no C++ but C#.

这篇关于如何在 Visual Studio 2010 中创建 C++ Windows 服务并与之通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆