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