Ignore:
Timestamp:
Mar 3, 2000, 12:16:00 PM (25 years ago)
Author:
sandervl
Message:

moved registry apis into kernel32 + cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/initsystem.cpp

    r2973 r2984  
    1 /* $Id: initsystem.cpp,v 1.5 2000-03-02 19:17:21 sandervl Exp $ */
     1/* $Id: initsystem.cpp,v 1.6 2000-03-03 11:15:57 sandervl Exp $ */
    22/*
    33 * Odin system initialization (registry & directories)
     
    2727#include "dbglocal.h"
    2828
    29 static HINSTANCE hInstance = 0;
    30 
    3129BOOL InitRegistry();
    32 
    33 LONG (WIN32API *ADVAPI32_RegCloseKey)(HKEY) = 0;
    34 LONG (WIN32API *ADVAPI32_RegOpenKeyA)(HKEY,LPCSTR,LPHKEY) = 0;
    35 LONG (WIN32API *ADVAPI32_RegCreateKeyA)(HKEY,LPCSTR,LPHKEY) = 0;
    36 LONG (WIN32API *ADVAPI32_RegSetValueExA)(HKEY,LPSTR,DWORD,DWORD,LPBYTE,DWORD) = 0;
    3730
    3831//******************************************************************************
     
    4033BOOL InitSystemEnvironment(ULONG nrCPUs)
    4134{
    42    hInstance = LoadLibraryA("ADVAPI32.DLL");
    43    if(hInstance) {
    44         *(VOID **)&ADVAPI32_RegCloseKey=(void*)GetProcAddress(hInstance, (LPCSTR)"RegCloseKey");
    45         *(VOID **)&ADVAPI32_RegOpenKeyA=(void*)GetProcAddress(hInstance, (LPCSTR)"RegOpenKeyA");
    46         *(VOID **)&ADVAPI32_RegCreateKeyA=(void*)GetProcAddress(hInstance, (LPCSTR)"RegCreateKeyA");
    47         *(VOID **)&ADVAPI32_RegSetValueExA=(void*)GetProcAddress(hInstance, (LPCSTR)"RegSetValueExA");
    48    }
    4935   InitSystemInfo(nrCPUs);
    5036   return InitRegistry();
     
    6753 char  digbuf[16];
    6854
    69    if(ADVAPI32_RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\Windows",&hkey)!=ERROR_SUCCESS) {
     55   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\Windows",&hkey)!=ERROR_SUCCESS) {
    7056        dprintf(("InitRegistry: Unable to register system information\n"));
    7157        return FALSE;
    7258   }
    7359   buf = InternalGetWindowsDirectoryA();
    74    ADVAPI32_RegSetValueExA(hkey,"Directory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
     60   RegSetValueExA(hkey,"Directory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
    7561   buf = InternalGetSystemDirectoryA();
    76    ADVAPI32_RegSetValueExA(hkey,"SystemDirectory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
     62   RegSetValueExA(hkey,"SystemDirectory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
    7763   val = 0;
    78    ADVAPI32_RegSetValueExA(hkey,"ErrorMode",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
     64   RegSetValueExA(hkey,"ErrorMode",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
    7965   val = 0;
    80    ADVAPI32_RegSetValueExA(hkey,"NoInteractiveServices",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
     66   RegSetValueExA(hkey,"NoInteractiveServices",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
    8167   val = ODINNT_BUILD_NR;
    82    ADVAPI32_RegSetValueExA(hkey,"CSDVersion",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
    83    ADVAPI32_RegSetValueExA(hkey,"ShutdownTime",0,REG_DWORD, (LPBYTE)ShutdownTime, sizeof(ShutdownTime));
    84    ADVAPI32_RegCloseKey(hkey);
     68   RegSetValueExA(hkey,"CSDVersion",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
     69   RegSetValueExA(hkey,"ShutdownTime",0,REG_DWORD, (LPBYTE)ShutdownTime, sizeof(ShutdownTime));
     70   RegCloseKey(hkey);
    8571
    86    if(ADVAPI32_RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",&hkey)!=ERROR_SUCCESS) {
     72   if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",&hkey)!=ERROR_SUCCESS) {
    8773        dprintf(("InitRegistry: Unable to register system information (2)"));
    8874        return FALSE;
    8975   }
    9076   buf = InternalGetSystemDirectoryA();
    91    ADVAPI32_RegSetValueExA(hkey,"SystemRoot",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
    92    ADVAPI32_RegSetValueExA(hkey,"PathName",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
     77   RegSetValueExA(hkey,"SystemRoot",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
     78   RegSetValueExA(hkey,"PathName",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
    9379   sprintf(digbuf, "%d", ODINNT_BUILD_NR);
    94    ADVAPI32_RegSetValueExA(hkey,"CurrentBuildNumber",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
    95    ADVAPI32_RegSetValueExA(hkey,"CurrentType",0,REG_SZ, (LPBYTE)ODINNT_OSTYPE_UNI, sizeof(ODINNT_OSTYPE_UNI));
    96    ADVAPI32_RegSetValueExA(hkey,"CSDVersion",0,REG_SZ, (LPBYTE)ODINNT_CSDVERSION, sizeof(ODINNT_CSDVERSION));
    97    ADVAPI32_RegSetValueExA(hkey,"SoftwareType",0,REG_SZ, (LPBYTE)ODINNT_SOFTWARE_TYPE, sizeof(ODINNT_SOFTWARE_TYPE));
     80   RegSetValueExA(hkey,"CurrentBuildNumber",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
     81   RegSetValueExA(hkey,"CurrentType",0,REG_SZ, (LPBYTE)ODINNT_OSTYPE_UNI, sizeof(ODINNT_OSTYPE_UNI));
     82   RegSetValueExA(hkey,"CSDVersion",0,REG_SZ, (LPBYTE)ODINNT_CSDVERSION, sizeof(ODINNT_CSDVERSION));
     83   RegSetValueExA(hkey,"SoftwareType",0,REG_SZ, (LPBYTE)ODINNT_SOFTWARE_TYPE, sizeof(ODINNT_SOFTWARE_TYPE));
    9884
    9985   sprintf(digbuf, "%d.%d", ODINNT_MAJOR_VERSION, ODINNT_MINOR_VERSION);
    100    ADVAPI32_RegSetValueExA(hkey,"CurrentVersion",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
     86   RegSetValueExA(hkey,"CurrentVersion",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
    10187
    10288   val = (DWORD)time(NULL); //todo: Correct format???
    103    ADVAPI32_RegSetValueExA(hkey,"InstallDate",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
     89   RegSetValueExA(hkey,"InstallDate",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
    10490   
    105    ADVAPI32_RegCloseKey(hkey);
     91   RegCloseKey(hkey);
    10692   //todo: productid, registered org/owner, sourcepath,   
    10793
     
    121107   char shellpath[260];
    122108
    123    if(ADVAPI32_RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hkey) != ERROR_SUCCESS)
    124    {
    125         if(ADVAPI32_RegCreateKeyA(HKEY_CURRENT_USER,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",&hkey)!=ERROR_SUCCESS) {
    126                 dprintf(("InitRegistry: Unable to register system information (3)"));
    127                 return FALSE;
    128         }
     109   if(RegCreateKeyA(HKEY_CURRENT_USER,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",&hkey)!=ERROR_SUCCESS) {
     110        dprintf(("InitRegistry: Unable to register system information (3)"));
     111        return FALSE;
     112   }
     113//   if(RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hkey) != ERROR_SUCCESS)
     114//   {
    129115        strcpy(shellpath, InternalGetSystemDirectoryA());
    130         strcat(shellpath, "\\Favorites");
     116        strcat(shellpath, "\\WIN\\Favorites");
    131117        CreateDirectoryA(shellpath, NULL);
    132         ADVAPI32_RegSetValueExA(hkey,"Favorites",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     118        RegSetValueExA(hkey,"Favorites",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    133119        strcpy(shellpath, InternalGetSystemDirectoryA());
    134         strcat(shellpath, "\\Programs\\Startup");
     120        strcat(shellpath, "\\WIN\\Programs\\Startup");
    135121        CreateDirectoryA(shellpath, NULL);
    136         ADVAPI32_RegSetValueExA(hkey,"Startup",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     122        RegSetValueExA(hkey,"Startup",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    137123        strcpy(shellpath, InternalGetSystemDirectoryA());
    138         strcat(shellpath, "\\Desktop");
     124        strcat(shellpath, "\\WIN\\Desktop");
    139125        CreateDirectoryA(shellpath, NULL);
    140         ADVAPI32_RegSetValueExA(hkey,"Desktop",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     126        RegSetValueExA(hkey,"Desktop",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    141127        strcpy(shellpath, InternalGetSystemDirectoryA());
    142         strcat(shellpath, "\\Start Menu\\Programs");
     128        strcat(shellpath, "\\WIN\\Start Menu\\Programs");
    143129        CreateDirectoryA(shellpath, NULL);
    144         ADVAPI32_RegSetValueExA(hkey,"Programs",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     130        RegSetValueExA(hkey,"Programs",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    145131        strcpy(shellpath, InternalGetSystemDirectoryA());
    146         strcat(shellpath, "\\Fonts");
     132        strcat(shellpath, "\\WIN\\Fonts");
    147133        CreateDirectoryA(shellpath, NULL);
    148         ADVAPI32_RegSetValueExA(hkey,"Fonts",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     134        RegSetValueExA(hkey,"Fonts",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    149135        strcpy(shellpath, InternalGetSystemDirectoryA());
    150         strcat(shellpath, "\\SendTo");
     136        strcat(shellpath, "\\WIN\\SendTo");
    151137        CreateDirectoryA(shellpath, NULL);
    152         ADVAPI32_RegSetValueExA(hkey,"SendTo",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     138        RegSetValueExA(hkey,"SendTo",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    153139        strcpy(shellpath, InternalGetSystemDirectoryA());
    154         strcat(shellpath, "\\Start Menu");
     140        strcat(shellpath, "\\WIN\\Start Menu");
    155141        CreateDirectoryA(shellpath, NULL);
    156         ADVAPI32_RegSetValueExA(hkey,"Start Menu",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     142        RegSetValueExA(hkey,"Start Menu",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    157143        strcpy(shellpath, InternalGetSystemDirectoryA());
    158         strcat(shellpath, "\\ShellNew");
     144        strcat(shellpath, "\\WIN\\ShellNew");
    159145        CreateDirectoryA(shellpath, NULL);
    160         ADVAPI32_RegSetValueExA(hkey,"Templates",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     146        RegSetValueExA(hkey,"Templates",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    161147        strcpy(shellpath, InternalGetSystemDirectoryA());
    162         strcat(shellpath, "\\Recent");
     148        strcat(shellpath, "\\WIN\\Recent");
    163149        CreateDirectoryA(shellpath, NULL);
    164         ADVAPI32_RegSetValueExA(hkey,"Recent",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     150        RegSetValueExA(hkey,"Recent",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    165151        strcpy(shellpath, InternalGetSystemDirectoryA());
    166         strcat(shellpath, "\\NetHood");
     152        strcat(shellpath, "\\WIN\\NetHood");
    167153        CreateDirectoryA(shellpath, NULL);
    168         ADVAPI32_RegSetValueExA(hkey,"NetHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     154        RegSetValueExA(hkey,"NetHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    169155        strcpy(shellpath, InternalGetSystemDirectoryA());
    170         strcat(shellpath, "\\My Documents");
     156        strcat(shellpath, "\\WIN\\My Documents");
    171157        CreateDirectoryA(shellpath, NULL);
    172         ADVAPI32_RegSetValueExA(hkey,"Personal",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    173    }
    174    ADVAPI32_RegCloseKey(hkey);
     158        RegSetValueExA(hkey,"Personal",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
     159//   }
     160   RegCloseKey(hkey);
    175161   return TRUE;
    176162}
Note: See TracChangeset for help on using the changeset viewer.