source: trunk/src/kernel32/initsystem.cpp@ 3005

Last change on this file since 3005 was 3005, checked in by sandervl, 25 years ago

DosOpen (file handle error) & dll destruction bugfixes

File size: 7.0 KB
Line 
1/* $Id: initsystem.cpp,v 1.7 2000-03-04 19:52:36 sandervl Exp $ */
2/*
3 * Odin system initialization (registry & directories)
4 *
5 *
6 * NOTE: Most of this has to be moved into the Odin install program!!!!!
7 *
8 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
9 *
10 */
11
12#include <os2win.h>
13#include <ctype.h>
14#include <string.h>
15#include "winreg.h"
16#include "global.h"
17#include "winnt.h"
18#include "winerror.h"
19#include "winreg.h"
20#include "debugtools.h"
21#include "cpuhlp.h"
22#include "initsystem.h"
23#include "directory.h"
24#include <versionos2.h>
25
26#define DBG_LOCALLOG DBG_initsystem
27#include "dbglocal.h"
28
29BOOL InitRegistry();
30
31//******************************************************************************
32//******************************************************************************
33BOOL InitSystemEnvironment(ULONG nrCPUs)
34{
35 InitSystemInfo(nrCPUs);
36 return InitRegistry();
37}
38//******************************************************************************
39//[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows]
40//"Directory"=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,00
41//"SystemDirectory"=hex(2):25,53,79,73,74,65,6d,52,6f,6f,74,25,5c,73,79,73,74,65,\
42// 6d,33,32,00
43//"ErrorMode"=dword:00000000
44//"NoInteractiveServices"=dword:00000000
45//"CSDVersion"=dword:00000300
46BYTE ShutdownTime[] = {0x44,0x5e,0xf2,0xbb,0x84,0x41,0xbf,0x01};
47//******************************************************************************
48BOOL InitRegistry()
49{
50 HKEY hkey;
51 char *buf;
52 DWORD val;
53 char digbuf[16];
54
55 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\Windows",&hkey)!=ERROR_SUCCESS) {
56 dprintf(("InitRegistry: Unable to register system information\n"));
57 return FALSE;
58 }
59 buf = InternalGetWindowsDirectoryA();
60 RegSetValueExA(hkey,"Directory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
61 buf = InternalGetSystemDirectoryA();
62 RegSetValueExA(hkey,"SystemDirectory",0,REG_BINARY, (LPBYTE)buf, strlen(buf)+1);
63 val = 0;
64 RegSetValueExA(hkey,"ErrorMode",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
65 val = 0;
66 RegSetValueExA(hkey,"NoInteractiveServices",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
67 val = ODINNT_BUILD_NR;
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);
71
72 if(RegCreateKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",&hkey)!=ERROR_SUCCESS) {
73 dprintf(("InitRegistry: Unable to register system information (2)"));
74 return FALSE;
75 }
76 buf = InternalGetSystemDirectoryA();
77 RegSetValueExA(hkey,"SystemRoot",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
78 RegSetValueExA(hkey,"PathName",0,REG_SZ, (LPBYTE)buf, strlen(buf)+1);
79 sprintf(digbuf, "%d", ODINNT_BUILD_NR);
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));
84
85 sprintf(digbuf, "%d.%d", ODINNT_MAJOR_VERSION, ODINNT_MINOR_VERSION);
86 RegSetValueExA(hkey,"CurrentVersion",0,REG_SZ, (LPBYTE)digbuf, strlen(digbuf)+1);
87
88 val = (DWORD)time(NULL); //todo: Correct format???
89 RegSetValueExA(hkey,"InstallDate",0,REG_DWORD, (LPBYTE)&val, sizeof(DWORD));
90
91 RegCloseKey(hkey);
92 //todo: productid, registered org/owner, sourcepath,
93
94 //Create Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders keys
95 //"Favorites"="C:\WINDOWS\Favorites"
96 //"StartUp"="C:\WINDOWS\Start Menu\Programs\Startup"
97 //"Desktop"="C:\WINDOWS\Desktop"
98 //"Programs"="C:\WINDOWS\Start Menu\Programs"
99 //"Fonts"="C:\WINDOWS\Fonts"
100 //"SendTo"="C:\WINDOWS\SendTo"
101 //"Start Menu"="C:\WINDOWS\Start Menu"
102 //"Templates"="C:\WINDOWS\ShellNew"
103 //"Recent"="C:\WINDOWS\Recent"
104 //"NetHood"="C:\WINDOWS\NetHood"
105 //"Personal"="C:\My Documents"
106
107 char shellpath[260];
108
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// {
115 strcpy(shellpath, InternalGetWindowsDirectoryA());
116 strcat(shellpath, "\\Favorites");
117 CreateDirectoryA(shellpath, NULL);
118 RegSetValueExA(hkey,"Favorites",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
119 strcpy(shellpath, InternalGetWindowsDirectoryA());
120 strcat(shellpath, "\\Programs\\Startup");
121 CreateDirectoryA(shellpath, NULL);
122 RegSetValueExA(hkey,"Startup",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
123 strcpy(shellpath, InternalGetWindowsDirectoryA());
124 strcat(shellpath, "\\Desktop");
125 CreateDirectoryA(shellpath, NULL);
126 RegSetValueExA(hkey,"Desktop",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
127 strcpy(shellpath, InternalGetWindowsDirectoryA());
128 strcat(shellpath, "\\Start Menu\\Programs");
129 CreateDirectoryA(shellpath, NULL);
130 RegSetValueExA(hkey,"Programs",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
131 strcpy(shellpath, InternalGetWindowsDirectoryA());
132 strcat(shellpath, "\\Fonts");
133 CreateDirectoryA(shellpath, NULL);
134 RegSetValueExA(hkey,"Fonts",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
135 strcpy(shellpath, InternalGetWindowsDirectoryA());
136 strcat(shellpath, "\\SendTo");
137 CreateDirectoryA(shellpath, NULL);
138 RegSetValueExA(hkey,"SendTo",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
139 strcpy(shellpath, InternalGetWindowsDirectoryA());
140 strcat(shellpath, "\\Start Menu");
141 CreateDirectoryA(shellpath, NULL);
142 RegSetValueExA(hkey,"Start Menu",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
143 strcpy(shellpath, InternalGetWindowsDirectoryA());
144 strcat(shellpath, "\\ShellNew");
145 CreateDirectoryA(shellpath, NULL);
146 RegSetValueExA(hkey,"Templates",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
147 strcpy(shellpath, InternalGetWindowsDirectoryA());
148 strcat(shellpath, "\\Recent");
149 CreateDirectoryA(shellpath, NULL);
150 RegSetValueExA(hkey,"Recent",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
151 strcpy(shellpath, InternalGetWindowsDirectoryA());
152 strcat(shellpath, "\\NetHood");
153 CreateDirectoryA(shellpath, NULL);
154 RegSetValueExA(hkey,"NetHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
155 strcpy(shellpath, InternalGetWindowsDirectoryA());
156 strcat(shellpath, "\\My Documents");
157 CreateDirectoryA(shellpath, NULL);
158 RegSetValueExA(hkey,"Personal",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
159// }
160 RegCloseKey(hkey);
161 return TRUE;
162}
163//******************************************************************************
164//******************************************************************************
Note: See TracBrowser for help on using the repository browser.