@@ -2,7 +2,7 @@ Attribute VB_Name = "mdUmmm"
2
2
'=========================================================================
3
3
'
4
4
' Unattended Make My Manifest Project
5
- ' Copyright (c) 2009-2021 [email protected]
5
+ ' Copyright (c) 2009-2022 [email protected]
6
6
'
7
7
'=========================================================================
8
8
Option Explicit
@@ -39,6 +39,9 @@ Private Declare Function ProgIDFromCLSID Lib "ole32.dll" (pCLSID As Any, lpszPro
39
39
Private Declare Function lstrlenW Lib "kernel32 " (ByVal lpString As Long ) As Long
40
40
Private Declare Sub CoTaskMemFree Lib "ole32 " (ByVal pv As Long )
41
41
Private Declare Function GetFileAttributes Lib "kernel32 " Alias "GetFileAttributesA " (ByVal lpFileName As String ) As Long
42
+ Private Declare Function CommandLineToArgvW Lib "shell32 " (ByVal lpCmdLine As Long , pNumArgs As Long ) As Long
43
+ Private Declare Function LocalFree Lib "kernel32 " (ByVal hMem As Long ) As Long
44
+ Private Declare Function ApiSysAllocString Lib "oleaut32 " Alias "SysAllocString " (ByVal Ptr As Long ) As Long
42
45
43
46
'=========================================================================
44
47
' Constants and member variables
@@ -156,7 +159,7 @@ Private Function pvProcess(sFile As String) As String
156
159
'--- on_off is true/false or 0/1
157
160
pvDumpGdiScaling C_Bool(At(vRow, 1 )), cOutput
158
161
Case "dpiawareness"
159
- '--- dpiawareness elements
162
+ '--- dpiawareness < elements>
160
163
pvDumpDpiAwareness At(vRow, 1 ), cOutput
161
164
Case "supportedos"
162
165
'--- supportedos <os_types>
@@ -166,6 +169,10 @@ Private Function pvProcess(sFile As String) As String
166
169
'--- longpathaware [on_off]
167
170
'--- on_off is true/false or 0/1
168
171
pvDumpLongPathAware C_Bool(At(vRow, 1 )), cOutput
172
+ Case "activecodepage"
173
+ '--- activecodepage <locale>
174
+ '--- locale can be UTF-8, Legacy or locale name (e.g. en-US)
175
+ pvDumpActiveCodePage At(vRow, 1 ), cOutput
169
176
End Select
170
177
Next
171
178
Case 0
536
543
Resume Next
537
544
End Function
538
545
539
- Private Function pvDumpLongPathAware (ByVal bAware As Boolean , cOutput As Collection ) As Boolean
540
- Const FUNC_NAME As String = "pvDumpLongPathAware"
541
- '--- note: longPathAware details from MS here:
542
- '--- https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN
543
- '--- Requires Windows 10, version 1607 or newer and HKLM\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled = 1
544
- On Error GoTo EH
545
- If bAware Then
546
- cOutput.Add " <application xmlns=""urn:schemas-microsoft-com:asm.v3"">"
547
- cOutput.Add " <windowsSettings xmlns:ws2=""http://schemas.microsoft.com/SMI/2016/WindowsSettings"">"
548
- cOutput.Add " <ws2:longPathAware>true</ws2:longPathAware>"
549
- cOutput.Add " </windowsSettings>"
550
- cOutput.Add " </application>"
551
- End If
552
- '--- success
553
- pvDumpLongPathAware = True
554
- Exit Function
555
- EH:
556
- PrintError FUNC_NAME
557
- Resume Next
558
- End Function
559
-
560
546
Private Function pvDumpGdiScaling (ByVal bEnable As Boolean , cOutput As Collection ) As Boolean
561
547
Const FUNC_NAME As String = "pvDumpGdiScaling"
562
548
@@ -576,13 +562,13 @@ EH:
576
562
Resume Next
577
563
End Function
578
564
579
- Private Function pvDumpDpiAwareness (ByVal sValues As String , cOutput As Collection ) As Boolean
565
+ Private Function pvDumpDpiAwareness (sValues As String , cOutput As Collection ) As Boolean
580
566
Const FUNC_NAME As String = "pvDumpDpiAwareness"
581
567
582
568
On Error GoTo EH
583
569
cOutput.Add " <asmv3:application>"
584
570
cOutput.Add " <asmv3:windowsSettings xmlns=""http://schemas.microsoft.com/SMI/2016/WindowsSettings"">"
585
- cOutput.Add Printf(" <dpiAwareness>%1</dpiAwareness>" , sValues)
571
+ cOutput.Add Printf(" <dpiAwareness>%1</dpiAwareness>" , pvXmlEscape( sValues) )
586
572
cOutput.Add " </asmv3:windowsSettings>"
587
573
cOutput.Add " </asmv3:application>"
588
574
'--- success
593
579
Resume Next
594
580
End Function
595
581
582
+ Private Function pvDumpLongPathAware (ByVal bAware As Boolean , cOutput As Collection ) As Boolean
583
+ Const FUNC_NAME As String = "pvDumpLongPathAware"
584
+ '--- note: longPathAware details from MS here:
585
+ '--- https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN
586
+ '--- Requires Windows 10, version 1607 or newer and HKLM\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled = 1
587
+ On Error GoTo EH
588
+ If bAware Then
589
+ cOutput.Add " <application xmlns=""urn:schemas-microsoft-com:asm.v3"">"
590
+ cOutput.Add " <windowsSettings xmlns:ws2=""http://schemas.microsoft.com/SMI/2016/WindowsSettings"">"
591
+ cOutput.Add " <ws2:longPathAware>true</ws2:longPathAware>"
592
+ cOutput.Add " </windowsSettings>"
593
+ cOutput.Add " </application>"
594
+ End If
595
+ '--- success
596
+ pvDumpLongPathAware = True
597
+ Exit Function
598
+ EH:
599
+ PrintError FUNC_NAME
600
+ Resume Next
601
+ End Function
602
+
596
603
Private Function pvDumpSupportedOs (vRow As Variant , cOutput As Collection ) As Boolean
597
604
Const FUNC_NAME As String = "pvDumpSupportedOs"
598
605
Dim lIdx As Long
634
641
Resume Next
635
642
End Function
636
643
644
+ Private Function pvDumpActiveCodePage (sLocale As String , cOutput As Collection ) As Boolean
645
+ Const FUNC_NAME As String = "pvDumpActiveCodePage"
646
+
647
+ '--- https://docs.microsoft.com/en-us/windows/win32/sbscs/application-manifests#activeCodePage
648
+ On Error GoTo EH
649
+ cOutput.Add " <asmv3:application>"
650
+ cOutput.Add " <asmv3:windowsSettings xmlns=""http://schemas.microsoft.com/SMI/2019/WindowsSettings"">"
651
+ cOutput.Add Printf(" <activeCodePage>%1</activeCodePage>" , pvXmlEscape(sLocale))
652
+ cOutput.Add " </asmv3:windowsSettings>"
653
+ cOutput.Add " </asmv3:application>"
654
+ '--- success
655
+ pvDumpActiveCodePage = True
656
+ Exit Function
657
+ EH:
658
+ PrintError FUNC_NAME
659
+ Resume Next
660
+ End Function
661
+
637
662
Private Function pvGetFlags (ByVal lMask As Long , vFlags As Variant ) As String
638
663
Const FUNC_NAME As String = "pvGetFlags"
639
664
Dim lIdx As Long
@@ -656,32 +681,33 @@ EH:
656
681
End Function
657
682
658
683
Private Function pvSplitArgs (sText As String ) As Variant
659
- Const FUNC_NAME As String = "pvSplitArgs"
660
- Dim oMatches As Object
661
684
Dim vRetVal As Variant
685
+ Dim lPtr As Long
686
+ Dim lArgc As Long
662
687
Dim lIdx As Long
688
+ Dim lArgPtr As Long
663
689
664
- On Error GoTo EH
665
- With CreateObject("VBScript.RegExp" )
666
- .Global = True
667
- .Pattern = """([^""]*(?:""""[^""]*)*)""|([^ ]+)"
668
- Set oMatches = .Execute(sText)
669
- If oMatches.Count > 0 Then
670
- ReDim vRetVal(0 To oMatches.Count - 1 ) As String
671
- For lIdx = 0 To oMatches.Count - 1
672
- With oMatches(lIdx)
673
- vRetVal(lIdx) = Replace$(.SubMatches(0 ) & .SubMatches(1 ), """""" , """" )
674
- End With
675
- Next
676
- Else
677
- vRetVal = Split(vbNullString)
678
- End If
679
- End With
690
+ If LenB(sText) <> 0 Then
691
+ lPtr = CommandLineToArgvW(StrPtr(sText), lArgc)
692
+ End If
693
+ If lArgc > 0 Then
694
+ ReDim vRetVal(0 To lArgc - 1 ) As String
695
+ For lIdx = 0 To UBound(vRetVal)
696
+ Call CopyMemory (lArgPtr, ByVal lPtr + 4 * lIdx, 4 )
697
+ vRetVal(lIdx) = SysAllocString(lArgPtr)
698
+ Next
699
+ Else
700
+ vRetVal = Split(vbNullString)
701
+ End If
702
+ Call LocalFree (lPtr)
680
703
pvSplitArgs = vRetVal
681
- Exit Function
682
- EH:
683
- PrintError FUNC_NAME
684
- Resume Next
704
+ End Function
705
+
706
+ Private Function SysAllocString (ByVal lPtr As Long ) As String
707
+ Dim lTemp As Long
708
+
709
+ lTemp = ApiSysAllocString(lPtr)
710
+ Call CopyMemory (ByVal VarPtr(SysAllocString), lTemp, 4 )
685
711
End Function
686
712
687
713
Private Function pvPathDifference (sBase As String , sFolder As String ) As String
@@ -850,8 +876,8 @@ Private Function pvGetTempFileName() As String
850
876
851
877
sFile = String (2000 , 0 )
852
878
Call GetTempFileName (Environ$("TEMP" ), "UMMM" , 0 , sFile)
853
- If InStr(sFile, Chr$( 0 ) ) > 0 Then
854
- pvGetTempFileName = Left$(sFile, InStr(sFile, Chr$( 0 ) ) - 1 )
879
+ If InStr(sFile, vbNullChar ) > 0 Then
880
+ pvGetTempFileName = Left$(sFile, InStr(sFile, vbNullChar ) - 1 )
855
881
Else
856
882
pvGetTempFileName = "C:\UMMM.tmp"
857
883
End If
@@ -919,7 +945,7 @@ Private Function pvGetStringFileInfo(sFile As String, sKey As String) As String
919
945
End If
920
946
921
947
' Strip out null termination (ASCII zero)
922
- pvGetStringFileInfo = Replace(pvGetStringFileInfo, Chr$( 0 ), "" )
948
+ pvGetStringFileInfo = Replace(pvGetStringFileInfo, vbNullChar, vbNullString )
923
949
QH:
924
950
End Function
925
951
@@ -965,4 +991,3 @@ Private Function pvIsGuid(ByVal sValue As String) As Boolean
965
991
Const EMPTY_GUID As String = "{00000000-0000-0000-0000-000000000000}"
966
992
pvIsGuid = sValue Like Replace(EMPTY_GUID, "0" , "[0-9a-fA-F]" )
967
993
End Function
968
-
0 commit comments