ReactOS 0.4.15-dev-7842-g558ab78
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 {
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
BOOL Error
Definition: chkdsk.c:66
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:93
FxAutoRegKey hKey
GLuint res
Definition: glext.h:9613
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static BOOL ProcessRunKeys(HKEY hkRoot, LPCWSTR szKeyName, BOOL bDelete, BOOL bSynchronous)
Definition: startup.c:289
const WCHAR runkeys_names[][30]
Definition: startup.c:219
EXTERN_C HRESULT WINAPI SHCreateSessionKey(REGSAM samDesired, PHKEY phKey)
Definition: shellreg.c:147
#define DEFAULT
Definition: startup.c:428
@ RUNKEY_RUNSERVICES
Definition: startup.c:216
@ RUNKEY_RUN
Definition: startup.c:216
@ RUNKEY_RUNONCE
Definition: startup.c:216
@ RUNKEY_RUNSERVICESONCE
Definition: startup.c:216
static const struct op_mask SESSION_START
Definition: startup.c:426
static const struct op_mask SETUP
Definition: startup.c:427
static BOOL pendingRename()
Definition: startup.c:69
static BOOL wininit()
Definition: startup.c:64
#define argv
Definition: mplay32.c:18
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_OPENED_EXISTING_KEY
Definition: nt_native.h:1085
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
HRESULT hr
Definition: shlfolder.c:183
structure holding startup flags
Definition: startup.c:416
#define wprintf(...)
Definition: whoami.c:18
#define GetWindowsDirectory
Definition: winbase.h:3792
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SetCurrentDirectory
Definition: winbase.h:3838
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegCreateKeyEx
Definition: winreg.h:501
#define SM_CLEANBOOT
Definition: winuser.h:1027
int WINAPI GetSystemMetrics(_In_ int)
char TCHAR
Definition: xmlstorage.h:189