locked
Have any WINAPI function which effect like CreateProcess(_T("\\Windows\\Beam.exe"),...) ? RRS feed

  • Question

  • Hi
    Have any  WINAPI function which effect like CreateProcess(_T("\\Windows\\Beam.exe"),...)  ?
    i need call this function in my app but not use CreateProcess.
    Have this winapi in windows mobile ? Thanks.

    Kabaeva
    Tuesday, April 7, 2009 10:04 AM

Answers

All replies

  • Hi,

    You can do this using P/Invokes etc.

    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    
    namespace WinMob5StandardCSharp
    {
        public partial class Form1 : Form
        {
    [DllImport("coredll.dll", SetLastError = true)]static extern bool CreateProcess(String imageName,        String cmdLine,        IntPtr lpProcessAttributes,        IntPtr lpThreadAttributes,        bool boolInheritHandles,        Int32 dwCreationFlags,        IntPtr lpEnvironment,        IntPtr lpszCurrentDir,        byte[] si,        IntPtr pi);
    public struct ProcessInfo
    {
        public IntPtr hProcess;
        public IntPtr hThread;
        public Int32 ProcessId;
        public Int32 ThreadId;
    }
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
                ProcessInfo pi = new ProcessInfo();
                IntPtr ptr_pi = Marshal.AllocHGlobal(Marshal.SizeOf(pi)); ;
                Marshal.StructureToPtr(pi, ptr_pi, true);
    
                byte[] si = new byte[128];
                bool result = CreateProcess("\\Windows\\iexplore.exe", 
                                            " ", 
                                            IntPtr.Zero, 
                                            IntPtr.Zero, 
                                            false, 
                                            0, 
                                            IntPtr.Zero, 
                                            IntPtr.Zero, 
                                            si, 
                                            ptr_pi);
    
                pi = (ProcessInfo)Marshal.PtrToStructure(ptr_pi, typeof(ProcessInfo));
    
            }
        }
    }




    Cheers.

    Tuesday, April 7, 2009 1:04 PM
  • ShellExecuteEx
    Alex Feinman. MVP .NET Compact Framework
    Wednesday, April 8, 2009 4:44 AM
  • i need call this function in my app but not use CreateProcess.


    D'oh!

    My response is surely a case of BDP (Brain Dead Programmer)...and RTQ (Read the Question).

    Sorry - I didn't spot the above caveat!

    W.
    Wednesday, April 8, 2009 8:36 AM