Other Languages - Create process - Asked By gungun saini on 18-Nov-11 04:21 AM

Hello All,
         
        Is it possible to create process in VC++ without using <System.dll>.








Regards,

Roopa saini
Reena Jain replied to gungun saini on 18-Nov-11 04:31 AM
hi,

regasm.exe(Assembly Registration Tool) makes changes to the Windows Registry, so if you want to start regasm.exe as elevated process you could use the following code:

#include "stdafx.h"
#include "windows.h"
#include "shellapi.h"
 
int _tmain(int argc, _TCHAR* argv[])
{
    SHELLEXECUTEINFO shExecInfo;
 
    shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
 
    shExecInfo.fMask = NULL;
    shExecInfo.hwnd = NULL;
    shExecInfo.lpVerb = L"runas";
    shExecInfo.lpFile = L"regasm.exe";
    shExecInfo.lpParameters = L"testdll /tlb:test.tlb /codebase";
    shExecInfo.lpDirectory = NULL;
    shExecInfo.nShow = SW_NORMAL;
    shExecInfo.hInstApp = NULL;
 
    ShellExecuteEx(&shExecInfo);
 
    return 0;
}

shExecInfo.lpVerb = L"runas" means that process will be started with elevated privileges. If you don't want that just set shExecInfo.lpVerb to NULL. But under Vista or Windows 7 it's required administrator rights to change some parts of Windows Registry

for more information check this
http://www.codeproject.com/KB/cpp/9505Yamaha_1.aspx
http://www.codeproject.com/KB/cpp/kill_process.aspx
Suchit shah replied to gungun saini on 18-Nov-11 05:02 AM

I think No because of following reason :

if you want to start the Process using Process.Start Method which can be derived from the Namespace called
Namespace: System.Diagnostics which use the Assembly called
Assembly: System (in System.dll)

So due to this it is not possibly and even System.Diagnostics Namespace we will use because The System.Diagnostics namespace provides classes that allow you to interact with system processes, event logs, and performance counters.
• The EventLog component provides functionality to write to event logs, read event log entries, and create and delete event logs and event sources on the network. The EntryWrittenEventHandler provides a way to interact with event logs asynchronously. Supporting classes provide access to more detailed control, including: permission restrictions, the ability to specify event log types (which controls the type of default data that is written with an event log entry), and iterate through collections of event log entries. For more information about these tasks, see the EventLogPermission, EventLogEntryType, and EventLogEntryCollection classes.

• The Process class provides functionality to monitor system processes across the network, and to start and stop local system processes. In addition to retrieving lists of running processes (by specifying either the computer, the process name, or the process id) or viewing information about the process that currently has access to the processor, you can get detailed knowledge of process threads and modules both through the Process class itself, and by interacting with the ProcessThread and ProcessModule classes. The ProcessStartInfo class enables you to specify a variety of elements with which to start a new process, such as input, output, and error streams, working directories, and command line verbs and arguments. These give you fine control over the behavior of your processes. Other related classes let you specify window styles, process and thread priorities, and interact with collections of threads and modules.

• The PerformanceCounter class enables you to monitor system performance, while the PerformanceCounterCategory class provides a way to create new custom counters and categories. You can write to local custom counters and read from both local and remote counters (system as well as custom). You can sample counters using the PerformanceCounter class, and calculate results from successive performance counter samples using the CounterSample class. The CounterCreationData class enables you to create multiple counters in a category and specify their types. Other classes associated with the performance counter component provide access to collections of counters, counter permission, and counter types.