Accessing DDE client from a Windows Service

Jun 25, 2009 at 5:14 PM

Hi

I have created some code that can access a DDE server application perfectly from a windows application, but if I port the exact same code to a Windows Service it refuses to connect to the same DDE Server.

The code is here for your reference:

        Dim DummyExtension As String = ""

        Using client As DdeClient = New DdeClient("CLIENT", "sCTI")

        client.Connect()

        DummyExtension = client.Request("Txt_ExtensionNo", 60000)

 

Please if someone knows what the problems is I would very much appreciate some assistance.

Cheers Mike

Jun 26, 2009 at 3:39 AM

Hi Mike,

I had the same problem for ages and took a while to figure it out, I'm assuming your server is not runnig as a service?

Services run with seperate session id's (0 I believe) where as windows apps use anything above 0, this causes a communication error as the services are not 'visible' to the apps. In order to get it to work two things are possible

1. Go to Control Panel -> Administrative Tools -> Services. Find your service and open it's properties. On the LogOn tab check the 'Allow service to interact with desktop' checkbox or alternatively fill in the login details.

2. Run the server as a service as well as the client.

Aug 21, 2009 at 5:38 PM

Hi Koncept,

I tried #1 on Vista without success.  The Service that is trying to be a DDE client is default set to run in the "Local System Account", so I tried turning on the "Allow the service to interact with desktop" checkbox and the DDE client could not connect to the DDE server, but I did get a weird "the application is trying to send you a message" desktop event, but no dialog was found there, so something was trying to ask permission, I think.  So then I tried setting the Service to run in a specific account, but no joy.  Then I tried making the DDE server application run "As Administrator", but that didn't help.  Then I turned UAC off and that didn't help.  I'm running out of options.

The DDE server is a 3rd party Windows app, generally started by the user, so #2 maybe is not an option, though I could try to get the Service to spawn the DDE server windows application and see what happens. 

I seem to be stuck and any advice will be greatly appreciated.

Thanks.

Aug 21, 2009 at 6:20 PM

UPDATE: Just for fun, we tried #2, spawning the DDE server application using Process.Start and it works!  And if the end user also starts the DDE server application (which has a GUI) in the user's account, it appears and they can use it as they see fit.  This works for us.

Thanks!

 

Apr 4, 2013 at 1:57 PM
Hi,
I have done a project on DDE using NDde and it covers all the needs. I have developed a windows service which will do the required DDE operation. This was successful in Win xp machine. When I deployed my Application in Windows 7 64-bit OS i'm getting the error.

("The client failed to connect to "MLDdeSrvr|data". Make sure the server application is running and that it supports the specified service name and topic name pair.")

The same code is working correctly if I deploy the Application as windows Forms and run as administrator. I tried running the service in all user types but its unsuccessful.
Can anyone help me in solving the issue. Thanks in advance.
Apr 11, 2016 at 10:16 AM
Edited Apr 11, 2016 at 10:37 AM
CMC wrote:
so I tried turning on the "Allow the service to interact with desktop" checkbox and the DDE client could not connect to the DDE server, but I did get a weird "the application is trying to send you a message" desktop event, but no dialog was found there, so something was trying to ask permission, I think.
I've done the same and got "The *** service is marked as an interactive service. However, the system is configured to not allow interactive services. This service may not function properly." To fix that I had to set HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\NoInteractiveServices to 0 and start Interactive Services Detection service. And then the same, seems like hopeless situation.