Click here to Skip to main content
15,928,111 members
Home / Discussions / C#
   

C#

 
GeneralPanel control in a DLL Pin
Reinier van de Wetering6-Oct-04 4:48
Reinier van de Wetering6-Oct-04 4:48 
GeneralRe: Panel control in a DLL Pin
Jon G6-Oct-04 5:06
Jon G6-Oct-04 5:06 
GeneralRe: Panel control in a DLL Pin
Reinier van de Wetering6-Oct-04 19:47
Reinier van de Wetering6-Oct-04 19:47 
Generaldisplaying nested tables Pin
njaromack6-Oct-04 4:34
njaromack6-Oct-04 4:34 
GeneralRe: displaying nested tables Pin
njaromack6-Oct-04 10:36
njaromack6-Oct-04 10:36 
GeneralRe: displaying nested tables Pin
Heath Stewart6-Oct-04 13:16
protectorHeath Stewart6-Oct-04 13:16 
GeneralChange windows service logon account and password using c# Pin
Subin KJ6-Oct-04 4:31
Subin KJ6-Oct-04 4:31 
GeneralRe: Change windows service logon account and password using c# Pin
Heath Stewart6-Oct-04 12:57
protectorHeath Stewart6-Oct-04 12:57 
If you want to do this at install time, use a ServiceInstaller and ServiceProcessInstaller which allow you to set the logon account when a service is installed using installutil.exe or the AssemblyInstaller in your own code.

If you want to do this at runtime, you'll need to P/Invoke ChangeServiceConfig like in the following example:
[DllImport("advapi32.dll", CharSet=CharSet.Auto)]
static extern bool ChangeServiceControl(
  IntPtr hService,
  uint dwServiceType,
  uint dwStartType,
  uint dwErrorControl,
  string lpBinaryPathName,
  string lpLoadOrderGroup,
  ref uint lpdwTagId,
  string lpDependencies,
  string lpServiceStartName,
  string lpPassword,
  string lpDisplayName
);
To get the hService handle, you'll need to also P/Invoke OpenService or CreateService. The ServiceController does most of what you need but not in this case, so you're probably better off writing your own class to handle that. I would recommend using the dispose pattern to make sure that any handle you open using OpenService or CreateService is closed using CloseServiceHandle.

Read Service Functions[^] for more information.

You can also visit http://pinvoke.net[^] for many managed signatures for unmanaged functions.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles]
GeneralLogin Pin
pat2708816-Oct-04 4:31
pat2708816-Oct-04 4:31 
GeneralRe: Login Pin
Heath Stewart6-Oct-04 12:34
protectorHeath Stewart6-Oct-04 12:34 
GeneralRe: Login Pin
pat2708817-Oct-04 7:38
pat2708817-Oct-04 7:38 
GeneralRe: Login Pin
pat2708817-Oct-04 7:43
pat2708817-Oct-04 7:43 
Generalsetting datagrid cursors Pin
ddelapasse6-Oct-04 4:01
ddelapasse6-Oct-04 4:01 
Question.NET OLAP control? Pin
jvbragt6-Oct-04 2:29
jvbragt6-Oct-04 2:29 
AnswerRe: .NET OLAP control? Pin
Christian Wikander6-Oct-04 3:36
Christian Wikander6-Oct-04 3:36 
GeneralRe: .NET OLAP control? Pin
jvbragt6-Oct-04 3:59
jvbragt6-Oct-04 3:59 
Generalserialization problem Pin
ongo6-Oct-04 1:53
ongo6-Oct-04 1:53 
GeneralRe: serialization problem Pin
J4amieC6-Oct-04 2:26
J4amieC6-Oct-04 2:26 
GeneralRe: serialization problem Pin
ongo6-Oct-04 2:42
ongo6-Oct-04 2:42 
GeneralConvert base64String to byte[] in CrystalReport Pin
Pain_Elemental6-Oct-04 1:41
Pain_Elemental6-Oct-04 1:41 
GeneralRe: Convert base64String to byte[] in CrystalReport Pin
Alex Korchemniy6-Oct-04 7:56
Alex Korchemniy6-Oct-04 7:56 
GeneralGUI from Windows Service Pin
Jo Develper6-Oct-04 1:22
Jo Develper6-Oct-04 1:22 
GeneralRe: GUI from Windows Service Pin
Stefan Troschuetz6-Oct-04 1:30
Stefan Troschuetz6-Oct-04 1:30 
GeneralUsing C# dll in vb6 Pin
Zapss6-Oct-04 0:27
Zapss6-Oct-04 0:27 
GeneralRe: Using C# dll in vb6 Pin
Stefan Troschuetz6-Oct-04 1:10
Stefan Troschuetz6-Oct-04 1:10 

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.