_TCHAR DependOnGroup[] = 'Parallel arbitrator ';
if (RegSetValueEx(mru, 'DependOnGroup', 0, REG_MULTI_SZ,
(CONST BYTE*)&DependOnGroup, strlen(DependOnGroup)+2) != ERROR_SUCCESS) {
AfxMessageBox('Could not create driver registry value DependOnGroup');
return;
}
// DependOnService
_TCHAR DependOnService[] = 'parport ';
if (RegSetValueEx(mru, 'DependOnService', 0, REG_MULTI_SZ,
(CONST BYTE*) &DependOnService, strlen(DependOnService)+2) != ERROR_SUCCESS) {
AfxMessageBox('Could not create driver registry value DependOnService');
return;
}
RegCloseKey(mru);
//////////////////////////////////////////////////////////////////
// Create/Open driverParameters registry key and set its values
if (RegCreateKeyEx(HKEY_LOCAL_MACHIME, 'SYSTEM\CurrentControlSet\Services\'+DriverName+'\Parameters',
0, '', 0, KEY_ALL_ACCESS, NULL, &mru, &disposition) != ERROR_SUCCESS) {
AfxMessageBox('Could not create driver\Parameters registry key');
return;
}
// EventLogLevel
dwRegValue = 1;
if (RegSetValueEx(mru, 'EventLogLevel', 0, REG_DWORD, (CONST BYTE*)&dwRegValue, sizeof(DWORD)) != ERROR_SUCCESS) {
AfxMessageBox('Could not create driver\Parameters registry value EventLogLevel');
return;
}
// Default or No Name
CString DefaultName = DriverName;
int DeviceNameLen = DefaultName.GetLength()+1;
LPTSTR lpDefaultName = DefaultName.GetBuffer(DeviceNameLen);
if (RegSetValueEx(mru, '', 0, REG_SZ, (CONST BYTE*)lpDefaultName, DeviceNameLen) != ERROR_SUCCESS) {
AfxMessageBox('Could not create driver\Parameters default registry value');
return;
}
DefaultName.ReleaseBuffer(0);
RegCloseKey(mru);
//////////////////////////////////////////////////////////////////
// Open EventLogSystem registry key and set its values
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Services\EventLog\System',
0, '', 0, KEY_ALL_ACCESS, NULL, &mru, &disposition) != ERROR SUCCESS) {
AfxMessageBox('Could not open EventLog\System registry key');
return;
}
// get Sources size
DWORD DataSize = 0;
DWORD Type;
if (RegQueryValueEx(mru, 'Sources', NULL, &Type, NULL, &DataSize) ! = ERROR_SUCCESS) {
AfxMessageBox('Could not read size of EventLog\System registry value Sources');
return;
}
// read Sources
int DriverNameLen = strlen(DriverName);
DataSize += DriverNameLen+1;
LPTSTR Sources = new _TCHAR[DataSize];
if (RegQueryValueEx(mru, 'Sources', NULL, &Type, (LPBYTE)Sources, &DataSize) != ERROR_SUCCESS) {
AfxMessageBox('Could not read EventLog\System registry value Sources');
return;
}
// If driver not there, add and write
if (FindInMultiSz(Sources, DataSize, DriverName )==-1) {
strcpy(Sources+DataSize-1,DriverName);
DataSize += DriverNameLen;
*(Sources+DataSize) = ' ';
if (RegSetValueEx(mru, 'Sources', 0, REG_MULTI_SZ, (CONST BYTE*)Sources.DataSize) != ERROR_SUCCESS) {
AfxMessageBox('Could not create driver registry value Sources');
return;
}
}
///////////////////////////////////////////////////////////////////
// Create/Open EventLogSystemdriver registry key and set its values
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Services\EventLog\System\'+DriverName,
0, '', 0, KEY_ALL_ACCESS, NULL, &mru, &disposition) != ERROR_SUCCESS) {
AfxMessageBox('Could not create EventLog\System\driver registry key');
return;
}
// TypesSupported dwRegValue = 7;
if (RegSetValueEx(mru,'TypesSupported', 0, REG_DWORD, (CONST BYTE*)&dwRegValue, sizeof(DWORD)) != ERROR_SUCCESS) {
AfxMessageBox('Could not create EventLog\System\driver registry value TypesSupported');
return;
}
// EventMessageFile
LPTSTR EventMessageFile = '%SystemRoot%\System32\IoLogMsg.dll;%SystemRoot%\System32\Drivers\'+DriverName+'.sys';
if (RegSetValueEx(mru, 'EventMessageFile', 0, REG_EXPAND_SZ,
(CONST BYTE*)EventMessageFile, strlen(EventMessageFile)+1) != ERROR_SUCCESS) {
AfxMessageBox('Could not create EventLog\System\driver registry value EventMessageFile');
return;
}
RegCloseKey(mru);
////////////////////////////////////////////////////////////////////
// Start driver service
if (!StartDriver(DriverName)) return;
}
////////////////////////////////////////////////////////////////