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
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy

Search Results for "ProcessInfo" in [All]

wtsapi32

.

    ref IntPtr ppProcessInfo, // pointer to array of WTS_PROCESS_INFO

.

     ByRef ppProcessInfo As IntPtr, _

.

    IntPtr pProcessInfo = IntPtr.Zero;

.

    if (!WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE, 0, 1, ref pProcessInfo, ref processCount))

.

    IntPtr pMemory = pProcessInfo;

.

    WTS_PROCESS_INFO[] processInfos = new WTS_PROCESS_INFO[processCount];

.

        processInfos[i] = (WTS_PROCESS_INFO)Marshal.PtrToStructure(pProcessInfo, typeof(WTS_PROCESS_INFO));

.

        pProcessInfo = (IntPtr)((long)pProcessInfo + Marshal.SizeOf(processInfos[i]));

.

    return processInfos;

.

Dim strucProcessInfo As WTS_PROCESS_INFO

.

Dim ptrProcessInfo As IntPtr

.

intReturn = WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE, 0, 1, ptrProcessInfo, intProcessCount)

.

    lngPtrPos = ptrProcessInfo.ToInt32()

.

        strucProcessInfo = Marshal.PtrToStructure(New IntPtr(lngPtrPos), strucProcessInfo.GetType)

.

        strProcessName = Marshal.PtrToStringAnsi(New IntPtr(strucProcessInfo.ProcessName))

.

        Console.WriteLine ("Process ID: " & strucProcessInfo.ProcessID)

.

        Console.WriteLine ("Session ID: " & strucProcessInfo.SessionID)

.

        lngPtrPos = lngPtrPos + Len(strucProcessInfo)

.

Call WTSFreeMemory(ptrProcessInfo)

ntdll

.

static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, IntPtr processInformation, uint processInformationLength, IntPtr returnLength);

.

static extern int NtQueryInformationProcess(IntPtr hProcess, PROCESSINFOCLASS pic, out PROCESS_BASIC_INFORMATION pbi, int cb, out int pSize);

.

public static extern void NtQueryInformationProcess(IntPtr ProcessHandle, PROCESSINFOCLASS ProcessInformationClass, out PROCESS_EXTENDED_BASIC_INFORMATION ProcessInformation, uint ProcessInformationLength, out uint ReturnLength);

.

   processHandle As IntPtr, processInformationClass As Integer, _

.

   processInformation As IntPtr, processInformationLength As Integer, _

.

     processInformationClass as PROCESSINFOCLASS,

.

     ref processInformation as PROCESS_BASIC_INFORMATION,

.

     processInformationLength as UInt32,

.

[PROCESSINFOCLASS], [PROCESS_BASIC_INFORMATION], [PROCESS_EXTENDED_BASIC_INFORMATION]

.

enum PROCESSINFOCLASS:

.

     MaxProcessInfoClass = 0x64

.

            int queryStatus = NtQueryInformationProcess(hProc, (PROCESSINFOCLASS)0, ref pbi, pbi.Size, out sizeInfoReturned);

.

     ref ProcessInformation64 as PROCESS_BASIC_INFORMATION64,

.

     ProcessInformationLength as UInt32,

.

private enum PROCESSINFOCLASS

.

    ProcessChildProcessInformation          = 0x49,

.

    MaxProcessInfoClass             = 0x64

.

Declare Function PROCESSINFOCLASS Lib "ntdll.dll" (TODO) As TODO

.

ProcessChildProcessInformation = 0x49

.

MaxProcessInfoClass = 0x64

.
Documentation
[PROCESSINFOCLASS] on MSDN
.

    SystemProcessInformation                  = 0x05,

.

    SystemSessionProcessInformation               = 0x35,

.

    SystemExtendedProcessInformation              = 0x39,

.

    SystemFullProcessInformation              = 0x94,

advapi32

.

    out PROCESS_INFORMATION lpProcessInformation);

.

    ByRef lpProcessInformation As PROCESS_INFORMATION) As Boolean

.

                           <Out()> ByRef lpProcessInformation As PROCESS_INFORMATION) As <MarshalAs(UnmanagedType.Bool)> Boolean

.

     out ProcessInformation     processInformation);

.

    Public Function CreateProcessWithLogonW(ByVal userName As String, ByVal domain As String, ByVal password As String, ByVal logonFlags As UInt32, ByVal applicationName As String, ByVal commandLine As String, ByVal creationFlags As UInt32, ByVal environment As UInt32, ByVal currentDirectory As String, ByRef startupInfo As StartupInfo, ByRef processInformation As ProcessInformation) As Boolean

.

    Friend Structure ProcessInformation

.

    End Structure 'ProcessInformation

.

    Public Function CreateProcessWithLogonW(ByVal userName As String, ByVal domain As String, ByVal password As String, ByVal logonFlags As UInt32, ByVal applicationName As String, ByVal commandLine As String, ByVal creationFlags As UInt32, ByVal environment As UInt32, ByVal currentDirectory As String, ByRef startupInfo As StartupInfo, ByRef processInformation As ProcessInformation) As Boolean

.

    Dim processInfo As New ProcessInformation

.

        currentDirectory, startupInfo, processInfo)

.

    WaitForSingleObject(processInfo.process, Infinite)

.

    GetExitCodeProcess(processInfo.process, exitCode)

.

    CloseHandle(processInfo.process)

.

    CloseHandle(processInfo.thread)

.

        internal struct ProcessInformation

.

            out  ProcessInformation processInformation);

.

            ProcessInformation processInfo = new ProcessInformation();

.

                    out processInfo);

.

            WaitForSingleObject(processInfo.process, Infinite);

.

            GetExitCodeProcess(processInfo.process, ref exitCode);

.

            CloseHandle(processInfo.process);

.

            CloseHandle(processInfo.thread);

Structures

.

public static extern bool CreateProcessWithTokenW(IntPtr hToken, LogonFlags dwLogonFlags, string lpApplicationName, string lpCommandLine, CreationFlags dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, [In] ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation);

.

        out PROCESS_INFORMATION lpProcessInformation);

.

    Public Shared Function CreateProcessWithTokenW(hToken As IntPtr, dwLogonFlags As Integer, lpApplicationName As String, lpCommandLine As String, dwCreationFlags As Integer, lpEnvironment As IntPtr, lpCurrentDirectory As IntPtr, ByRef lpStartupInfo As STARTUPINFO, ByRef lpProcessInformation As PROCESS_INFORMATION) As Boolean

.

  public CREATE_PROCESS_DEBUG_INFO CreateProcessInfo

coredll

.

    out ProcessInfo lpProcessInformation

.

public struct ProcessInfo

.

You will need the above ProcessInfo class and may also want to use GetLastError and WaitForSingleObject.

.

ProcessInfo pi; // no new required since ProcessInfo is a value type (struct)

.

    ProcessInfo pi = new ProcessInfo();

.

private static bool CreateProcessWait( String ExeName, String CmdLine, ProcessInfo pi, out uint retCode ){

.

    pi = new ProcessInfo();

.

    struct PROCESSINFO

.

Declare Function ProcessInfo Lib "coredll.dll" (TODO) As TODO

.
Documentation
[ProcessInfo] on MSDN
.

Both of the below examples assume that pi is an instnace of a ProcessInfo class. Examples of the ProcessInfo class can be found on the CreateProcess page.

kernel32

.

   out PROCESS_INFORMATION lpProcessInformation);

.

    <[Out]> ByRef lpProcessInformation As PROCESS_INFORMATION) As Boolean

.

    ref lpProcessInformation as PROCESS_INFORMATION) as bool:

.

lpProcessInformation);


 
Access PInvoke.net directly from VS: