Win32OperatingSystem.st
branchjv
changeset 17795 569eec7576f1
parent 17780 b6e42c92eba0
child 17807 06cc6c49e291
--- a/Win32OperatingSystem.st	Sun Aug 01 12:11:07 2010 +0100
+++ b/Win32OperatingSystem.st	Tue Aug 10 09:55:15 2010 +0100
@@ -4569,6 +4569,20 @@
     ^ false
 !
 
+clearHidden:aPathName
+    "set the hidden attribute; Return true if the operation succeeded"
+
+    |attr|
+
+    attr := self primGetFileAttributes:aPathName.
+    (attr bitTest:FILE_ATTRIBUTE_HIDDEN ) ifTrue:[
+        ^ self primSetFileAttributes:aPathName to:(attr bitClear:2).
+    ].
+    ^ true
+
+    "Created: / 29-07-2010 / 11:31:55 / sr"
+!
+
 compressPath:pathName
     "return the pathName compressed - that is, remove all ..-entries
      and . entries. This does not always (in case of symbolic links)
@@ -5866,15 +5880,17 @@
 !
 
 setHidden:aPathName
-    "set the hidden attribute. Return true if it is set"
+    "set the hidden attribute. Return true if the operation succeeded"
 
     |attr|
 
     attr := self primGetFileAttributes:aPathName.
     (attr bitTest:FILE_ATTRIBUTE_HIDDEN ) ifFalse:[
-	^ self primSetFileAttributes:aPathName to:(attr bitOr:2).
+        ^ self primSetFileAttributes:aPathName to:(attr bitOr:2).
     ].
     ^ true  "/ aready set
+
+    "Modified: / 29-07-2010 / 11:32:26 / sr"
 !
 
 setNormal:aPathName
@@ -7029,35 +7045,36 @@
 !Win32OperatingSystem class methodsFor:'mutex'!
 
 createMutexNamed: name
-
     "Returns an array with the handle and the lastErrorCode"
 
     |handle lastErrorCode|
 
-    "Without clear reasons, before creating the mutex we must call #printCR"
-    'Creating mutex' printCR.
+    "/ "Without clear reasons, before creating the mutex we must call #printCR"
+    "/ 'Creating mutex' printCR.
     self primSetLastError: 0.
     self primGetLastError.
     handle := self primCreateMutex:nil initialOwner: true name: name.
     lastErrorCode := self primGetLastError.
-    lastErrorCode printCR.
+    "/ lastErrorCode printCR.
+
 "/    self assert: lastErrorCode == 0.
 "/    lastErrorCode == 5 "ERROR_ACCESS_DENIED" ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.].
 "/    lastErrorCode == 183 "ERROR_ALREADY_EXISTS" ifTrue:[Transcript showCR: 'Mutex already exists (GetLastError = ERROR_ALREADY_EXISTS)'.].
     (handle isNil or:[handle address ~~ 0]) ifFalse:[
-	Transcript showCR: 'CreateMutexNamed: "', name printString, '" failed'.
-	handle := nil.
+        Transcript showCR: 'CreateMutexNamed: "', name printString, '" failed'.
+        handle := nil.
     ].
     ^ Array with: handle with: lastErrorCode
 
     "
-    self createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0'
-    self releaseMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0'
-    "
+     self createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0'
+     self releaseMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0'
+    "
+
+    "Modified: / 03-08-2010 / 16:57:36 / cg"
 !
 
 existsMutexNamed: name
-
     |handle lastErrorCode handleAndLastErrorCode|
 
     handleAndLastErrorCode := self createMutexNamed: name.
@@ -7065,17 +7082,16 @@
     lastErrorCode := handleAndLastErrorCode second.
 "/    self assert: lastErrorCode == 0.
     ^ handle isNil
-	or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS"
-	    or:[ lastErrorCode == 5 "ERROR_ACCESS_DENIED"]]
+        or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS"
+            or:[ lastErrorCode == 5 "ERROR_ACCESS_DENIED"]]
+
+    "Modified: / 03-08-2010 / 16:59:41 / cg"
 !
 
 openMutexNamed: name
-
-    "
-    If the function succeeds, the return value is a handle to the mutex object.
-    If the function fails, the return value is NULL. To get extended error information, call GetLastError.
-    If a named mutex does not exist, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND.
-    "
+    "If the function succeeds, the return value is a handle to the mutex object.
+     If the function fails, the return value is NULL. To get extended error information, call GetLastError.
+     If a named mutex does not exist, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND."
 
     |handle |
 
@@ -7084,8 +7100,8 @@
 "/    lastErrorCode = 2 ifTrue:[Transcript showCR: 'Mutex does not exist (GetLastError = ERROR_FILE_NOT_FOUND)'.].
 "/    lastErrorCode = 5 ifTrue:[Transcript showCR: 'Mutex not accesible (GetLastError = ERROR_ACCESS_DENIED)'.].
     (handle isNil or:[handle address ~~ 0]) ifFalse:[
-	Transcript showCR: 'OpenMutexNamed: "', name printString, '" failed'.
-	^ nil.
+        Transcript showCR: 'OpenMutexNamed: "', name printString, '" failed'.
+        ^ nil.
     ].
 
     ^ handle
@@ -7094,84 +7110,86 @@
     "
     self openMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0'
     "
+
+    "Modified: / 03-08-2010 / 16:59:37 / cg"
 !
 
 primCreateMutex:lpSecurityDescriptor initialOwner: bInitialOwner name: lpName
-
-    "
-     If the function succeeds, the return value is a handle to the newly created mutex object.
+    "If the function succeeds, the return value is a handle to the newly created mutex object.
      If the function fails, the return value is NULL.
-     If the mutex is a named mutex and the object existed before this function call, the return value is a handle to the existing object.
-    "
+     If the mutex is a named mutex and the object existed before this function call, the return value is a handle to the existing object."
 
     <apicall: handle "CreateMutexA" (lpstr bool lpstr) module: "kernel32.dll" >
+
+    "Modified: / 03-08-2010 / 16:59:26 / cg"
 !
 
 primOpenMutex:lpSecurityDescriptor initialOwner: bInitialOwner name: lpName
-
-    "
-    If the function succeeds, the return value is a handle to the mutex object.
-    If the function fails, the return value is NULL. To get extended error information, call GetLastError.
-    If a named mutex does not exist, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND.
-    "
+    "If the function succeeds, the return value is a handle to the mutex object.
+     If the function fails, the return value is NULL. To get extended error information, call GetLastError.
+     If a named mutex does not exist, the function fails and GetLastError returns ERROR_FILE_NOT_FOUND."
 
     <apicall: handle "OpenMutexA" (lpstr bool lpstr) module: "kernel32.dll" >
+
+    "Modified: / 03-08-2010 / 16:59:11 / cg"
 !
 
 primReleaseMutex: hMutex
-
-    "
-    If the function succeeds, the return value is nonzero.
-    If the function fails, the return value is zero.
-    "
+    "If the function succeeds, the return value is nonzero.
+     If the function fails, the return value is zero."
 
     <apicall: bool "ReleaseMutex" (handle) module: "kernel32.dll" >
+
+    "Modified: / 03-08-2010 / 16:59:55 / cg"
 !
 
 primWaitForSingleObject: handle milliseconds: dwMilliseconds
-
-    "
-    If the function succeeds, the return value indicates the event that caused the function to return.
-    If the function fails, the return value is WAIT_FAILED ((DWORD)0xFFFFFFFF).
-    "
+    "If the function succeeds, the return value indicates the event that caused the function to return.
+     If the function fails, the return value is WAIT_FAILED ((DWORD)0xFFFFFFFF)."
 
     <apicall: dword "WaitForSingleObject" (handle dword) module: "kernel32.dll" >
+
+    "Modified: / 03-08-2010 / 17:00:02 / cg"
 !
 
 releaseMutex: hMutex
-
     "Returns true if the Mutex was released. Otherwise, returns false."
 
     | released|
 
     hMutex isNil ifTrue:[
-	Transcript showCR: 'hMutex is nil - cannot release'.
-	^ false
+        Transcript showCR: 'hMutex is nil - cannot release'.
+        ^ false
     ].
     released := self primReleaseMutex: hMutex.
     released ifFalse:[Transcript showCR: 'Release Mutex failed'.].
     ^ released
