Create profile directories.

svn path=/trunk/; revision=7528
This commit is contained in:
Eric Kohl 2004-01-09 19:52:01 +00:00
parent 27044f2ad0
commit a2e92f560f
8 changed files with 296 additions and 0 deletions

View file

@ -0,0 +1,10 @@
temp.exp
*.d
*.a
*.dll
*.lib
*.sym
*.coff
*.map
*.tmp
*.o

View file

@ -0,0 +1,15 @@
/* $Id: internal.h,v 1.1 2004/01/09 19:52:01 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/internal.h
* PURPOSE: internal stuff
* PROGRAMMER: Eric Kohl
*/
#ifndef _INTERNAL_H
#define _INTERNAL_H
#endif /* _INTERNAL_H */
/* EOF */

View file

@ -0,0 +1,28 @@
PATH_TO_TOP = ../..
TARGET_TYPE = dynlink
TARGET_NAME = userenv
TARGET_BASE = 0x74850000
TARGET_CFLAGS = -fno-builtin -D__USE_W32API
# require os code to explicitly request A/W version of structs/functions
TARGET_CFLAGS += -DUNICODE -D_UNICODE -Wall -Werror
TARGET_LFLAGS = -nostdlib -nostartfiles
TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_OBJECTS = setup.o userenv.o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk
# EOF

169
reactos/lib/userenv/setup.c Normal file
View file

@ -0,0 +1,169 @@
/* $Id: setup.c,v 1.1 2004/01/09 19:52:01 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/setup.c
* PURPOSE: Profile setup functions
* PROGRAMMER: Eric Kohl
*/
#include <windows.h>
#include <string.h>
#include <userenv.h>
#include "internal.h"
typedef struct _DIRDATA
{
BOOL Hidden;
LPWSTR DirName;
} DIRDATA, *PDIRDATA;
static DIRDATA
DefaultUserDirectories[] =
{
{TRUE, L"Application Data"},
{FALSE, L"Desktop"},
{FALSE, L"Favorites"},
{FALSE, L"My Documents"},
{TRUE, L"PrintHood"},
{TRUE, L"Recent"},
{FALSE, L"Start Menu"},
{FALSE, L"Start Menu\\Programs"},
{FALSE, NULL}
};
static DIRDATA
AllUsersDirectories[] =
{
{TRUE, L"Application Data"},
{FALSE, L"Desktop"},
{FALSE, L"Favorites"},
{FALSE, L"My Documents"},
{FALSE, L"Start Menu"},
{FALSE, L"Start Menu\\Programs"},
{FALSE, NULL}
};
static LPWSTR
AppendBackslash(LPWSTR String)
{
ULONG Length;
Length = lstrlenW (String);
if (String[Length - 1] != L'\\')
{
String[Length] = L'\\';
Length++;
String[Length] = (WCHAR)0;
}
return &String[Length];
}
BOOL WINAPI
InitializeProfiles (VOID)
{
WCHAR SystemRoot[MAX_PATH];
WCHAR Path[MAX_PATH];
LPWSTR Postfix;
LPWSTR Ptr;
PDIRDATA DirData;
/* Build profile name postfix */
if (!ExpandEnvironmentStringsW (L"%SystemRoot%",
SystemRoot,
MAX_PATH))
return FALSE;
SystemRoot[2] = L'.';
Postfix = &SystemRoot[2];
Ptr = Postfix;
while (*Ptr != (WCHAR)0)
{
if (*Ptr == L'\\')
*Ptr = '_';
Ptr++;
}
_wcsupr (Postfix);
/* Create 'Documents and Settings' directory */
if (!ExpandEnvironmentStringsW (L"%SystemDrive%\\Documents and Settings",
Path,
MAX_PATH))
return FALSE;
if (!CreateDirectoryW (Path, NULL))
return FALSE;
/* Create 'Default User' directory */
if (!ExpandEnvironmentStringsW (L"%SystemDrive%\\Documents and Settings\\Default User",
Path,
MAX_PATH))
return FALSE;
wcscat (Path, Postfix);
if (!CreateDirectoryW (Path, NULL))
return FALSE;
/* Set current user profile */
SetEnvironmentVariableW (L"USERPROFILE", Path);
/* Create default user subdirectories */
Ptr = AppendBackslash (Path);
DirData = &DefaultUserDirectories[0];
while (DirData->DirName != NULL)
{
wcscpy (Ptr, DirData->DirName);
if (!CreateDirectoryW (Path, NULL))
return FALSE;
if (DirData->Hidden == TRUE)
{
SetFileAttributesW (Path, FILE_ATTRIBUTE_HIDDEN);
}
DirData++;
}
/* Create 'All Users' directory */
if (!ExpandEnvironmentStringsW (L"%SystemDrive%\\Documents and Settings\\All Users",
Path,
MAX_PATH))
return FALSE;
wcscat (Path, Postfix);
if (!CreateDirectoryW (Path, NULL))
return FALSE;
/* Create all users subdirectories */
Ptr = AppendBackslash (Path);
DirData = &AllUsersDirectories[0];
while (DirData->DirName != NULL)
{
wcscpy (Ptr, DirData->DirName);
if (!CreateDirectoryW (Path, NULL))
return FALSE;
if (DirData->Hidden == TRUE)
{
SetFileAttributesW (Path, FILE_ATTRIBUTE_HIDDEN);
}
DirData++;
}
return TRUE;
}

View file

@ -0,0 +1,29 @@
/* $Id: userenv.c,v 1.1 2004/01/09 19:52:01 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/userenv/userenv.c
* PURPOSE: DLL initialization code
* PROGRAMMER: Eric Kohl
*/
#include <windows.h>
#include <userenv.h>
#include "internal.h"
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
}
else if (fdwReason == DLL_PROCESS_DETACH)
{
}
return TRUE;
}

View file

@ -0,0 +1,4 @@
LIBRARY userenv.dll
EXPORTS
InitializeProfiles@0
;EOF

View file

@ -0,0 +1,4 @@
LIBRARY userenv.dll
EXPORTS
InitializeProfiles=InitializeProfiles@0
;EOF

View file

@ -0,0 +1,37 @@
#include <windows.h>
#include <reactos/resource.h>
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
VS_VERSION_INFO VERSIONINFO
FILEVERSION 5,1,2600,0
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", RES_STR_COMPANY_NAME
VALUE "FileDescription", "User Environment DLL\0"
VALUE "FileVersion", "5.1.2600\0"
VALUE "InternalName", "userenv\0"
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
VALUE "OriginalFilename", "userenv.dll\0"
VALUE "ProductName", RES_STR_PRODUCT_NAME
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END