Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

STARTUPINFOA structure (processthreadsapi.h)

Feedback

In this article

Specifies the window station, desktop, standard handles, and appearance of the main window for a process at creation time.

Syntax

typedef struct _STARTUPINFOA {  DWORD  cb;  LPSTR  lpReserved;  LPSTR  lpDesktop;  LPSTR  lpTitle;  DWORD  dwX;  DWORD  dwY;  DWORD  dwXSize;  DWORD  dwYSize;  DWORD  dwXCountChars;  DWORD  dwYCountChars;  DWORD  dwFillAttribute;  DWORD  dwFlags;  WORD   wShowWindow;  WORD   cbReserved2;  LPBYTE lpReserved2;  HANDLE hStdInput;  HANDLE hStdOutput;  HANDLE hStdError;} STARTUPINFOA, *LPSTARTUPINFOA;

Members

cb

The size of the structure, in bytes.

lpReserved

Reserved; must be NULL.

lpDesktop

The name of the desktop, or the name of both the desktop and window station for this process. A backslash in the string indicates that the string includes both the desktop and window station names.

For more information, seeThread Connection to a Desktop.

lpTitle

For console processes, this is the title displayed in the title bar if a new console window is created. If NULL, the name of the executable file is used as the window title instead. This parameter must be NULL for GUI or console processes that do not create a new console window.

dwX

IfdwFlags specifies STARTF_USEPOSITION, this member is the x offset of the upper left corner of a window if a new window is created, in pixels. Otherwise, this member is ignored.

The offset is from the upper left corner of the screen. For GUI processes, the specified position is used the first time the new process callsCreateWindow to create an overlapped window if thex parameter ofCreateWindow is CW_USEDEFAULT.

dwY

IfdwFlags specifies STARTF_USEPOSITION, this member is the y offset of the upper left corner of a window if a new window is created, in pixels. Otherwise, this member is ignored.

The offset is from the upper left corner of the screen. For GUI processes, the specified position is used the first time the new process callsCreateWindow to create an overlapped window if they parameter ofCreateWindow is CW_USEDEFAULT.

dwXSize

IfdwFlags specifies STARTF_USESIZE, this member is the width of the window if a new window is created, in pixels. Otherwise, this member is ignored.

For GUI processes, this is used only the first time the new process callsCreateWindow to create an overlapped window if thenWidth parameter ofCreateWindow is CW_USEDEFAULT.

dwYSize

IfdwFlags specifies STARTF_USESIZE, this member is the height of the window if a new window is created, in pixels. Otherwise, this member is ignored.

For GUI processes, this is used only the first time the new process callsCreateWindow to create an overlapped window if thenHeight parameter ofCreateWindow is CW_USEDEFAULT.

dwXCountChars

IfdwFlags specifies STARTF_USECOUNTCHARS, if a new console window is created in a console process, this member specifies the screen buffer width, in character columns. Otherwise, this member is ignored.

dwYCountChars

IfdwFlags specifies STARTF_USECOUNTCHARS, if a new console window is created in a console process, this member specifies the screen buffer height, in character rows. Otherwise, this member is ignored.

dwFillAttribute

IfdwFlags specifies STARTF_USEFILLATTRIBUTE, this member is the initial text and background colors if a new console window is created in a console application. Otherwise, this member is ignored.

This value can be any combination of the following values: FOREGROUND_BLUE, FOREGROUND_GREEN, FOREGROUND_RED, FOREGROUND_INTENSITY, BACKGROUND_BLUE, BACKGROUND_GREEN, BACKGROUND_RED, and BACKGROUND_INTENSITY. For example, the following combination of values produces red text on a white background:

FOREGROUND_RED| BACKGROUND_RED| BACKGROUND_GREEN| BACKGROUND_BLUE

dwFlags

A bitfield that determines whether certainSTARTUPINFO members are used when the process creates a window. This member can be one or more of the following values.

ValueMeaning
STARTF_FORCEONFEEDBACK
0x00000040
Indicates that the cursor is in feedback mode for two seconds afterCreateProcess is called. The Working in Background cursor is displayed (see the Pointers tab in the Mouse control panel utility).

If during those two seconds the process makes the first GUI call, the system gives five more seconds to the process. If during those five seconds the process shows a window, the system gives five more seconds to the process to finish drawing the window.

The system turns the feedback cursor off after the first call toGetMessage, regardless of whether the process is drawing.

STARTF_FORCEOFFFEEDBACK
0x00000080
Indicates that the feedback cursor is forced off while the process is starting. The Normal Select cursor is displayed.
STARTF_PREVENTPINNING
0x00002000
Indicates that any windows created by the process cannot be pinned on the taskbar.

This flag must be combined with STARTF_TITLEISAPPID.

STARTF_RUNFULLSCREEN
0x00000020
Indicates that the process should be run in full-screen mode, rather than in windowed mode.

This flag is only valid for console applications running on an x86 computer.

STARTF_TITLEISAPPID
0x00001000
ThelpTitle member contains an AppUserModelID. This identifier controls how the taskbar andStart menu present the application, and enables it to be associated with the correct shortcuts and Jump Lists. Generally, applications will use theSetCurrentProcessExplicitAppUserModelID andGetCurrentProcessExplicitAppUserModelID functions instead of setting this flag. For more information, seeApplication User Model IDs.

If STARTF_PREVENTPINNING is used, application windows cannot be pinned on the taskbar. The use of any AppUserModelID-related window properties by the application overrides this setting for that window only.

This flag cannot be used with STARTF_TITLEISLINKNAME.

STARTF_TITLEISLINKNAME
0x00000800
ThelpTitle member contains the path of the shortcut file (.lnk) that the user invoked to start this process. This is typically set by the shell when a .lnk file pointing to the launched application is invoked. Most applications will not need to set this value.

This flag cannot be used with STARTF_TITLEISAPPID.

STARTF_UNTRUSTEDSOURCE
0x00008000
The command line came from an untrusted source. For more information, see Remarks.
STARTF_USECOUNTCHARS
0x00000008
ThedwXCountChars anddwYCountChars members contain additional information.
STARTF_USEFILLATTRIBUTE
0x00000010
ThedwFillAttribute member contains additional information.
STARTF_USEHOTKEY
0x00000200
ThehStdInput member contains additional information.

This flag cannot be used withSTARTF_USESTDHANDLES.

STARTF_USEPOSITION
0x00000004
ThedwX anddwY members contain additional information.
STARTF_USESHOWWINDOW
0x00000001
ThewShowWindow member contains additional information.
STARTF_USESIZE
0x00000002
ThedwXSize anddwYSize members contain additional information.
STARTF_USESTDHANDLES
0x00000100
ThehStdInput,hStdOutput, andhStdError members contain additional information.

If this flag is specified when calling one of the process creation functions, the handles must be inheritable and thefunction'sbInheritHandles parameter must be set to TRUE. For more information, seeHandle Inheritance.

If this flag is specified when calling theGetStartupInfo function, these members are either the handle value specified during process creation or INVALID_HANDLE_VALUE.

Handles must be closed withCloseHandle when they are no longer needed.

This flag cannot be used withSTARTF_USEHOTKEY.

wShowWindow

IfdwFlags specifies STARTF_USESHOWWINDOW, this member can be any of the values that can be specified in thenCmdShow parameter for theShowWindow function, except for SW_SHOWDEFAULT. Otherwise, this member is ignored.

For GUI processes, the first timeShowWindow is called, itsnCmdShow parameter is ignoredwShowWindow specifies the default value. In subsequent calls toShowWindow, thewShowWindow member is used if thenCmdShow parameter ofShowWindow is set to SW_SHOWDEFAULT.

cbReserved2

Reserved for use by the C Run-time; must be zero.

lpReserved2

Reserved for use by the C Run-time; must be NULL.

hStdInput

IfdwFlags specifies STARTF_USESTDHANDLES, this member is the standard input handle for the process. If STARTF_USESTDHANDLES is not specified, the default for standard input is the keyboard buffer.

IfdwFlags specifies STARTF_USEHOTKEY, this member specifies a hotkey value that is sent as thewParam parameter of aWM_SETHOTKEY message to the first eligible top-level window created by the application that owns the process. If the window is created with the WS_POPUP window style, it is not eligible unless the WS_EX_APPWINDOW extended window style is also set. For more information, seeCreateWindowEx.

Otherwise, this member is ignored.

hStdOutput

IfdwFlags specifies STARTF_USESTDHANDLES, this member is the standard output handle for the process. Otherwise, this member is ignored and the default for standard output is the console window's buffer.

If a process is launched from the taskbar or jump list, the system setshStdOutput to a handle to the monitor that contains the taskbar or jump list used to launch the process. For more information, see Remarks.Windows 7, Windows Server 2008 R2, Windows Vista, Windows Server 2008, Windows XP and Windows Server 2003:  This behavior was introduced in Windows 8 and Windows Server 2012.

hStdError

IfdwFlags specifies STARTF_USESTDHANDLES, this member is the standard error handle for the process. Otherwise, this member is ignored and the default for standard error is the console window's buffer.

Remarks

For graphical user interface (GUI) processes, this information affects the first window created by theCreateWindow function and shown by theShowWindow function. For console processes, this information affects the console window if a new console is created for the process. A process can use theGetStartupInfo function to retrieve theSTARTUPINFO structure specified when the process was created.

If a GUI process is being started and neither STARTF_FORCEONFEEDBACK or STARTF_FORCEOFFFEEDBACK is specified, the process feedback cursor is used. A GUI process is one whose subsystem is specified as "windows."

If a process is launched from the taskbar or jump list, the system setsGetStartupInfo to retrieve theSTARTUPINFO structure and check thathStdOutput is set. If so, useGetMonitorInfo to check whetherhStdOutput is a valid monitor handle (HMONITOR). The process can then use the handle to position its windows.

If theSTARTF_UNTRUSTEDSOURCE flag is specified, the application should be aware that the command line is untrusted. If this flag is set, applications should disable potentially dangerous features such as macros, downloaded content, and automatic printing. This flag is optional, but applications that callCreateProcess are encouraged to set this flag when launching a program with untrusted command line arguments (such as those provided by web content) so that the newly created process can apply appropriate policy.

TheSTARTF_UNTRUSTEDSOURCE flag is supported starting in Windows Vista, but it is not defined in the SDK header files prior to the Windows 10 SDK. To use the flag in versions prior to Windows 10, you can define it manually in your program.

Examples

The following code example shows the use ofStartUpInfoA.

#include <windows.h>#include <stdio.h>#include <tchar.h>void _tmain( int argc, TCHAR *argv[] ){    STARTUPINFO si;    PROCESS_INFORMATION pi;    ZeroMemory( &si, sizeof(si) );    si.cb = sizeof(si);    ZeroMemory( &pi, sizeof(pi) );    if( argc != 2 )    {        printf("Usage: %s [cmdline]\n", argv[0]);        return;    }    // Start the child process.     if( !CreateProcess( NULL,   // No module name (use command line)        argv[1],        // Command line        NULL,           // Process handle not inheritable        NULL,           // Thread handle not inheritable        FALSE,          // Set handle inheritance to FALSE        0,              // No creation flags        NULL,           // Use parent's environment block        NULL,           // Use parent's starting directory         &si,            // Pointer to STARTUPINFO structure        &pi )           // Pointer to PROCESS_INFORMATION structure    )     {        printf( "CreateProcess failed (%d).\n", GetLastError() );        return;    }    // Wait until child process exits.    WaitForSingleObject( pi.hProcess, INFINITE );    // Close process and thread handles.     CloseHandle( pi.hProcess );    CloseHandle( pi.hThread );}

For more information about this example, seeCreating Processes.

Note

The processthreadsapi.h header defines STARTUPINFO as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, seeConventions for Function Prototypes.

Requirements

RequirementValue
Minimum supported clientWindows XP [desktop apps only]
Minimum supported serverWindows Server 2003 [desktop apps only]
Headerprocessthreadsapi.h (include Windows.h on Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008 Windows Server 2008 R2)

See also

CreateProcess

CreateProcessAsUser

CreateProcessWithLogonW

CreateProcessWithTokenW

GetStartupInfo


Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?