@@ -865,26 +865,36 @@ def collect_subprocess(info_add):
865
865
866
866
867
867
def collect_windows (info_add ):
868
- try :
869
- import ctypes
870
- except ImportError :
871
- return
872
-
873
- if not hasattr (ctypes , 'WinDLL' ):
868
+ if sys .platform != "win32" :
869
+ # Code specific to Windows
874
870
return
875
871
876
- ntdll = ctypes .WinDLL ('ntdll' )
877
- BOOLEAN = ctypes .c_ubyte
878
-
872
+ # windows.RtlAreLongPathsEnabled: RtlAreLongPathsEnabled()
873
+ # windows.is_admin: IsUserAnAdmin()
879
874
try :
880
- RtlAreLongPathsEnabled = ntdll .RtlAreLongPathsEnabled
881
- except AttributeError :
882
- res = '<function not available>'
875
+ import ctypes
876
+ if not hasattr (ctypes , 'WinDLL' ):
877
+ raise ImportError
878
+ except ImportError :
879
+ pass
883
880
else :
884
- RtlAreLongPathsEnabled .restype = BOOLEAN
885
- RtlAreLongPathsEnabled .argtypes = ()
886
- res = bool (RtlAreLongPathsEnabled ())
887
- info_add ('windows.RtlAreLongPathsEnabled' , res )
881
+ ntdll = ctypes .WinDLL ('ntdll' )
882
+ BOOLEAN = ctypes .c_ubyte
883
+ try :
884
+ RtlAreLongPathsEnabled = ntdll .RtlAreLongPathsEnabled
885
+ except AttributeError :
886
+ res = '<function not available>'
887
+ else :
888
+ RtlAreLongPathsEnabled .restype = BOOLEAN
889
+ RtlAreLongPathsEnabled .argtypes = ()
890
+ res = bool (RtlAreLongPathsEnabled ())
891
+ info_add ('windows.RtlAreLongPathsEnabled' , res )
892
+
893
+ shell32 = ctypes .windll .shell32
894
+ IsUserAnAdmin = shell32 .IsUserAnAdmin
895
+ IsUserAnAdmin .restype = BOOLEAN
896
+ IsUserAnAdmin .argtypes = ()
897
+ info_add ('windows.is_admin' , IsUserAnAdmin ())
888
898
889
899
try :
890
900
import _winapi
@@ -893,6 +903,7 @@ def collect_windows(info_add):
893
903
except (ImportError , AttributeError ):
894
904
pass
895
905
906
+ # windows.version_caption: "wmic os get Caption,Version /value" command
896
907
import subprocess
897
908
try :
898
909
# When wmic.exe output is redirected to a pipe,
@@ -919,6 +930,7 @@ def collect_windows(info_add):
919
930
if line :
920
931
info_add ('windows.version' , line )
921
932
933
+ # windows.ver: "ver" command
922
934
try :
923
935
proc = subprocess .Popen (["ver" ], shell = True ,
924
936
stdout = subprocess .PIPE ,
@@ -937,6 +949,22 @@ def collect_windows(info_add):
937
949
if line :
938
950
info_add ('windows.ver' , line )
939
951
952
+ # windows.developer_mode: get AllowDevelopmentWithoutDevLicense registry
953
+ import winreg
954
+ try :
955
+ key = winreg .OpenKey (
956
+ winreg .HKEY_LOCAL_MACHINE ,
957
+ r"SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" )
958
+ subkey = "AllowDevelopmentWithoutDevLicense"
959
+ try :
960
+ value , value_type = winreg .QueryValueEx (key , subkey )
961
+ finally :
962
+ winreg .CloseKey (key )
963
+ except OSError :
964
+ pass
965
+ else :
966
+ info_add ('windows.developer_mode' , "enabled" if value else "disabled" )
967
+
940
968
941
969
def collect_fips (info_add ):
942
970
try :
0 commit comments