+
+    "Modified: / 03-08-2010 / 17:00:05 / cg"
 !
 
 releaseMutexNamed: name
-
     "Returns true if the Mutex was released. Otherwise, returns false."
 
     | hMutex |
+
     hMutex := self openMutexNamed: name.
     hMutex isNil ifTrue:[
-	Transcript showCR: 'Cannot release Mutex named: "', name printString,'"'.
-	^ false
+        Transcript showCR: 'Cannot release Mutex named: "', name printString,'"'.
+        ^ false
     ].
     ^ self releaseMutex: hMutex.
+
+    "Modified: / 03-08-2010 / 16:58:25 / cg"
 !
 
 waitForSingleObject: handle
-
     |result|
 
     result := self primWaitForSingleObject: handle milliseconds: 500.
     ^ result
+
+    "Modified: / 03-08-2010 / 17:00:10 / cg"
 ! !
 
 !Win32OperatingSystem class methodsFor:'os queries'!
@@ -7186,57 +7204,57 @@
 !
 
 getDomainName
-    "return the domain this host is in.
+    "return the DNS domain this host is in.
      Notice:
-	not all systems support this; on some, 'unknown' is returned."
-
-    |name idx hostName k|
+        not all systems support this; on some, 'unknown' is returned."
+
+    |domainName idx hostName k|
 
     DomainName notNil ifTrue:[
-	^ DomainName
-    ].
-
-    name := self getEnvironment:'DOMAIN'.
-    name isNil ifTrue:[
-	name := self getEnvironment:'DOMAINNAME'.
-    ].
-
-    name isNil ifTrue:[
-	"/ sometimes, we can extract the domainName from the hostName ...
-	hostName := self primGetHostName.
-	hostName notNil ifTrue:[
-	    idx := hostName indexOf:$..
-	    idx ~~ 0 ifTrue:[
-		name := hostName copyFrom:idx+1.
-	    ]
-	].
-
-	name isNil ifTrue:[
-	    "/ ok, search the registry ...
-	    "/ under NT and later, it is found there ...
-	    k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'.
-	    k notNil ifTrue:[
-		name := k valueNamed:'Domain'.
-		k close.
-	    ].
-	].
-
-	name isNil ifTrue:[
-	    "/ under Win95/Win98, it is found there ...
-	    k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP'.
-	    k notNil ifTrue:[
-		name := k valueNamed:'Domain'.
-		k close.
-	    ]
-	].
-
-	name isNil ifTrue:[
-	    'Win32OperatingSystem [warning]: cannot find out domainname' errorPrintCR.
-	    name := 'unknown'.
-	]
-    ].
-    DomainName := name.
-    ^ name
+        ^ DomainName
+    ].
+
+    "/ sometimes, we can extract the domainName from the hostName ...
+    hostName := self getHostName.
+    hostName notEmptyOrNil ifTrue:[
+        idx := hostName indexOf:$..
+        idx ~~ 0 ifTrue:[
+            domainName := hostName copyFrom:idx+1.
+        ]
+    ].
+
+    domainName isNil ifTrue:[
+        domainName := self getEnvironment:'DOMAIN'.
+        domainName isNil ifTrue:[
+            domainName := self getEnvironment:'DOMAINNAME'.
+        ].
+
+        domainName isNil ifTrue:[
+            "/ ok, search the registry ...
+            "/ under NT and later, it is found there ...
+            k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'.
+            k notNil ifTrue:[
+                domainName := k valueNamed:'Domain'.
+                k close.
+            ].
+        ].
+
+        domainName isNil ifTrue:[
+            "/ under Win95/Win98, it is found there ...
+            k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP'.
+            k notNil ifTrue:[
+                domainName := k valueNamed:'Domain'.
+                k close.
+            ]
+        ].
+
+        domainName isNil ifTrue:[
+            'Win32OperatingSystem [warning]: cannot find out domainName' errorPrintCR.
+            domainName := 'unknown'.
+        ].
+        DomainName := domainName.     "cache only, if it is fixed"
+    ].
+    ^ domainName
 
     "
      DomainName := nil.
@@ -7294,28 +7312,20 @@
 !
 
 getHostName
-    "return the hostname we are running on - if there is
-     a HOST environment variable, we are much faster here ...
-     Notice:
-	not all systems support this; on some, 'unknown' is returned."
-
-    |name idx|
-
-    HostName notNil ifTrue:[
-	^ HostName
-    ].
-
-    name := self primGetHostName.
-
-    "/ on some systems, the hostname already contains the domain.
-    "/ decompose it here.
-    idx := name indexOf:$..
-    idx ~~ 0 ifTrue:[
-	DomainName := name copyFrom:(idx+1).
-	name := name copyTo:(idx-1).
-    ].
-    HostName := name.
-    ^ name
+    "return the hostname we are running on
+      - if possible, the fully qualified host name."
+
+    |hostName|
+
+%{  /* STACK: 2048 */
+    char buffer[512];
+    DWORD buffSize = sizeof(buffer);
+
+    if (GetComputerNameEx(ComputerNameDnsFullyQualified, buffer, &buffSize) == TRUE) {
+        hostName = __MKSTRING(buffer);
+    }
+%}.
+    ^ hostName
 
     "
      OperatingSystem getHostName
@@ -7776,25 +7786,25 @@
        This method is mainly provided to augment error reports with some system
        information.
        (in case of system/version specific OS errors, conditional workarounds and patches
-	may be based upon this info).
+        may be based upon this info).
        Your application should NOT depend upon this in any way.
 
      The returned info may (or may not) contain:
-	#system -> some operating system identification (irix, Linux, nt, win32s ...)
-	#version -> OS version (some os version identification)
-	#release -> OS release (3.5, 1.2.1 ...)
-	#node   -> some host identification (hostname)
-	#domain  -> domain name (hosts domain)
-	#machine -> type of machine (i586, mips ...)
+        #system -> some operating system identification (irix, Linux, nt, win32s ...)
+        #version -> OS version (some os version identification)
+        #release -> OS release (3.5, 1.2.1 ...)
+        #node   -> some host identification (hostname)
+        #domain  -> domain name (hosts domain)
+        #machine -> type of machine (i586, mips ...)
 
      win32:
-	#physicalRam -> total amount of physical memory
-	#freeRam -> amount of free memory
-	#swapSize -> size of swapSpace (page file)
-	#freeSwap -> free bytes in swapSpace
-	#virtualRam -> total amount of virtual memory
-	#freeVirtual -> amount of free virtual memory
-	#memoryLoad -> percentage of memory usage (useless)
+        #physicalRam -> total amount of physical memory
+        #freeRam -> amount of free memory
+        #swapSize -> size of swapSpace (page file)
+        #freeSwap -> free bytes in swapSpace
+        #virtualRam -> total amount of virtual memory
+        #freeVirtual -> amount of free virtual memory
+        #memoryLoad -> percentage of memory usage (useless)
     "
 
     |sys node rel ver minorVer majorVer mach dom info arch
@@ -7820,19 +7830,21 @@
     majorVer = __mkSmallInteger(verMajor);
 
     if (HIWORD(vsn) & 0x8000) {
-	s = "win95";
+        sys = @symbol(win95);
     } else {
-	if ((verMajor > 5)
-	 || ((verMajor == 5) && (verMinor >= 1))) {
-	    s = "xp";
-	    if (verMajor >= 6) {
-		s = "vista";
-	    }
-	} else {
-	    s = "nt";
-	}
-    }
-    sys = __MKSTRING(s);
+        if ((verMajor > 5)
+         || ((verMajor == 5) && (verMinor >= 1))) {
+            sys = @symbol(xp);
+            if (verMajor >= 6) {
+                sys = @symbol(vista);
+                if (verMinor >= 1) {
+                    sys = @symbol(win7);
+                }
+            }
+        } else {
+            sys = @symbol(nt);
+        }
+    }
     len = snprintf(vsnBuffer, sizeof(vsnBuffer), "%d.%d", verMajor, verMinor);
     rel = __MKSTRING_L(vsnBuffer, len);
 
@@ -7857,166 +7869,155 @@
 #endif
     {
 #ifdef PROCESSOR_ARCHITECTURE_INTEL
-	case PROCESSOR_ARCHITECTURE_INTEL:
-	    s = "intel";
-	    break;
+        case PROCESSOR_ARCHITECTURE_INTEL:
+            arch = @symbol(intel);
+            break;
 #endif
 #ifdef PROCESSOR_ARCHITECTURE_MIPS
-	case PROCESSOR_ARCHITECTURE_MIPS:
-	    s = "mips";
-	    break;
+        case PROCESSOR_ARCHITECTURE_MIPS:
+            arch = @symbol(mips);
+            break;
 #endif
 #ifdef PROCESSOR_ARCHITECTURE_ALPHA
-	case PROCESSOR_ARCHITECTURE_ALPHA:
-	    s = "alpha";
-	    break;
+        case PROCESSOR_ARCHITECTURE_ALPHA:
+            arch = @symbol(alpha);
+            break;
 #endif
 #ifdef PROCESSOR_ARCHITECTURE_ALPHA64
-	case PROCESSOR_ARCHITECTURE_ALPHA64:
-	    s = "alpha64";
-	    break;
+        case PROCESSOR_ARCHITECTURE_ALPHA64:
+            arch = @symbol(alpha64);
+            break;
 #endif
 #ifdef PROCESSOR_ARCHITECTURE_PPC
-	case PROCESSOR_ARCHITECTURE_PPC:
-	    s = "ppc";
-	    break;
+        case PROCESSOR_ARCHITECTURE_PPC:
+            arch = @symbol(ppc);
+            break;
 #endif
 #ifdef PROCESSOR_ARCHITECTURE_ARM
-	case PROCESSOR_ARCHITECTURE_ARM:
-	    s = "arm";
-	    break;
+        case PROCESSOR_ARCHITECTURE_ARM:
+            arch = @symbol(arm);
+            break;
 #endif
 #ifdef PROCESSOR_ARCHITECTURE_SHX
-	case PROCESSOR_ARCHITECTURE_SHX:
-	    s = "shx";
-	    break;
+        case PROCESSOR_ARCHITECTURE_SHX:
+            arch = @symbol(shx);
+            break;
 #endif
 #ifdef PROCESSOR_ARCHITECTURE_IA64
-	case PROCESSOR_ARCHITECTURE_IA64:
-	    s = "ia64";
-	    break;
+        case PROCESSOR_ARCHITECTURE_IA64:
+            arch = @symbol(ia64);
+            break;
 #endif
 #ifdef PROCESSOR_ARCHITECTURE_MSIL
-	case PROCESSOR_ARCHITECTURE_MSIL:
-	    s = "msil";
-	    break;
-#endif
-	default:
-	    s = "unknown";
-	    break;
-    }
-    arch = __MKSTRING(s);
+        case PROCESSOR_ARCHITECTURE_MSIL:
+            arch = @symbol(msil);
+            break;
+#endif
+        default:
+            arch = @symbol(unknown);
+            break;
+    }
 
     switch (sysInfo.dwProcessorType) {
 #ifdef PROCESSOR_INTEL_386
-	case PROCESSOR_INTEL_386:
-	    s = "i386";
-	    break;
+        case PROCESSOR_INTEL_386:
+            mach = @symbol(i386);
+            break;
 #endif
 #ifdef PROCESSOR_INTEL_486
-	case PROCESSOR_INTEL_486:
-	    s = "i486";
-	    break;
+        case PROCESSOR_INTEL_486:
+            mach = @symbol(i486);
+            break;
 #endif
 #ifdef PROCESSOR_INTEL_PENTIUM
-	case PROCESSOR_INTEL_PENTIUM:
-	    s = "i586";
-	    break;
+        case PROCESSOR_INTEL_PENTIUM:
+            mach = @symbol(i586);
+            break;
 #endif
 #ifdef PROCESSOR_INTEL_860
-	case PROCESSOR_INTEL_860:
-	    s = "i860";
-	    break;
+        case PROCESSOR_INTEL_860:
+            mach = @symbol(i860);
+            break;
 #endif
 #ifdef PROCESSOR_INTEL_IA64
-	case PROCESSOR_INTEL_IA64:
-	    s = "ia64";
-	    break;
+        case PROCESSOR_INTEL_IA64:
+            mach = @symbol(ia64);
+            break;
 #endif
 #ifdef PROCESSOR_MIPS_R2000
-	case PROCESSOR_MIPS_R2000:
-	    s = "r2000";
-	    break;
+        case PROCESSOR_MIPS_R2000:
+            mach = @symbol(r2000);
+            break;
 #endif
 #ifdef PROCESSOR_MIPS_R3000
-	case PROCESSOR_MIPS_R3000:
-	    s = "r3000";
-	    break;
+        case PROCESSOR_MIPS_R3000:
+            mach = @symbol(r3000);
+            break;
 #endif
 #ifdef PROCESSOR_MIPS_R4000
-	case PROCESSOR_MIPS_R4000:
-	    s = "r4000";
-	    break;
+        case PROCESSOR_MIPS_R4000:
+            mach = @symbol(r4000);
+            break;
 #endif
 #ifdef PROCESSOR_ALPHA_21064
-	case PROCESSOR_ALPHA_21064:
-	    s = "alpha21064";
-	    break;
+        case PROCESSOR_ALPHA_21064:
+            mach = @symbol(alpha21064);
+            break;
 #endif
 #ifdef PROCESSOR_ARM720
-	case PROCESSOR_ARM720:
-	    s = "arm720";
-	    break;
+        case PROCESSOR_ARM720:
+            mach = @symbol(arm720);
+            break;
 #endif
 #ifdef PROCESSOR_ARM820
-	case PROCESSOR_ARM820:
-	    s = "arm820";
-	    break;
+        case PROCESSOR_ARM820:
+            mach = @symbol(arm820);
+            break;
 #endif
 #ifdef PROCESSOR_ARM920
-	case PROCESSOR_ARM920:
-	    s = "arm920";
-	    break;
+        case PROCESSOR_ARM920:
+            mach = @symbol(arm920);
+            break;
 #endif
 #ifdef PROCESSOR_ARM_7TDMI
-	case PROCESSOR_ARM_7TDMI:
-	    s = "arm70001";
-	    break;
+        case PROCESSOR_ARM_7TDMI:
+            mach = @symbol(arm70001);
+            break;
 #endif
 #ifdef PROCESSOR_PPC_601
-	case PROCESSOR_PPC_601:
-	    s = "ppc601";
-	    break;
+        case PROCESSOR_PPC_601:
+            mach = @symbol(ppc601);
+            break;
 #endif
 #ifdef PROCESSOR_PPC_603
-	case PROCESSOR_PPC_603:
-	    s = "ppc603";
-	    break;
+        case PROCESSOR_PPC_603:
+            mach = @symbol(ppc603);
+            break;
 #endif
 #ifdef PROCESSOR_PPC_604
-	case PROCESSOR_PPC_604:
-	    s = "ppc604";
-	    break;
+        case PROCESSOR_PPC_604:
+            mach = @symbol(ppc604);
+            break;
 #endif
 #ifdef PROCESSOR_PPC_620
-	case PROCESSOR_PPC_620:
-	    s = "ppc620";
-	    break;
-#endif
-
-	default:
-	    sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType);
-	    s = vsnBuffer;
-	    break;
-    }
-    mach = __MKSTRING(s);
+        case PROCESSOR_PPC_620:
+            mach = @symbol(ppc620);
+            break;
+#endif
+
+        default:
+            sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType);
+            mach =  __MKSTRING(vsnBuffer);
+            break;
+    }
 
     numberOfCPUs = __MKUINT(sysInfo.dwNumberOfProcessors);
 %}.
