ReactOS  0.4.14-dev-77-gd9e7c48
shellservices.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SSOThread
 

Functions

int startup (int argc, const char *argv[])
 

Function Documentation

◆ startup()

int startup ( int  argc,
const char argv[] 
)

Definition at line 430 of file startup.c.

431 {
432  struct op_mask ops; /* Which of the ops do we want to perform? */
433  /* First, set the current directory to SystemRoot */
434  TCHAR gen_path[MAX_PATH];
435  DWORD res;
436  HKEY hSessionKey, hKey;
437  HRESULT hr;
438 
439  res = GetWindowsDirectory(gen_path, sizeof(gen_path));
440 
441  if (res==0)
442  {
443  printf("Couldn't get the windows directory - error %ld\n",
444  GetLastError());
445 
446  return 100;
447  }
448 
449  if (!SetCurrentDirectory(gen_path))
450  {
451  wprintf(L"Cannot set the dir to %s (%ld)\n", gen_path, GetLastError());
452 
453  return 100;
454  }
455 
456  hr = SHCreateSessionKey(KEY_WRITE, &hSessionKey);
457  if (SUCCEEDED(hr))
458  {
459  LONG Error;
460  DWORD dwDisp;
461 
462  Error = RegCreateKeyEx(hSessionKey, L"StartupHasBeenRun", 0, NULL, REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp);
463  RegCloseKey(hSessionKey);
464  if (Error == ERROR_SUCCESS)
465  {
466  RegCloseKey(hKey);
467  if (dwDisp == REG_OPENED_EXISTING_KEY)
468  {
469  /* Startup programs has already been run */
470  return 0;
471  }
472  }
473  }
474 
475  if (argc > 1)
476  {
477  switch(argv[1][0])
478  {
479  case 'r': /* Restart */
480  ops = SETUP;
481  break;
482  case 's': /* Full start */
483  ops = SESSION_START;
484  break;
485  default:
486  ops = DEFAULT;
487  break;
488  }
489  } else
490  ops = DEFAULT;
491 
492  /* do not run certain items in Safe Mode */
493  if(GetSystemMetrics(SM_CLEANBOOT)) ops.startup = FALSE;
494 
495  /* Perform the ops by order, stopping if one fails, skipping if necessary */
496  /* Shachar: Sorry for the perl syntax */
497  res = TRUE;
498  if (res && !ops.ntonly && ops.preboot)
499  res = wininit();
500  if (res && !ops.w9xonly && ops.preboot)
501  res = pendingRename();
502  if (res && !ops.ntonly && ops.prelogin)
504  if (res && !ops.ntonly && ops.prelogin && ops.startup)
506  if (res && ops.postlogin)
508  if (res && ops.postlogin && ops.startup)
510  if (res && ops.postlogin && ops.startup)
512  if (res && ops.postlogin && ops.startup)
514 
515  printf("Operation done\n");
516 
517  return res ? 0 : 101;
518 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
static const struct op_mask SETUP
Definition: startup.c:427
static BOOL wininit()
Definition: startup.c:64
HRESULT hr
Definition: shlfolder.c:183
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static BOOL ProcessRunKeys(HKEY hkRoot, LPCWSTR szKeyName, BOOL bDelete, BOOL bSynchronous)
Definition: startup.c:289
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define REG_OPENED_EXISTING_KEY
Definition: nt_native.h:1085
#define wprintf(...)
Definition: whoami.c:18
#define argv
Definition: mplay32.c:18
static const struct op_mask SESSION_START
Definition: startup.c:426
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define DEFAULT
Definition: startup.c:428
#define SM_CLEANBOOT
Definition: winuser.h:1017
#define KEY_WRITE
Definition: nt_native.h:1031
char TCHAR
Definition: xmlstorage.h:189
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
EXTERN_C HRESULT WINAPI SHCreateSessionKey(REGSAM samDesired, PHKEY phKey)
Definition: shellreg.c:151
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Error
Definition: chkdsk.c:66
static const WCHAR L[]
Definition: oid.c:1250
static BOOL pendingRename()
Definition: startup.c:69
const WCHAR runkeys_names[][30]
Definition: startup.c:219
GLuint res
Definition: glext.h:9613
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
#define GetWindowsDirectory
Definition: winbase.h:3674
#define RegCreateKeyEx
Definition: winreg.h:501
#define SetCurrentDirectory
Definition: winbase.h:3720
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define printf
Definition: config.h:203
structure holding startup flags
Definition: startup.c:416
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by _tWinMain(), ConfigFileHandler_startElement(), crash_and_debug(), crash_and_winedbg(), create_io_inherit_block(), create_server_process(), do_parent(), do_register_dll(), run_child(), run_client(), run_process(), SHELL_ExecuteW(), START_TEST(), test___getmainargs_parent(), test_comctl32_classes(), test_CommandLine(), test_Console(), test_CreateProcessWithDesktop(), test_debug_heap(), test_DebuggingFlag(), test_DetachConsoleHandles(), test_DetachStdHandles(), test_Directory(), test_Environment(), test_ExitCode(), test_file_inherit(), test_invalid_stdin(), test_LresultFromObject(), test_NonExistentPath(), test_NtSuspendProcess(), test_process_security(), test_Startup(), test_StartupNoConsole(), test_stdout_handle(), test_SuspendFlag(), test_token_security_descriptor(), test_Toolhelp(), test_WaitForInputIdle(), test_window_from_point(), test_winproc_handles(), and xsltTimestamp().