I want to install a service to Service Manager and run it. My code is as follows:
using System;
using System.Runtime.InteropServices;
class Ana
{
static void Main()
{
IntPtr sc_handle=OpenSCManager(null,null,2);
IntPtr sv_handle = CreateService(sc_handle, "deneme", "deneme", 16, 16, 2, 0, @"D:\ServisDeneme2.exe", null, null, null, null, null);
int i=StartService(sv_handle,0,null);
CloseServiceHandle(sc_handle);
}
[DllImport("advapi32.dll")]
public static extern IntPtr OpenSCManager(string machine, string db, int parameter);
[DllImport("advapi32.dll")]
public static extern IntPtr CreateService(IntPtr SC_HANDLE, string lpSvcName, string lpDisplayName, int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl, string lpPathName, string lpLoadOrderGroup, object lpdwTagId, string lpDependencies, string lpServiceStartName, string lpPassword);
[DllImport("advapi32.dll")]
public static extern void CloseServiceHandle(IntPtr SCHANDLE);
[DllImport("advapi32.dll")]
public static extern int StartService(IntPtr SVHANDLE, int dwNumServiceArgs, string[] lpServiceArgVectors);
}
This code works perfectly on my 32 bit computer but does not work on 64 bit computer. How can I do the same work for 64 bit?