Click here to Skip to main content
15,909,742 members
Home / Discussions / C#
   

C#

 
GeneralRe: windows not in focus Pin
Heinzzy17-Jan-10 5:38
Heinzzy17-Jan-10 5:38 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 5:43
michaelgr117-Jan-10 5:43 
GeneralRe: windows not in focus Pin
Heinzzy17-Jan-10 5:50
Heinzzy17-Jan-10 5:50 
AnswerRe: windows not in focus Pin
wjp_auhtm17-Jan-10 5:27
wjp_auhtm17-Jan-10 5:27 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 5:28
michaelgr117-Jan-10 5:28 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 18:33
wjp_auhtm17-Jan-10 18:33 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 20:06
michaelgr117-Jan-10 20:06 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 21:24
wjp_auhtm17-Jan-10 21:24 
You could install the windows service like this, if u are using .Net FrameWork 3.5.

I found that the file named "System.Configuration.Install.dll" in .Net 2.0 is different from the .Net 3.5's.

There are some simple code.
using System.ServiceProcess;
using System.Configuration.Install;
using System.Collections;

            /// <summary>
            /// TODO: Is the service is existed and return true or false.
            /// </summary>
            /// <param name=" NameService ">Name of the windows service.</param>
            /// <returns>If the service is existed then return true,or return false.</returns>
            private bool isServiceIsExisted(string NameService) 
            {
                ServiceController[] services = ServiceController.GetServices();
                foreach (ServiceController s in services) 
                {
                    if (s.ServiceName.ToLower() == NameService.ToLower()) 
                    {
                        return true;
                    }
                }
                return false;
            }

            /// <summary>
            /// TODO: Install windows service.
            /// </summary>
            /// <param name="stateSaver">Collection(default is Null)</param>
            /// <param name="filepath">Full path of the windows service file</param>
            private void InstallmyService(IDictionary stateSaver, string filepath)
            {
                AssemblyInstaller AssemblyInstaller1 = new AssemblyInstaller();
                AssemblyInstaller1.UseNewContext = true;
                AssemblyInstaller1.Path = filepath;
                AssemblyInstaller1.Install(stateSaver);
                AssemblyInstaller1.Commit(stateSaver);
                AssemblyInstaller1.Dispose();
            }
            /// <summary>
            /// TODO: Uninstall windows service.
            /// </summary>
            /// <param name="filepath">Full path of the windows service file</param>
            private void UnInstallmyService(string filepath)
            {
                AssemblyInstaller AssemblyInstaller1 = new AssemblyInstaller();
                AssemblyInstaller1.UseNewContext = true;
                AssemblyInstaller1.Path = filepath;
                AssemblyInstaller1.Uninstall(null);
                AssemblyInstaller1.Dispose();
            }

Good Luck!
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 21:35
michaelgr117-Jan-10 21:35 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 21:57
wjp_auhtm17-Jan-10 21:57 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 22:00
michaelgr117-Jan-10 22:00 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 22:26
wjp_auhtm17-Jan-10 22:26 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 22:39
michaelgr117-Jan-10 22:39 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 22:57
wjp_auhtm17-Jan-10 22:57 
GeneralRe: windows not in focus Pin
Heinzzy18-Jan-10 3:51
Heinzzy18-Jan-10 3:51 
GeneralRe: windows not in focus Pin
wjp_auhtm18-Jan-10 14:21
wjp_auhtm18-Jan-10 14:21 
GeneralRe: windows not in focus Pin
Ravi Bhavnani17-Jan-10 9:26
professionalRavi Bhavnani17-Jan-10 9:26 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 18:41
wjp_auhtm17-Jan-10 18:41 
AnswerRe: windows not in focus Pin
Heinzzy17-Jan-10 5:47
Heinzzy17-Jan-10 5:47 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 6:40
michaelgr117-Jan-10 6:40 
QuestionHow to reject changes between two equal DataTables? Pin
obarahmeh16-Jan-10 21:13
obarahmeh16-Jan-10 21:13 
AnswerRe: How to reject changes between two equal DataTables? Pin
dan!sh 16-Jan-10 21:20
professional dan!sh 16-Jan-10 21:20 
QuestionUSB read Pin
michaelgr116-Jan-10 20:39
michaelgr116-Jan-10 20:39 
AnswerRe: USB read Pin
Alex Manolescu16-Jan-10 21:24
Alex Manolescu16-Jan-10 21:24 
QuestionMicrosoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server ‘\\.\pipe\3F103E6E-3FD4-47\tsql\query’ Pin
Mohammad Dayyan16-Jan-10 20:28
Mohammad Dayyan16-Jan-10 20:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.