EnumCDs plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Added category links.)
(System plug-in alternative)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{|align=right
{{PageAuthor|cube}}
|<small>Author: [[{{ns:2}}:cube|cube]] ([[{{ns:3}}:cube|talk]], [[{{ns:-1}}:Contributions/cube|contrib]])</small>
 
|}
<br style="clear:both;">
<attach>EnumCDs.zip</attach>
<attach>EnumCDs.zip</attach>


Line 33: Line 31:
</highlight-nsis>
</highlight-nsis>


[[{{ns:14}}:Plugins]]
== System plug-in alternative ==
<highlight-nsis>
!include LogicLib.nsh
!define /IfNDef DRIVE_CDROM 5
 
Section
System::Call 'KERNEL32::GetLogicalDrives()i.r3'
${ForEach} $2 0 26 + 1
IntOp $1 1 << $2
${If} $3 & $1
IntOp $1 65 + $2
IntFmt $1 "%c:\" $1
System::Call 'KERNEL32::GetDriveType(tr1)i.r4'
${If} $4 = ${DRIVE_CDROM}
DetailPrint "Drive $1"
${EndIf}
${EndIf}
${Next}
SectionEnd
</highlight-nsis>
 
[[Category:Plugins]]

Latest revision as of 21:48, 7 June 2021

Author: cube (talk, contrib)


EnumCDs.zip (3 KB)

Plug-in originally written by cube. Tweaked, compiled and uploaded by KiCHiK

Description

This plug-in will return every available CD-ROM drive on the user's machine one by one.

This plug-in requires NSIS 2.

Put EnumCDs.dll in the Plugins directory under the directory where you installed NSIS.

How To Use

To use it call EnumCDs::next with the /NOUNLOAD flag, and keep popping the results, the CD-ROM drive letters, one by one until the plug-in pushes "done". Then call EnumCDs::next once more without the /NOUNLOAD flag, pop the second "done" and you're done.

Example

again:
  EnumCDs::next /NOUNLOAD
  Pop $0
  StrCmp $0 "error" done
  DetailPrint $0
StrCmp $0 "done" done again
done:
  EnumCDs::next
  Pop $0

System plug-in alternative

!include LogicLib.nsh
!define /IfNDef DRIVE_CDROM 5
 
Section
System::Call 'KERNEL32::GetLogicalDrives()i.r3'
${ForEach} $2 0 26 + 1
	IntOp $1 1 << $2
	${If} $3 & $1
		IntOp $1 65 + $2 
		IntFmt $1 "%c:\" $1
		System::Call 'KERNEL32::GetDriveType(tr1)i.r4'
		${If} $4 = ${DRIVE_CDROM}
			DetailPrint "Drive $1"
		${EndIf}
	${EndIf}
${Next}
SectionEnd