Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "Service" in [All]

userenv

.

When a user logs on interactively, the system automatically loads the user's profile. If a service or an application impersonates a user, the system does not load the user's profile. Therefore, the service or application should load the user's profile with LoadUserProfile.

.

Services and applications that call LoadUserProfile should check to see if the user has a roaming profile. If the user has a roaming profile, specify its path as the lpProfilePath member of PROFILEINFO. To retrieve the user's roaming profile path, you can call the NetUserGetInfo function, specifying information level 3 or 4.

.

Upon successful return, the hProfile member of PROFILEINFO is a registry key handle opened to the root of the user's hive. It has been opened with full access (KEY_ALL_ACCESS). If a service that is impersonating a user needs to read or write to the user's registry file, use this handle instead of HKEY_CURRENT_USER. Do not close the hProfile handle. Instead, pass it to the UnloadUserProfile function. This function closes the handle. You should ensure that all handles to keys in the user's registry hive are closed. If you do not close all open registry handles, the user's profile fails to unload. For more information, see Registry Key Security and Access Rights and Registry Hives.

mapi32

.

Microsoft Important Note: MAPI32 is not supported in a managed environment, memory leaks may be seen. Use the current alternatives: System.Net.Mail or WebDav or Exhange 2007 webservice interface.

.

  <Runtime.InteropServices.DllImport("MAPI32.DLL", CharSet:=System.Runtime.InteropServices.CharSet.Ansi)> _

icmp

.

    using System.Runtime.InteropServices;

credui

.

    <System.Runtime.InteropServices.DllImport("credui.dll", EntryPoint:="CredUIPromptForWindowsCredentials", CharSet:=CharSet.Unicode)> <CLSCompliant(False)> _

kernel32

.

    public UInt16 wServicePackMajor;

.

    public UInt16 wServicePackMinor;

.

    Public wServicePackMajor As Integer

.

    Public wServicePackMinor As Integer

.

using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices; // Needed for the DllImport Attribute

.

using System.Runtime.InteropServices;

.

  using System.Runtime.InteropServices;

.

This implements a Mutex using a Null DACL (with all the security problems with that). This allows the Mutex to be sharable cross-process. In my implementation I access this Mutex from both ASP.Net and a Windows service running under different ids.

.

using System.Runtime.InteropServices;

.

[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.I1)]

.

using System.Runtime.InteropServices;

.

    [DllImport("kernel32", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]

.

    [DllImport("kernel32", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]

.

    [DllImport("kernel32", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]

.

using System.Runtime.InteropServices;

.

   Imports System.Runtime.InteropServices

.

Sample and signature code originally used System.Runtime.InteropServices.FILETIME, but this uses ints instead of uints (DWORDs) meaning that this line:

.

  using System.Runtime.InteropServices;

.

    using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices;

.

    <System.Runtime.InteropServices.DllImport("Kernel32.dll", EntryPoint:="FormatMessageW", SetLastError:=True, CharSet:=System.Runtime.InteropServices.CharSet.Unicode)>

.

    <System.Runtime.InteropServices.DllImport("Kernel32.dll", SetLastError:=True)>

.

    'so Runtime.InteropServices.Marshal.GetLastWin32Error() returns a valid error

.

    Dim nLastError As Integer = Runtime.InteropServices.Marshal.GetLastWin32Error

.

    Dim sRet As String = Runtime.InteropServices.Marshal.PtrToStringAuto(lpMsgBuf, dwChars)

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]

.

        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]

.

    using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices;

.

            throw new System.Runtime.InteropServices.ExternalException(" GetExitCodeProcess Error " + lastError, lastError);

.

[System.Runtime.InteropServices.Marshal.GetLastWin32Error]

.

using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices;

.

Imports System.Runtime.InteropServices

.

using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices;

.

Imports System.Runtime.InteropServices

.

This API becomes a lot more interesting in .NET v2.0 because the System.Runtime.InteropServices.Marshal class gains a new API called GetDelegateForFunctionPointer(). This means that you will be able to write code like this:

.

    System.Runtime.InteropServices.FILETIME ftCreation, ftExit, ftKernel, ftUser;

.

    out System.Runtime.InteropServices.FILETIME lpCreationTime,

.

    out System.Runtime.InteropServices.FILETIME lpExitTime,

.

    out System.Runtime.InteropServices.FILETIME lpKernelTime,

.

    out System.Runtime.InteropServices.FILETIME lpUserTime);

.

public static DateTime FiletimeToDateTime(System.Runtime.InteropServices.FILETIME fileTime)

.

public static TimeSpan FiletimeToTimeSpan(System.Runtime.InteropServices.FILETIME fileTime)

.

Here's something that worked for me, the 0,0 for the service pack is what they used at MSN...

.

using System.Runtime.InteropServices;

.

Imports System.Runtime.InteropServices

.

          <MarshalAs(Runtime.InteropServices.UnmanagedType.U4)> ByVal bufferSize As Integer) As Integer

.

      <Runtime.InteropServices.DllImport("kernel32.dll", SetLastError:=True, CharSet:=Runtime.InteropServices.CharSet.Auto)> _

.

      <Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.LPTStr)> _

.

      <Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.U4)> _

.

using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices; // Necessary!

.

using System.Runtime.InteropServices;

.

using FILETIME=System.Runtime.InteropServices.ComTypes.FILETIME;

.

      throw new Exception("Win32 Error: " + System.Runtime.InteropServices.Marshal.GetLastWin32Error());

.

Imports System.Runtime.InteropServices

.

  Imports System.Runtime.InteropServices

.

Imports System.Runtime.InteropServices

.

  Imports System.Runtime.InteropServices

.

[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]

.

using System.Runtime.InteropServices;

.

[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]

.

using System.Runtime.InteropServices;

.

[System.Runtime.InteropServices.Marshal.AllocHGlobal]

.

[System.Runtime.InteropServices.Marshal.FreeHGlobal]

.

using System.Runtime.InteropServices;

.

    [StructLayout(LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Auto)]

.

using System.Runtime.InteropServices;

.

Imports System.Runtime.InteropServices

.

    using System.Runtime.InteropServices;

.
Summary
The RegisterServiceProcess function registers or unregisters a service process. A service process continues to run after the user logs off.
.

private extern static void RegisterServiceProcess(long dwProcessId, long dwType);

.

Declare Function RegisterServiceProcess Lib "kernel32.dll" (TODO) As TODO

.

Does Not work with XP and higher OS. "RegisterServiceProcess" is not part of Kernel32.dll

.
Documentation
[RegisterServiceProcess] on MSDN
.

using System.Runtime.InteropServices;    // for StructLayout

.

using System.Runtime.InteropServices;

.

<System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError:=True)> _

.

using System.Runtime.InteropServices; //u need that for DLL IMPPORT

.

    using System.Runtime.InteropServices;

.

Imports System.Runtime.InteropServices

.

  <Runtime.InteropServices.DllImport("kernel32.dll", CharSet:=Runtime.InteropServices.CharSet.Auto, CallingConvention:=Runtime.InteropServices.CallingConvention.StdCall)> _

.

using System.Runtime.InteropServices;

.

Be sure to include in the header: using System.Runtime.InteropServices;

Cut off search results after 60. Please refine your search.


 
Access PInvoke.net directly from VS: