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 "Run" in [All]

Enums

.
Summary
Indicates the execution contexts in which an object is to be run
.
Summary
A set of values from the COINIT enumeration is passed as the second parameter to CoInitializeEx. This value determines the concurrency model used for incoming calls to objects created by the thread making the call. However, since pinvoke is a dotNET construct you should be aware that dotNET already does a COM initialization and therefore calling a CoInitializeEx function most likely will not do what you expect. This problem occurs when trying to instantiate a COM object from within dotNET where the COM objects threading model is different from dotNETs. Search on Common Language Runtime or CLR and COINIT_APARTMENTTHREADED to find posts on this issue.
.

    using System.Runtime.InteropServices;

.

    using System.Runtime.InteropServices;

.

    ModesPruned = 0x8000000,

.

    ModesPruned = &H8000000

.

  [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential,Pack=4)]

.

      return System.Runtime.InteropServices.Marshal.GetExceptionForHR(hr);

.

    ///The class is configured to run as a security id different from the caller

.

    [Description("The class is configured to run as a security id different from the caller")]

.

    ///A RunAs specification must be &lt;domain name>\<user name> or simply &lt;user name>

.

    [Description("A RunAs specification must be <domain name>\\<user name> or simply <user name>")]

.

    public const int CO_E_RUNAS_SYNTAX = unchecked((int)0x80004017);

.

    public const int CO_E_RUNAS_CREATEPROCESS_FAILURE = unchecked((int)0x80004019);

.

    public const int CO_E_RUNAS_LOGON_FAILURE = unchecked((int)0x8000401A);

.

    ///The common language runtime is not available

.

    [Description("The common language runtime is not available")]

.

    ///Need to run the object to perform this operation

.

    [Description("Need to run the object to perform this operation")]

.

    public const int OLE_E_NOTRUNNING = unchecked((int)0x80040005);

.

    ///Application cannot be run more than once

.

    [Description("Application cannot be run more than once")]

.

    ///Message is too long; some of it had to be truncated before displaying

.

    [Description("Message is too long; some of it had to be truncated before displaying")]

.

    public const int INPLACE_S_TRUNCATED = unchecked((int)0x000401A0);

.

    ///Moniker is already registered in running object table

.

    [Description("Moniker is already registered in running object table")]

.

    ///The task is ready to run at its next scheduled time.

.

    [Description("The task is ready to run at its next scheduled time.")]

.

    ///The task is currently running.

.

    [Description("The task is currently running.")]

.

    public const int SCHED_S_TASK_RUNNING = unchecked((int)0x00041301);

.

    ///The task will not run at the scheduled times because it has been disabled.

.

    [Description("The task will not run at the scheduled times because it has been disabled.")]

.

    ///The task has not yet run.

.

    [Description("The task has not yet run.")]

.

    public const int SCHED_S_TASK_HAS_NOT_RUN = unchecked((int)0x00041303);

.

    ///There are no more runs scheduled for this task.

.

    [Description("There are no more runs scheduled for this task.")]

.

    public const int SCHED_S_TASK_NO_MORE_RUNS = unchecked((int)0x00041304);

.

    ///One or more of the properties that are needed to run this task on a schedule have not been set.

.

    [Description("One or more of the properties that are needed to run this task on a schedule have not been set.")]

.

    ///The last run of the task was terminated by the user.

.

    [Description("The last run of the task was terminated by the user.")]

.

    ///Event triggers don't have set run times.

.

    [Description("Event triggers don't have set run times.")]

.

    ///One or more of the properties that are needed to run this task have not been set.

.

    [Description("One or more of the properties that are needed to run this task have not been set.")]

.

    ///There is no running instance of the task to terminate.

.

    [Description("There is no running instance of the task to terminate.")]

.

    public const int SCHED_E_TASK_NOT_RUNNING = unchecked((int)0x8004130B);

.

    ///The task has been configured with an unsupported combination of account settings and run time options.

.

    [Description("The task has been configured with an unsupported combination of account settings and run time options.")]

.

    ///The Task Scheduler Service is not running.

.

    [Description("The Task Scheduler Service is not running.")]

.

    public const int SCHED_E_SERVICE_NOT_RUNNING = unchecked((int)0x80041315);

.

    //  See asn1code.h for a definition of the OSS runtime errors. The OSS

.

    ///OSS ASN.1 Error: Output buffer is too small, the decoded data has been truncated.

.

    [Description("OSS ASN.1 Error: Output buffer is too small, the decoded data has been truncated.")]

.

    ///The Smart card resource manager is not running.

.

    [Description("The Smart card resource manager is not running.")]

.

    ///The COM+ registry database is already running

.

    [Description("The COM+ registry database is already running")]

.

    public const int COMADMIN_E_REGDB_ALREADYRUNNING = unchecked((int)0x80110475);

.

    ///The specified application is not currently running

.

    [Description("The specified application is not currently running")]

.

    public const int COMADMIN_E_APP_NOT_RUNNING = unchecked((int)0x8011080A);

.

    ///COM+ applications that run as NT service may not be pooled or recycled

.

    [Description("COM+ applications that run as NT service may not be pooled or recycled")]

.

    ///Applications running as NT services may not be recycled.

.

    [Description("Applications running as NT services may not be recycled.")]

.

<System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential, Pack := 4)> _

.

        Return System.Runtime.InteropServices.Marshal.GetExceptionForHR(hr)

.

    '''The class is configured to run as a security id different from the caller

.

    <Description("The class is configured to run as a security id different from the caller")> _

.

    '''A RunAs specification must be &lt;domain name>\<user name> or simply &lt;user name>

.

    <Description("A RunAs specification must be <domain name>\<user name> or simply <user name>")> _

.

    Public Const CO_E_RUNAS_SYNTAX As Integer = CInt(&H80004017UI)

.

    Public Const CO_E_RUNAS_CREATEPROCESS_FAILURE As Integer = CInt(&H80004019UI)

.

    Public Const CO_E_RUNAS_LOGON_FAILURE As Integer = CInt(&H8000401aUI)

.

    '''The common language runtime is not available

.

    <Description("The common language runtime is not available")> _

.

    '''Need to run the object to perform this operation

.

    <Description("Need to run the object to perform this operation")> _

.

    Public Const OLE_E_NOTRUNNING As Integer = CInt(&H80040005UI)

.

    '''Application cannot be run more than once

.

    <Description("Application cannot be run more than once")> _

.

    '''Message is too long; some of it had to be truncated before displaying

.

    <Description("Message is too long; some of it had to be truncated before displaying")> _

.

    Public Const INPLACE_S_TRUNCATED As Integer = CInt(&H401a0)

.

    '''Moniker is already registered in running object table

.

    <Description("Moniker is already registered in running object table")> _

.

    '''The task is ready to run at its next scheduled time.

.

    <Description("The task is ready to run at its next scheduled time.")> _

.

    '''The task is currently running.

.

    <Description("The task is currently running.")> _

.

    Public Const SCHED_S_TASK_RUNNING As Integer = CInt(&H41301)

.

    '''The task will not run at the scheduled times because it has been disabled.

.

    <Description("The task will not run at the scheduled times because it has been disabled.")> _

.

    '''The task has not yet run.

.

    <Description("The task has not yet run.")> _

.

    Public Const SCHED_S_TASK_HAS_NOT_RUN As Integer = CInt(&H41303)

.

    '''There are no more runs scheduled for this task.

.

    <Description("There are no more runs scheduled for this task.")> _

.

    Public Const SCHED_S_TASK_NO_MORE_RUNS As Integer = CInt(&H41304)

.

    '''One or more of the properties that are needed to run this task on a schedule have not been set.

.

    <Description("One or more of the properties that are needed to run this task on a schedule have not been set.")> _

.

    '''The last run of the task was terminated by the user.

.

    <Description("The last run of the task was terminated by the user.")> _

.

    '''Event triggers don't have set run times.

.

    <Description("Event triggers don't have set run times.")> _

.

    '''One or more of the properties that are needed to run this task have not been set.

.

    <Description("One or more of the properties that are needed to run this task have not been set.")> _

.

    '''There is no running instance of the task to terminate.

.

    <Description("There is no running instance of the task to terminate.")> _

.

    Public Const SCHED_E_TASK_NOT_RUNNING As Integer = CInt(&H8004130bUI)

.

    '''The task has been configured with an unsupported combination of account settings and run time options.

.

    <Description("The task has been configured with an unsupported combination of account settings and run time options.")> _

.

    '''The Task Scheduler Service is not running.

.

    <Description("The Task Scheduler Service is not running.")> _

.

    Public Const SCHED_E_SERVICE_NOT_RUNNING As Integer = CInt(&H80041315UI)

.

    '  See asn1code.h for a definition of the OSS runtime errors. The OSS

.

    '''OSS ASN.1 Error: Output buffer is too small, the decoded data has been truncated.

.

    <Description("OSS ASN.1 Error: Output buffer is too small, the decoded data has been truncated.")> _

.

    '''The Smart card resource manager is not running.

.

    <Description("The Smart card resource manager is not running.")> _

.

    '''The COM+ registry database is already running

.

    <Description("The COM+ registry database is already running")> _

.

    Public Const COMADMIN_E_REGDB_ALREADYRUNNING As Integer = CInt(&H80110475UI)

.

    '''The specified application is not currently running

.

    <Description("The specified application is not currently running")> _

.

    Public Const COMADMIN_E_APP_NOT_RUNNING As Integer = CInt(&H8011080aUI)

.

    '''COM+ applications that run as NT service may not be pooled or recycled

.

    <Description("COM+ applications that run as NT service may not be pooled or recycled")> _

.

    '''Applications running as NT services may not be recycled.

.

    <Description("Applications running as NT services may not be recycled.")> _

.

    INSTALLSTATE_SOURCEABSENT = -4,  // run from source, source is unavailable

.

    INSTALLSTATE_SOURCE       =  4,  // run from source, CD or net

.

    ''' Run from source, source is unavailable.

