--- a/Win32OperatingSystem.st Thu May 27 14:07:16 1999 +0200
+++ b/Win32OperatingSystem.st Thu May 27 18:13:23 1999 +0200
@@ -34,7 +34,7 @@
!
Object subclass:#RegistryEntry
- instanceVariableNames:'handle'
+ instanceVariableNames:'path handle'
classVariableNames:'Lobby HKEY_CLASSES_ROOT HKEY_CURRENT_USER HKEY_LOCAL_MACHINE
HKEY_USERS HKEY_PERFORMANCE_DATA HKEY_CURRENT_CONFIG HKEY_DYN_DATA'
poolDictionaries:''
@@ -2478,21 +2478,19 @@
DWORD endStatus;
int status = -1;
- if (__isExternalAddress(aProcessId) )
- {
+ if (__isExternalAddress(aProcessId)) {
HANDLE handle = _HANDLEVal(aProcessId);
- if (handle)
- {
- endStatus = WaitForSingleObject(handle , INFINITE );
- if ( endStatus != WAIT_FAILED )
- {
- if (GetExitCodeProcess(handle,&endStatus))
- {
- status = endStatus;
- printf("getexitcode status = %d\n",status);
+ if (handle) {
+ endStatus = WaitForSingleObject(handle , INFINITE);
+ if (endStatus != WAIT_FAILED) {
+ if (GetExitCodeProcess(handle,&endStatus)) {
+ status = endStatus;
+#ifdef PROCESSDEBUGWIN32
+ fprintf(stderr, "getexitcode status = %d\n",status);
+ } else {
+ fprintf(stderr, "getexitcode failed.\n");
+#endif
}
- else
- printf("getexitcode failed.\n");
}
}
RETURN ( __MKSMALLINT(status));
@@ -5850,27 +5848,27 @@
I added this in order to be able to shutdown w95 cleanly"
confirmationMessageOrNil notNil ifTrue:[
- (Dialog confirm:confirmationMessageOrNil) ifFalse:[
- ^ false
- ].
+ (Dialog confirm:confirmationMessageOrNil) ifFalse:[
+ ^ false
+ ].
].
%{
int flag;
if (how == @symbol(shutdown)) {
- flag = EWX_SHUTDOWN;
+ flag = EWX_SHUTDOWN;
} else if (how == @symbol(reboot)) {
- flag = EWX_REBOOT;
+ flag = EWX_REBOOT;
} else if (how == @symbol(logoff)) {
- flag = EWX_LOGOFF;
+ flag = EWX_LOGOFF;
} else if (how == @symbol(forceShutdown)) {
- flag = EWX_SHUTDOWN | EWX_FORCE;
+ flag = EWX_SHUTDOWN | EWX_FORCE;
} else if (how == @symbol(forceReboot)) {
- flag = EWX_REBOOT | EWX_FORCE;
+ flag = EWX_REBOOT | EWX_FORCE;
} else if (how == @symbol(forceLogoff)) {
- flag = EWX_LOGOFF | EWX_FORCE;
+ flag = EWX_LOGOFF | EWX_FORCE;
} else {
- RETURN (false);
+ RETURN (false);
}
RETURN ((ExitWindowsEx(flag, 0) == TRUE) ? true : false);
%}
@@ -6819,7 +6817,7 @@
keyVal := self rootKeyValueFor:aRootKeyStringOrSymbol.
keyVal isNil ifTrue:[^ nil].
"/ rootKeys are not registered for RegClose ...
- ^ self basicNew setHandle:keyVal
+ ^ self basicNew setHandle:keyVal path:aRootKeyStringOrSymbol.
"
RegistryEntry rootKey:#'HKEY_LOCAL_MACHINE'
@@ -6853,7 +6851,7 @@
^ root
].
- ^ root subKey:rest.
+ ^ root subKeyNamed:rest.
"
self key:'HKEY_LOCAL_MACHINE'
@@ -6863,6 +6861,12 @@
"
! !
+!Win32OperatingSystem::RegistryEntry methodsFor:'accessing'!
+
+path
+ ^ path.
+! !
+
!Win32OperatingSystem::RegistryEntry methodsFor:'accessing subkeys'!
remoteKeyOnHost:hostName
@@ -6882,7 +6886,7 @@
}
%}.
remoteHandle notNil ifTrue:[
- newEntry := self class basicNew setHandle:remoteHandle.
+ newEntry := self class basicNew setHandle:remoteHandle path:path.
Lobby register:newEntry.
^ newEntry.
].
@@ -6915,7 +6919,50 @@
!
-subKey:subKeyString
+subKeyAtIndex:subKeyIndex
+ "return a new registry entry below mySelf for the given subKey index.
+ Return nil if no such key exists"
+
+ |newEntry subHandle subKeyName subKeyClassName|
+
+%{
+ HKEY myKey, subKey = 0;
+ char nameBuffer[256];
+ DWORD nameSize = sizeof(nameBuffer) - 1;
+ char classNameBuffer[256];
+ DWORD classNameSize = sizeof(classNameBuffer) - 1;
+ FILETIME modificationTime;
+
+ if (__isExternalAddress(__INST(handle))
+ && __isSmallInteger(subKeyIndex)) {
+ myKey = (HKEY)__externalAddressVal(__INST(handle));
+ if (RegEnumKeyEx(myKey, __intVal(subKeyIndex),
+ nameBuffer, &nameSize,
+ NULL,
+ classNameBuffer, &classNameSize,
+ &modificationTime) == ERROR_SUCCESS) {
+ nameBuffer[nameSize] = '\0';
+ classNameBuffer[classNameSize] = '\0';
+printf("name=%s class=%s\n", nameBuffer, classNameBuffer);
+ subKeyName = __MKSTRING(nameBuffer);
+ subKeyClassName = __MKSTRING(classNameBuffer);
+ } else {
+printf("RegEnumKey failed\n");
+ }
+ }
+%}.
+ subKeyName isNil ifTrue:[^ nil].
+ ^ self subKeyNamed:subKeyName.
+
+ "
+ |top sub|
+
+ top := self key:'HKEY_LOCAL_MACHINE'.
+ sub := top subKeyAtIndex:0
+ "
+!
+
+subKeyNamed:subKeyString
"return a new registry entry below mySelf with the given subKey.
Return nil if no such key exists"
@@ -6933,7 +6980,9 @@
}
%}.
subHandle notNil ifTrue:[
- newEntry := self class basicNew setHandle:subHandle.
+ newEntry := self class basicNew
+ setHandle:subHandle
+ path:(path , self class separator asString , subKeyString).
Lobby register:newEntry.
^ newEntry.
].
@@ -6943,15 +6992,63 @@
|top sub|
top := self key:'HKEY_LOCAL_MACHINE'.
- sub := top subKey:'Software'
- "
-
+ sub := top subKeyNamed:'Software'
+ "
! !
!Win32OperatingSystem::RegistryEntry methodsFor:'enumeration'!
-subKeyNamesDo:aBlock
+allSubKeysDo:aBlock
+ "recursively evaluate aBlock for all subKeys below the receiver"
+
+ |idx subEntry|
+
+ idx := 0.
+ [true] whileTrue:[
+ subEntry := self subKeyAtIndex:idx.
+ subEntry isNil ifTrue:[
+ ^self
+ ].
+ aBlock value:subEntry.
+ subEntry allSubKeysDo:aBlock.
+ subEntry close.
+ idx := idx + 1.
+ ]
+
+ "
+ |top sub|
+
+ top := self key:'HKEY_LOCAL_MACHINE'.
+ top allSubKeysDo:[:subEntry |
+ Transcript showCR:subEntry path
+ ]
+ "
+!
+
+subKeysDo:aBlock
"evaluate aBlock for all subKeys below the receiver"
+
+ |idx subEntry|
+
+ idx := 0.
+ [true] whileTrue:[
+ subEntry := self subKeyAtIndex:idx.
+ subEntry isNil ifTrue:[
+ ^self
+ ].
+ aBlock value:subEntry.
+ subEntry close.
+ idx := idx + 1.
+ ]
+
+ "
+ |top sub|
+
+ top := self key:'HKEY_LOCAL_MACHINE'.
+ top subKeysDo:[:subEntry |
+ Transcript showCR:subEntry path
+ ]
+ "
! !
!Win32OperatingSystem::RegistryEntry methodsFor:'instance release'!
@@ -6992,8 +7089,9 @@
!Win32OperatingSystem::RegistryEntry methodsFor:'private'!
-setHandle:aHandle
- handle := aHandle
+setHandle:aHandle path:aPathString
+ handle := aHandle.
+ path := aPathString.
"Created: / 19.5.1999 / 22:27:05 / cg"
!
@@ -7021,6 +7119,6 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.59 1999-05-27 12:07:16 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.60 1999-05-27 16:13:23 cg Exp $'
! !
Win32OperatingSystem initialize!