-    sys isNil ifTrue:[
-	sys := self getSystemType.
-    ].
     node isNil ifTrue:[
-	node := self getHostName.
+        node := self getHostName.
     ].
     dom isNil ifTrue:[
-	dom := self getDomainName.
-    ].
-    mach isNil ifTrue:[
-	mach := self getCPUType.
-    ].
-    arch isNil ifTrue:[
-	arch := 'unknown'.
+        dom := self getDomainName.
     ].
 
     info := IdentityDictionary new.
@@ -8055,7 +8056,7 @@
      here ...
      (except for slight differences between next/mach and other machs)"
 
-    ^ 'win32'
+    ^ #win32
 
     "
      OperatingSystem getSystemType
@@ -8214,6 +8215,22 @@
     "
 !
 
+isWin7Like
+    "return true, if running on a Windows7 like system."
+
+    |sysInfo major|
+
+    sysInfo := self getSystemInfo.
+    major := sysInfo at:#majorVersion.
+
+    ^ (major == 6 and:[(sysInfo at:#minorVersion) >= 1])
+      or:[major > 6]
+
+    "
+     self isWin7Like
+    "
+!
+
 maxFileNameLength
     "return the max number of characters in a filename.
      CAVEAT:
@@ -8251,14 +8268,14 @@
 
 osName
 
-    | os |
-
-    os := 'Windows ', (#('3.x' '95' 'NT' '2000' 'XP') at: (#('3.0' '4.0' '4.1' '5.0' '5.1') indexOf: (OperatingSystem osVersion))).
-
-    ^os
-
-    "Created: / 18-01-2007 / 17:21:06 / User"
-    "Modified: / 19-01-2007 / 13:15:59 / User"
+    ^ 'Windows ', 
+        (#('NT' '2000' 'XP' 'VISTA' '7') 
+            at: (#('4.1' '5.0' '5.1' '6.0' '6.1') indexOf:OperatingSystem osVersion) 
+            ifAbsent:OperatingSystem osVersion).
+
+    "
+      self osName
+    "
 !
 
 osVersion
@@ -8291,112 +8308,6 @@
     "Modified: 20.6.1997 / 17:37:26 / cg"
 !
 
-primGetDomainName
-%{
-#if 0   /* not needed */
-    HINSTANCE hNetApi32 = LoadLibrary("netapi32.dll");
-    DWORD (__stdcall *pfnNetApiBufferFree)(LPVOID Buffer);
-    DWORD (__stdcall *pfnNetWkstaGetInfo)(LPWSTR servername, DWORD level, void *bufptr);
-
-    if (hNetApi32) {
-	pfnNetApiBufferFree = (DWORD (__stdcall *)(void *)) GetProcAddress(hNetApi32, "NetApiBufferFree");
-	pfnNetWkstaGetInfo = (DWORD (__stdcall *)(LPWSTR, DWORD, void *)) GetProcAddress(hNetApi32, "NetWkstaGetInfo");
-    }
-
-    if (hNetApi32 && pfnNetWkstaGetInfo && pfnNetApiBufferFree) {
-	/* this way is more reliable, in case user has a local account. */
-	char dname[256];
-	DWORD dnamelen = sizeof(dname);
-	struct {
-	    DWORD   wki100_platform_id;
-	    LPWSTR  wki100_computername;
-	    LPWSTR  wki100_langroup;
-	    DWORD   wki100_ver_major;
-	    DWORD   wki100_ver_minor;
-	} *pwi;
-
-	/* NERR_Success *is* 0*/
-	if (0 == pfnNetWkstaGetInfo(NULL, 100, &pwi)) {
-	    if (pwi->wki100_langroup && *(pwi->wki100_langroup)) {
-		WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_langroup,
-				    -1, (LPSTR)dname, dnamelen, NULL, NULL);
-	    }
-	    else {
-		WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_computername,
-				    -1, (LPSTR)dname, dnamelen, NULL, NULL);
-	    }
-	    pfnNetApiBufferFree(pwi);
-	    FreeLibrary(hNetApi32);
-	    RETURN (__MKSTRING(dname));
-	}
-	FreeLibrary(hNetApi32);
-    } else {
-	/* Win95 doesn't have NetWksta*(), so do it the old way */
-	char name[256];
-	DWORD size = sizeof(name);
-	if (hNetApi32)
-	    FreeLibrary(hNetApi32);
-	if (GetUserName(name,&size)) {
-	    char sid[1024];
-	    DWORD sidlen = sizeof(sid);
-	    char dname[256];
-	    DWORD dnamelen = sizeof(dname);
-	    SID_NAME_USE snu;
-	    if (LookupAccountName(NULL, name, (PSID)&sid, &sidlen,
-				  dname, &dnamelen, &snu)) {
-		RETURN (__MKSTRING(dname));             /* all that for this */
-	    }
-	}
-    }
-#endif /* not needed */
-%}.
-    ^ nil
-!
-
-primGetHostName
-    "return the hostname we are running on - if there is
-     a HOST environment variable, we are much faster here ...
-     Notice:
-	not all systems support this; on some, 'unknown' is returned."
-
-    |name|
-
-%{  /* STACK: 2048 */
-#if defined(HAS_GETHOSTNAME)
-    char buffer[256];
-
-    if (gethostname(buffer, sizeof(buffer)) == 0) {
-	name = __MKSTRING(buffer);
-    }
-#else
-    char buffer[128];
-    DWORD buffSize = sizeof(buffer);
-
-    if (GetComputerName(buffer, &buffSize) == TRUE) {
-	name = __MKSTRING(buffer);
-    }
-#endif
-%}.
-    name isNil ifTrue:[
-	name := self getEnvironment:'HOST'.
-	name isNil ifTrue:[
-	    name := self getEnvironment:'HOSTNAME'.
-	    name isNil ifTrue:[
-		name := self getEnvironment:'COMPUTERNAME'.
-		name isNil ifTrue:[
-		    'Win32OperatingSystem [warning]: cannot find out hostname' errorPrintCR.
-		    name := 'unknown'.
-		]
-	    ]
-	]
-    ].
-    ^ name
-
-    "
-     OperatingSystem primGetHostName
-    "
-!
-
 randomBytesInto:bufferOrInteger
     "If bufferOrInteger is a String or a ByteArray,
 	fill a given buffer with random bytes from the RtlGenRandom function
@@ -10199,6 +10110,36 @@
 
 !Win32OperatingSystem class methodsFor:'users & groups'!
 
+getApplicationDataDirectoryFor:appName
+    "return the directory, where user-and-application-specific private files are to be
+     located (ini-files, preferences etc.).
+     Under windows, something like 'C:\Users\Administrator\AppData\Roaming\<appName>'
+     is returned, here, the fallback ~/.<appName> is returned.
+     Notice that only the name is returned; the directory is not guaranteed to exist."
+
+    "{ Pragma: +optSpace }"
+
+    |appDataDirFromEnv appDataDirFromRegistry|
+
+    appDataDirFromEnv := self getEnvironment:'APPDATA'.
+    appDataDirFromEnv notNil ifTrue:[
+        ^ appDataDirFromEnv , '\' , appName
+    ].
+    appDataDirFromRegistry := 
+        (self registryEntry key:'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders')
+            valueNamed:'AppData'.
+    appDataDirFromRegistry notNil ifTrue:[
+        ^ appDataDirFromRegistry , '\' , appName
+    ].
+    ^ super getApplicationDataDirectoryFor:appName
+
+    "
+     OperatingSystem getApplicationDataDirectoryFor:'expecco'  
+    "
+
+    "Created: / 29-07-2010 / 12:13:12 / sr"
+!
+
 getDesktopDirectory
     "return the name of the users desktop directory (i.e. yours)."
 
@@ -16299,15 +16240,15 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Id: Win32OperatingSystem.st 10544 2010-07-12 16:20:36Z vranyj1 $'
+    ^ '$Id: Win32OperatingSystem.st 10564 2010-08-10 08:55:15Z vranyj1 $'
 !
 
 version_CVS
-    ^ 'Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.404 2010/07/07 14:58:13 cg Exp '
+    ^ 'Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.409 2010/08/03 15:08:47 cg Exp '
 !
 
 version_SVN
-    ^ '$Id: Win32OperatingSystem.st 10544 2010-07-12 16:20:36Z vranyj1 $'
+    ^ '$Id: Win32OperatingSystem.st 10564 2010-08-10 08:55:15Z vranyj1 $'
 ! !
 
 Win32OperatingSystem initialize!
@@ -16317,3 +16258,4 @@
 
 
 
+