.

    ''' Run from source, CD or net.

.

    DataOverrun = 0xc000003c,

.

    OF_CREATE    = 0x00001000,  // Creates a new file. If file exists, it is truncated to zero (0) length.

.

        /// <summary>664. The system has run out of memory. </summary>

.

        /// <summary>710. Serial overrun errors were detected while communicating with the modem. </summary>

.

        ERROR_OVERRUN,

.

        /// <summary>827. The L2TP/IPsec connection cannot be completed because the IKE and AuthIP IPSec Keying Modules service and/or the Base Filtering Engine service is not running. These services are required to establish an L2TP/IPSec connection. </summary>

.

    /// Application is currently running.

.

    RmStatusRunning = 0x1,

.

    /// One or more processes are running in another TS session.

12: SBSP
.

    SBSP_CALLERUNTRUSTED = 0x00800000,

.

            Run_Command = 3

.

        Run_Command = 3

.

    MinorUnstable = 0x00000006,

.

     MinorUnstable = &H6

15: STARTF
.

        STARTF_RUNFULLSCREEN = 0x00000020,  // ignored for non-x86 platforms

.

    STARTF_RUNFULLSCREEN = &H20

.

        /// input supported by a device running Windows 7 or Windows Server 2008 R2. For more information, see Remarks.

.
Summary
Specifies values that identify whether the font size of a highlighted text run should be incremented or decremented.
.

You should use System.Runtime.InteropServices.VarEnum instead.

.

using System.Runtime.InteropServices;

.

            Application.Run(new Form1());

.

     /// A null-terminated string that contains the name of the initial program that Remote Desktop Services runs when the user logs on.

.

     /// A null-terminated string that contains the published name of the application that the session is running.

cards

.

using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices;

.

>�b�%�kLf'm;�Dq���j�x�)a�d<:q�X�����2k�<��܈�=��V7RUN3����9��/��S��-��H d��: +ls���1o���

mapi32

.

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

misc

.

The rapi.dll section needs to be corrected. Rapi is not for running on the .NET Compact Framework, but rather for desktop applications. It does not appear possible to edit this part of the page.

.

There is also IE (6.0.2800.1106.xpsp2) bug: clicking "Edit This Page" brings up error message "A runtime error has occurred... Line: 15 Error: 'ButtonBar' is undefined". Harmless but annoying.

26: FAQ
.

using System.Runtime.InteropServices;

.

For pointer-sized entities such as handles, they must be defined such that they will be 32 bits on a 32-bit machine and 64 bits on a 64-bit machine. IntPtr (or UIntPtr) accomplishes this. The use of int will appear to be fine if you only run the code on a 32-bit machine, but will likely cause your application/component to crash as soon as it gets on a 64-bit machine.

advapi32

.

        int lastError = System.Runtime.InteropServices.Marshal.GetLastWin32Error();

.

You will need to reference System.Runtime.InteropServices

.

        ' do a "dry run" to get the size of the SID and Domain string

.

    SERVICE_RUNNING            = 0x00000004,

.

    SERVICE_RUNNING = &H4

.

using System.Runtime.InteropServices;

.

         ServiceBase.Run (new TestService());

.

  System.Runtime.InteropServices.Marshal.Copy(SID, 0, sidPtr, SID.Length);

.

  System.Runtime.InteropServices.Marshal.FreeHGlobal( sidPtr );

.

       sSID = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ptrSID)

.

       sSID = System.Runtime.InteropServices.Marshal.PtrToStringAuto(ptrSID)

.

     System.Runtime.InteropServices.Marshal.FreeHGlobal(ptrSID)

.
Summary
.
Summary
Starts a new process, opens an application in that process, and uses a passed UserID and Password. The application opened is running under the credentials and authority of the UserID passed.
.

Imports System.Runtime.InteropServices

.

    Console.WriteLine("Running ...")

.

using System.Runtime.InteropServices;

.

namespace RunAs

.

            Console.WriteLine("Running ...");

.
Note
For .NET 1.1, System.Diagnostics.Process only allows you to start processes that will run under the same user account as the process that created it.
.

For .NET 2.0, System.Diagnostics.Process.Start has new overloads that allows you to run under different user accounts.

.

    /// the right to change the executable file that the system runs,

.

    /// Service that runs in its own process.

.

    ''' the right to change the executable file that the system runs

.

    ''' Service that runs in its own process.

.

    $cred.target = [System.Runtime.InteropServices.Marshal]::StringToCoTaskMemUni('server')

.

        MAXIMUM_EX = (MAXIMUM + 1000),  // Allow new applications to run on old OSes

.

        public System.Runtime.InteropServices.ComTypes.FILETIME LastWritten;

.

            public System.Runtime.InteropServices.ComTypes.FILETIME LastWritten;

.

     //public System.Runtime.InteropServices.FILETIME lastWritten; // .NET 1.1

.

     public System.Runtime.InteropServices.ComTypes.FILETIME lastWritten; // .NET 2.0

.

     public System.Runtime.InteropServices.ComTypes.FILETIME lastWritten;

.

$cred.targetName = [System.Runtime.InteropServices.Marshal]::StringToCoTaskMemUni('server1')

.

$cred.userName = [System.Runtime.InteropServices.Marshal]::StringToCoTaskMemUni('domain\user')

.

$cred.credentialBlob = [System.Runtime.InteropServices.Marshal]::StringToCoTaskMemUni($password)

.

using System.Runtime.InteropServices;

.
Summary
The EnumDependentServices function retrieves the name and status of each service that depends on the specified service; that is, the specified service must be running before the dependent services can run.
.

    using System.Runtime.InteropServices;

.

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

.

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

.

using System.Runtime.InteropServices;

.

Runtime.InteropServices.Marshal.Copy(GetSidIdentifierAuthority(pSID), sia, 0, 6)

.

Dim pSID As IntPtr = Runtime.InteropServices.Marshal.AllocHGlobal(GetSidLengthRequired(iSubAuthorityCount))

.

Dim numSubAuthorities As Byte = Runtime.InteropServices.Marshal.ReadByte(GetSidSubAuthorityCount(pSID), 0)

.

Dim numSubAuthorities As Byte = Runtime.InteropServices.Marshal.ReadByte(GetSidSubAuthorityCount(pSID), 0)

.

using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices;

.

Imports System.Runtime.InteropServices

.

  Dim pSID As IntPtr = Runtime.InteropServices.Marshal.AllocHGlobal(GetSidLengthRequired(sidParts.Length - 1))

.
Summary
The LogonUserEx function attempts to log a user on to the local computer. The local computer is the computer from which LogonUserEx was called. You cannot use LogonUserEx to log on to a remote computer. You specify the user with a user name and domain, and authenticate the user with a plaintext password. If the function succeeds, you receive a handle to a token that represents the logged-on user. You can then use this token handle to impersonate the specified user or, in most cases, to create a process that runs in the context of the specified user.
.
Summary
The LogonUserEx function attempts to log a user on to the local computer. The local computer is the computer from which LogonUserEx was called. You cannot use LogonUserEx to log on to a remote computer. You specify the user with a user name and domain, and authenticate the user with a plaintext password. If the function succeeds, you receive a handle to a token that represents the logged-on user. You can then use this token handle to impersonate the specified user or, in most cases, to create a process that runs in the context of the specified user.
.

   using System.Runtime.InteropServices;

.

using System.Runtime.InteropServices;

.

    err = System.Runtime.InteropServices.Marshal.GetLastWin32Error();

.

        err = System.Runtime.InteropServices.Marshal.GetLastWin32Error();

.

The privileges that Windows knows about vary from one system to another. If you run your code on a Windows version other than the one you developed it on, you'll need to handle this one.

.

(Answer: Nobody knows why, but the runtime seems to screw it up)

.

using System.Runtime.InteropServices;

.

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

.

    using System.Runtime.InteropServices;

.

    using System.Runtime.CompilerServices;

.

I used a custom marshaler to live a happier life with the "own super special" string type that LSA uses. It marshals LSA_UNICODE_STRINGS to and from normal .NET strings. See "Alternate Sample Code" way below. However I'm quite new to p/invoke and this is my first custom marshaler ever, so please keep your eyes open for problems and bugs with my code. (A problem I had was CleanUpNativeData for data converted from managed to unmanaged aswell as for data converted from unmanaged to managed. Since I didn't allocate the data myself in the latter case my marshaler uses a hash table to keep track of the native data it allocated itself. Don't know if that's the correct way, however. Feel free to mail me at pi AT removethispart frohwalt removethisaswell DOT de for suggestions/corrections. ) Oh, by the way this also contains an example for LSARetrievePrivateData in case you want to read out some RunAs passwords from the LSA. (My goal is to ultimateley change them, not to read them )

.

(However, these won't do when you need to modify COM runas Passwords ...)

.

using System.Runtime.InteropServices;

.

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

.

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

.

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

.

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

.

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

.

        dw = System.Runtime.InteropServices.Marshal.GetLastWin32Error();

.

        dw = System.Runtime.InteropServices.Marshal.GetLastWin32Error();

.

          dw = System.Runtime.InteropServices.Marshal.GetLastWin32Error();

.

          dw = System.Runtime.InteropServices.Marshal.GetLastWin32Error();

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


 
Access PInvoke.net directly from VS: