Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Service interact with Windows MFC

Service interact with Windows MFC

Scheduled Pinned Locked Moved C#
helpcsharpquestionc++dotnet
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brunoconde
    wrote on last edited by
    #1

    Greetings!! I have been working on a project of a windows service and now i have a big problem. But after installing my new service i discover that the framework lib's don't work when the service starts ( when Windows Starts). I read about this problem in .NET and they say that only windows MFC Library is capable of this. I wonder if there is a class in c# for making possible the framework work on startup. In another way of explaining this my service starts but when I click on the service icon I don't get any result or sometimes I get Error when it shoud show a window I make. This is my problem::::::::::::::::::::::::::::::: Windows Service applications run in a different window station than the interactive station of the logged-on user. A window station is a secure object that contains a clipboard, a set of global atoms, and a group of desktop objects. Because the station of the Windows Service is not an interactive station, dialog boxes raised from within a Windows Service application will not be seen and may cause your program to stop responding. Similarly, error messages should be logged in the Windows event log rather than raised in the user interface. The Windows Service classes supported by the .NET Framework do not support interaction with interactive stations, that is, the logged-on user. The .NET Framework also does not include classes that represent stations and desktops. If your Windows Service must interact with other stations, you will need to access the unmanaged Windows API. For more information, see Window Stations and Desktops in the Platform SDK documentation. :::::::::::::::::::::::::::::::::::::::::::::: How can i resolve this??????????????????????? Please help me and sorry my bad English. :(( :confused:

    E S 2 Replies Last reply
    0
    • B brunoconde

      Greetings!! I have been working on a project of a windows service and now i have a big problem. But after installing my new service i discover that the framework lib's don't work when the service starts ( when Windows Starts). I read about this problem in .NET and they say that only windows MFC Library is capable of this. I wonder if there is a class in c# for making possible the framework work on startup. In another way of explaining this my service starts but when I click on the service icon I don't get any result or sometimes I get Error when it shoud show a window I make. This is my problem::::::::::::::::::::::::::::::: Windows Service applications run in a different window station than the interactive station of the logged-on user. A window station is a secure object that contains a clipboard, a set of global atoms, and a group of desktop objects. Because the station of the Windows Service is not an interactive station, dialog boxes raised from within a Windows Service application will not be seen and may cause your program to stop responding. Similarly, error messages should be logged in the Windows event log rather than raised in the user interface. The Windows Service classes supported by the .NET Framework do not support interaction with interactive stations, that is, the logged-on user. The .NET Framework also does not include classes that represent stations and desktops. If your Windows Service must interact with other stations, you will need to access the unmanaged Windows API. For more information, see Window Stations and Desktops in the Platform SDK documentation. :::::::::::::::::::::::::::::::::::::::::::::: How can i resolve this??????????????????????? Please help me and sorry my bad English. :(( :confused:

      E Offline
      E Offline
      EssOEss
      wrote on last edited by
      #2

      Well, you could make a program run when the user logs on and then use IPC to tell that program to pop up any windows you want. Not a very elegant solution, though - you'd have to make sure it runs for all users and even when users are added or removed... very messy. Or you could use PInvoke to access any native DLLs that might support this sort of thing. Depends on how the plain old Win32 services do it, I suppose.

      1 Reply Last reply
      0
      • B brunoconde

        Greetings!! I have been working on a project of a windows service and now i have a big problem. But after installing my new service i discover that the framework lib's don't work when the service starts ( when Windows Starts). I read about this problem in .NET and they say that only windows MFC Library is capable of this. I wonder if there is a class in c# for making possible the framework work on startup. In another way of explaining this my service starts but when I click on the service icon I don't get any result or sometimes I get Error when it shoud show a window I make. This is my problem::::::::::::::::::::::::::::::: Windows Service applications run in a different window station than the interactive station of the logged-on user. A window station is a secure object that contains a clipboard, a set of global atoms, and a group of desktop objects. Because the station of the Windows Service is not an interactive station, dialog boxes raised from within a Windows Service application will not be seen and may cause your program to stop responding. Similarly, error messages should be logged in the Windows event log rather than raised in the user interface. The Windows Service classes supported by the .NET Framework do not support interaction with interactive stations, that is, the logged-on user. The .NET Framework also does not include classes that represent stations and desktops. If your Windows Service must interact with other stations, you will need to access the unmanaged Windows API. For more information, see Window Stations and Desktops in the Platform SDK documentation. :::::::::::::::::::::::::::::::::::::::::::::: How can i resolve this??????????????????????? Please help me and sorry my bad English. :(( :confused:

        S Offline
        S Offline
        Sebastian Schneider
        wrote on last edited by
        #3

        Well, this depends on several conditions: Do you want your users to ALWAYS see pop-ups and information windows? Because that is not what a service should do. A service should run in the background unattended. IF you want your users to continously interact with your program, make it a windows-forms application. You can still "autostart" it via a registry entry. Do you simply need some feedback for debugging purposes and want non-critical errors to be described somewhere? Then use this.EventLog.WriteEntry. That will allow you to write some output to Windows' application event log. If you want an local user or administrator to be able to change the settings of your service, you could use an ini-File which holds configuration information, so someone could simply edit the file to change settings (or store those settings in the registry). If you need remote-configuration capabilities, have an asynchronous tcp socket waiting for connections on a certain port and use net.security or a simple user/password combination to restrict access. Then send commands and have your service react accordingly. You could even write a Windows-Forms App to communicate with your service. I chose the latter (ini-file and remote config) for my Windows Service. Cheers Sebastian

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups