NSIS GetVolumeInformation 结果
NSIS GetVolumeInformation Results
好的,我从另一个问题中找到了这段代码,我是 NSIS 的新手。下面的问题
!define FILE_SUPPORTS_ENCRYPTION 0x00020000
!define FILE_READ_ONLY_VOLUME 0x00080000
!define FILE_VOLUME_QUOTAS 0x00000020
!macro MakeBitFlagYesNo flags bit outvar
IntOp ${outvar} ${flags} & ${bit}
${IfThen} ${outvar} <> 0 ${|} StrCpy ${outvar} "Yes" ${|}
${IfThen} ${outvar} == 0 ${|} StrCpy ${outvar} "No" ${|}
!macroend
StrCpy [=10=] "c:\"
System::Call 'Kernel32::GetVolumeInformation(t "[=10=]",t,i ${NSIS_MAX_STRLEN},*i,*i,*i.r1,t,i ${NSIS_MAX_STRLEN})i.r0'
${If} [=10=] <> 0
!insertmacro MakeBitFlagYesNo ${FILE_SUPPORTS_ENCRYPTION}
!insertmacro MakeBitFlagYesNo ${FILE_READ_ONLY_VOLUME}
!insertmacro MakeBitFlagYesNo ${FILE_VOLUME_QUOTAS}
MessageBox mb_ok "flags= $\nFILE_SUPPORTS_ENCRYPTION=$\nFILE_READ_ONLY_VOLUME=$\nFILE_VOLUME_QUOTAS="
${EndIf}
这是我需要得到的:
驱动器卷标:
文件系统:(Fat32、NTFS、exFat...)
磁盘容量:(7.27TB,5.59TB,...)
免费 Space:(4.62TB,632GB,...)
分配单元大小:(4096b、16kb、32kb、...)
然后我需要在 if then 语句中使用该信息
只是不知道如何将上面的代码和结果变成下面的代码列表。
我已经尝试搜索 google 有关 NSIS 和 GetVolumeInformation 的信息,但使用 GetVolumeInformation 我找不到如何在任何地方获取和读取结果。
${If} $File_System <> "NTFS"
${EndIf}
${If} $Disk_Capacity < "1.86TB"
${EndIf}
${If} $Free_Space < "1.25TB"
${EndIf}
${If} $Allocation_Unit_Size <> "4096 bytes"
${EndIf}
MessageBox mb_ok "$Drive_Volume_Label$\n$File_System$\n$Disk_Capacity$\n$Free_Space$\n$Allocation_Unit_Size"
如果你可以 post 给我答案代码,然后告诉我你从哪里得到代码的信息(解释)。如果我知道它为我需要做什么,这有助于我更快地学习代码。
谢谢,
艾伯特
answer you found does actually return the name of the file system and then it goes on to tell you that that is probably not the best way to do things. You should use the file system flags if possible. Case in point, Microsofts new file system ReFS 中的代码支持一些 NTFS 功能并添加了一些新的可靠性功能。
!include LogicLib.nsh
StrCpy "c:\"
System::Call 'Kernel32::GetVolumeInformation(t "",t.r3,i ${NSIS_MAX_STRLEN},*i,*i,*i.r1,t.r2,i ${NSIS_MAX_STRLEN})i.r0'
${If} [=10=] <> 0
IntFmt "%#.8x"
MessageBox MB_OK " FileSystemFlags= $\n FileSystemName= $\n VolumeName="
${If} == "NTFS"
MessageBox MB_OK " is NTFS"
${Else}
MessageBox MB_OK " is and not NTFS but hopefully you don't care"
${EndIf}
${EndIf}
您的其他属性不会被此函数公开,如果您查看它的 documentation on MSDN.
就会很明显
!include LogicLib.nsh
StrCpy "c:\"
System::Call 'Kernel32::GetDiskFreeSpaceEx(t "", *l.r1, *l.r2, *l.r3)i.r0' ; This function does not work on Windows 95
${If} [=11=] <> 0
MessageBox MB_OK " FreeBytesAvailable= $\n TotalNumberOfBytes= $\n TotalNumberOfFreeBytes="
System::Call 'ShLwApi::StrFormatByteSizeW(l , w.r4, i ${NSIS_MAX_STRLEN})'
MessageBox MB_OK "Friendly FreeBytesAvailable: " ; For display in UI only!
!define /math MYSIZE 0x100000 * 666 ; 666 MiB
${If} L>= ${MYSIZE}
MessageBox MB_OK "Disk quota on allows you to write at least ${MYSIZE} bytes on this volume"
${Else}
MessageBox MB_OK|MB_ICONSTOP "Not enough space on volume, ${MYSIZE} bytes required!"
Quit
${EndIf}
${EndIf}
NSIS 已经提供了检查磁盘的目录页面 space,如果可能请使用它。注意:您不能比较不同比例的数字(TB 与 GB 等),您必须比较 64 位字节数。
按分配单位我假设你在谈论 cluster size?
!include LogicLib.nsh
StrCpy "c:\"
System::Call 'Kernel32::GetDiskFreeSpace(t "", *i.r1, *i.r2, *i, *i)i.r0'
${If} [=12=] <> 0
IntOp *
System::Call 'ShLwApi::StrFormatByteSizeW(l , w.r3, i ${NSIS_MAX_STRLEN})'
MessageBox MB_OK "Cluster size: ( bytes)"
${If} 4096 <>
; ...
${EndIf}
${EndIf}
(报告的簇大小可能是逻辑大小,而不是物理大小)
好的,我从另一个问题中找到了这段代码,我是 NSIS 的新手。下面的问题
!define FILE_SUPPORTS_ENCRYPTION 0x00020000
!define FILE_READ_ONLY_VOLUME 0x00080000
!define FILE_VOLUME_QUOTAS 0x00000020
!macro MakeBitFlagYesNo flags bit outvar
IntOp ${outvar} ${flags} & ${bit}
${IfThen} ${outvar} <> 0 ${|} StrCpy ${outvar} "Yes" ${|}
${IfThen} ${outvar} == 0 ${|} StrCpy ${outvar} "No" ${|}
!macroend
StrCpy [=10=] "c:\"
System::Call 'Kernel32::GetVolumeInformation(t "[=10=]",t,i ${NSIS_MAX_STRLEN},*i,*i,*i.r1,t,i ${NSIS_MAX_STRLEN})i.r0'
${If} [=10=] <> 0
!insertmacro MakeBitFlagYesNo ${FILE_SUPPORTS_ENCRYPTION}
!insertmacro MakeBitFlagYesNo ${FILE_READ_ONLY_VOLUME}
!insertmacro MakeBitFlagYesNo ${FILE_VOLUME_QUOTAS}
MessageBox mb_ok "flags= $\nFILE_SUPPORTS_ENCRYPTION=$\nFILE_READ_ONLY_VOLUME=$\nFILE_VOLUME_QUOTAS="
${EndIf}
这是我需要得到的:
驱动器卷标:
文件系统:(Fat32、NTFS、exFat...)
磁盘容量:(7.27TB,5.59TB,...)
免费 Space:(4.62TB,632GB,...)
分配单元大小:(4096b、16kb、32kb、...)
然后我需要在 if then 语句中使用该信息 只是不知道如何将上面的代码和结果变成下面的代码列表。
我已经尝试搜索 google 有关 NSIS 和 GetVolumeInformation 的信息,但使用 GetVolumeInformation 我找不到如何在任何地方获取和读取结果。
${If} $File_System <> "NTFS"
${EndIf}
${If} $Disk_Capacity < "1.86TB"
${EndIf}
${If} $Free_Space < "1.25TB"
${EndIf}
${If} $Allocation_Unit_Size <> "4096 bytes"
${EndIf}
MessageBox mb_ok "$Drive_Volume_Label$\n$File_System$\n$Disk_Capacity$\n$Free_Space$\n$Allocation_Unit_Size"
如果你可以 post 给我答案代码,然后告诉我你从哪里得到代码的信息(解释)。如果我知道它为我需要做什么,这有助于我更快地学习代码。
谢谢, 艾伯特
answer you found does actually return the name of the file system and then it goes on to tell you that that is probably not the best way to do things. You should use the file system flags if possible. Case in point, Microsofts new file system ReFS 中的代码支持一些 NTFS 功能并添加了一些新的可靠性功能。
!include LogicLib.nsh
StrCpy "c:\"
System::Call 'Kernel32::GetVolumeInformation(t "",t.r3,i ${NSIS_MAX_STRLEN},*i,*i,*i.r1,t.r2,i ${NSIS_MAX_STRLEN})i.r0'
${If} [=10=] <> 0
IntFmt "%#.8x"
MessageBox MB_OK " FileSystemFlags= $\n FileSystemName= $\n VolumeName="
${If} == "NTFS"
MessageBox MB_OK " is NTFS"
${Else}
MessageBox MB_OK " is and not NTFS but hopefully you don't care"
${EndIf}
${EndIf}
您的其他属性不会被此函数公开,如果您查看它的 documentation on MSDN.
就会很明显!include LogicLib.nsh
StrCpy "c:\"
System::Call 'Kernel32::GetDiskFreeSpaceEx(t "", *l.r1, *l.r2, *l.r3)i.r0' ; This function does not work on Windows 95
${If} [=11=] <> 0
MessageBox MB_OK " FreeBytesAvailable= $\n TotalNumberOfBytes= $\n TotalNumberOfFreeBytes="
System::Call 'ShLwApi::StrFormatByteSizeW(l , w.r4, i ${NSIS_MAX_STRLEN})'
MessageBox MB_OK "Friendly FreeBytesAvailable: " ; For display in UI only!
!define /math MYSIZE 0x100000 * 666 ; 666 MiB
${If} L>= ${MYSIZE}
MessageBox MB_OK "Disk quota on allows you to write at least ${MYSIZE} bytes on this volume"
${Else}
MessageBox MB_OK|MB_ICONSTOP "Not enough space on volume, ${MYSIZE} bytes required!"
Quit
${EndIf}
${EndIf}
NSIS 已经提供了检查磁盘的目录页面 space,如果可能请使用它。注意:您不能比较不同比例的数字(TB 与 GB 等),您必须比较 64 位字节数。
按分配单位我假设你在谈论 cluster size?
!include LogicLib.nsh
StrCpy "c:\"
System::Call 'Kernel32::GetDiskFreeSpace(t "", *i.r1, *i.r2, *i, *i)i.r0'
${If} [=12=] <> 0
IntOp *
System::Call 'ShLwApi::StrFormatByteSizeW(l , w.r3, i ${NSIS_MAX_STRLEN})'
MessageBox MB_OK "Cluster size: ( bytes)"
${If} 4096 <>
; ...
${EndIf}
${EndIf}
(报告的簇大小可能是逻辑大小,而不是物理大小)