开发者

Retrieving and displaying the Disk Volume Serial number in NSIS

开发者 https://www.devze.com 2023-04-12 19:00 出处:网络
I am using NS开发者_JAVA百科IS(HM NISedit 2.0.3 for editor) for building setup(s) of my application.

I am using NS开发者_JAVA百科IS(HM NISedit 2.0.3 for editor) for building setup(s) of my application. I am having a requirement for one of my setups to use the Disk volume serial number(in Hexadecimal format).I also need to display the same in a message box. Can someone please post me the complete piece of script for getting the Disk Volume serial number displaying it in a Message box?


This page describes how to retrieve the serial number in hex format:

http://nsis.sourceforge.net/Get_Disk_Volume_Serial_Number

So to do what you need include this function in your script:

Function ShowDiskVolumeSerialNumber
  !define GetVolumeInformation "Kernel32::GetVolumeInformation(t,t,i,*i,*i,*i,t,i) i"
  System::Call '${GetVolumeInformation ("$0",,${NSIS_MAX_STRLEN},.r0,,,,${NSIS_MAX_STRLEN})'
  IntFmt $0 "%08X" $0
  MessageBox MB_OK $0
FunctionEnd

and call it like this:

StrCpy $0 "C:\\"
Call ShowDiskVolumeSerialNumber

Obviously you can replace the drive letter with whatever you like but ensure it has a double trailing backslash .

0

精彩评论

暂无评论...
验证码 换一张
取 消