STARTUPINFOEX

STARTUPINFOEX is a structure that specifies the window station, desktop, standard handles, and attributes for a new process.

Syntax

typedef struct STARTUPINFOEX {
    STARTUPINFO StartupInfo;
    PROC_THREAD_ATTRIBUTE_LIST lpAttributeList,
} STARTUPINFOEX, *LPSTARTUPINFOEX;

Enumerators

StartupInfo

A STARTUPINFO structure. Information on the STARTUPINFO structure is available from MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686331(v=vs.85).aspx.

lpAttributeList

An attribute list. This list is created by RtInitializeProceThreadAttributeList function.

Remarks

First, call RtInitializeProcThreadAttributeList with the dwAttributeCount parameter set to the maximum number of attributes you will be using, and set lpAttributeList to NULL. The function returns the required buffer size in bytes in the lpSize parameter. Allocate enough space for the data in the lpAttributeList buffer and call the function again to initialize the buffer.

To add attributes to the list, call the RtUpdateProcThreadAttribute function. To specify these attributes when creating a process, specify EXTENDED_STARTUPINFO_PRESENT in the dwCreationFlag parameter and a STARTUPINFOEX structure in the lpStartupInfo parameter. Note that you can specify the same STARTUPINFOEX structure to multiple child processes.

When you have finished using the list, call the RtDeleteProcThreadAttributeList function.

Requirements

Minimum Supported Version RTX64 2013
Header Rtapi.h

ClosedExample

#include "RtxStartupInfoEx.h"
		
		
void
_cdecl
wmain(
	int     argc,
	wchar_t **argv,
	wchar_t **envp
	)
{
	STARTUPINFOEX startupInfoEx = { 0 };
	PROCESS_INFORMATION processInformation = { 0 };
	SIZE_T attributeListSize = 0;
	ULONG idealProcessor = RtGetCurrentProcessorNumber();
	BOOL bRetVal = FALSE;
	startupInfoEx.StartupInfo.cb = sizeof(STARTUPINFOEX);
	 
		
	//
	//Request the size of the opaque attribute list for one attribute.
	//
	bRetVal = RtInitializeProcThreadAttributeList(NULL, 1, 0, &attributeListSize);
	if ( !bRetVal )
	{
		RtPrintf("RtInitializeProcThreadAttributeList failed to get the necessary size of the attribute list.");
		return;
	}
		
	//
	//Allocate the proper amount of memory.
	//
	startupInfoEx.lpAttributeList = (LPPROC_THREAD_ATTRIBUTE_LIST)malloc(attributeListSize);
	if ( !startupInfoEx.lpAttributeList )
	{
		RtPrintf("malloc failed.");
		return;
	}
	
	//
	//Initialize the opaque attribute list.
	//
	bRetVal = RtInitializeProcThreadAttributeList(startupInfoEx.lpAttributeList, 1, 0, &attributeListSize);
	if ( !bRetVal )
	{
		free(startupInfoEx.lpAttributeList);
		RtPrintf("RtInitializeProcThreadAttributeList failed to initialize the attribute list.");
		return;
	}
		
	//
	//Update the list with the extended attribute.
	//
	bRetVal = RtUpdateProcThreadAttribute(startupInfoEx.lpAttributeList,
	0,
	RT_PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR,
	&idealProcessor,
	sizeof(ULONG),
	NULL,
	NULL);
	if ( !bRetVal )
	{
		free(startupInfoEx.lpAttributeList);
		RtPrintf("RtUpdateProcThreadAttribute failed.");
		return;
	}
		
	//
	//Create the process.
	//
	bRetVal = RtCreateProcess(L"c:\\Example\\Example.rtss",
	NULL,
	NULL,
	NULL,
	FALSE,
	EXTENDED_STARTUPINFO_PRESENT,
	NULL,
	NULL,
	(LPSTARTUPINFO)&startupInfoEx,
	&processInformation);
	if ( !bRetVal )
	{
		free(startupInfoEx.lpAttributeList);
		RtPrintf("RtCreateProcess failed to create process.");
		return;
	}
	 
		
	//
	//Clean up internal opaque attribute list data.
	//
	RtDeleteProcThreadAttributeList(startupInfoEx.lpAttributeList);
	free(startupInfoEx.lpAttributeList);
		
	//
	//Cleanup RTX handles.
	//
	RtCloseHandle(processInformation.hThread);
	RtCloseHandle(processInformation.hProcess);
	ExitProcess(0);
}

See Also

RtInitializeProcThreadAttribute

RtUpdateProcThreadAttribute

RtDeleteProcThreadAttribute