简体   繁体   English

使用NSIS安装软件时,如何通过从目标文件夹获取路径来检查驱动器中的空间

[英]How to check the space in the drive by taking the path from the Destination Folder When installing the software using NSIS

How to check the space in the drive by taking the path from the Destination Folder When installing the software. 安装软件时,如何通过从目标文件夹获取路径来检查驱动器中的空间。

I am able to check the space of the specific drive (for eg, "C") using the below code snippet. 我可以使用下面的代码片段检查特定驱动器的空间(例如“ C”)。

But I want to take the drive or path from the Destination folder dynamically and check the space of the drive whether there is enough space or not. 但是我想从目标文件夹中动态获取驱动器或路径,并检查驱动器的空间是否有足够的空间。

!define sysGetDiskFreeSpaceEx 'kernel32::GetDiskFreeSpaceExA(t, *l, *l, *l) i'    
function CheckSpaceFunc
      IntCmp $2 0 ignorequota
      ; obey quota
      System::Call '${sysGetDiskFreeSpaceEx}(r1,.r2,,.)'
      goto converttokb
      ; ignore quota
      ignorequota:
      System::Call '${sysGetDiskFreeSpaceEx}(r1,.,,.r2)'
      converttokb:
      ; convert the large integer byte values into managable kb
      System::Int64Op $2 / 1024
      Pop $2
      ; check space
      System::Int64Op $2 > $0
      Pop $2
    functionend


    Section "TestApp"

      SectionIn RO


      StrCpy $0 40000 ; kb u need
      StrCpy $1 'c:' ; check drive c: for space
      Call CheckSpaceFunc
      IntCmp $2 1 okay
      MessageBox MB_OK "Error: Not enough disk space"
      okay:

    SectionEnd

Could anyone please help me 谁能帮我

The built-in directory page ( Page Directory or !insertmacro MUI_PAGE_DIRECTORY ) will perform the free space check for you and takes care of all the details. 内置目录页面( Page Directory!insertmacro MUI_PAGE_DIRECTORY )将为您执行可用空间检查并处理所有详细信息。

It might be tempting to just do StrCpy $1 $InstDir 3 to get the drive letter and perform the check yourself but this can give you the wrong result because NTFS supports mounting other volumes as a folder . 仅仅通过StrCpy $1 $InstDir 3来获取驱动器号并自己执行检查可能很诱人,但这会给您错误的结果,因为NTFS支持将其他卷作为文件夹挂载

GetDiskFreeSpaceEx does support directory paths but I believe the path has to exist so if you want to use $InstDir before $InstDir has been created then you must chop off subfolders until GetDiskFreeSpaceEx succeeds (or you only have a invalid drive letter left of the path). GetDiskFreeSpaceEx确实支持目录路径,但我认为该路径必须存在,因此,如果您想在$ InstDir创建之前使用$ InstDir,则必须斩断子文件夹,直到GetDiskFreeSpaceEx成功(否则路径的剩余驱动器号无效) 。

Your !define should also be changed from GetDiskFreeSpaceExA to GetDiskFreeSpaceEx because it uses the t string type. !define也应该从改变GetDiskFreeSpaceExAGetDiskFreeSpaceEx因为它使用了t字符串类型。 This will make it Unicode compatible. 这将使其与Unicode兼容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用NSIS安装软件时,如何设置进度条文本? - When installing the software using NSIS how to set the progress bar text? 在安装软件时,如果特定条件为假,如何使用NSIS回退软件安装过程? - when installing the software, if the specific condition is false How to roll back the software installation process using NSIS? 如何检查软件安装的文件夹并在NSIS中的相同路径中执行静默更新 - How to check the software installed folder and do the silent update in same path in NSIS 使用Nullsoft安装应用程序时,如何基于32/64位Windows OS在目标文件夹中显示路径 - When installing the application using Nullsoft, how to display the path in the Destination Folder based on the 32/64 bit windows OS 使用NSIS安装软件时如何更改用户帐户控制屏幕文本 - How to change the User Account Control screen text when installing the software using NSIS 如何检查NSIS中安装的软件? - how to check software installed in NSIS? 如何使用 NSIS 更改目录目标文件夹文本? - How to change the Directory Destination folder text using NSIS? 如何从URL链接下载文件并将其添加到nsis中的目标文件夹? - How to download the files from a URL link and add it to destination folder in nsis? 安装使用NSIS开发的软件时,如果在服务器操作系统中安装,应如何抛出弹出消息 - When installing the software that was developed using NSIS, how should I throw a pop-up message if installing in server operating systems Destination 文件夹中的路径附加到旧路径,而不是使用 NSIS 显示新路径 - Path in the Destination folder is appending to the old path instead of showing the new path using NSIS
相关标签
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM