Retrieving Connected Mapped Network Drives: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 53: Line 53:
FunctionEnd
FunctionEnd
</highlight-nsis>
</highlight-nsis>
== License ==
This function is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this function.
Permission is granted to anyone to use this header file for any purpose,
including commercial applications, and to alter it and redistribute
it freely.


[[Category:Disk, Path & File Functions]]
[[Category:Disk, Path & File Functions]]

Revision as of 05:56, 17 January 2007

Author: Red Wine (talk, contrib)


Description

Just a simple function that retrieves from registry the mapped network drives on a system, and returns only those that are actually connected.

Invoke the function

  ;call the function
  call FindNetDrives
  ;get the result
  Pop $R0
  ;at this point $R0 contais error if no mapped drive found
  DetailPrint '$R0'

The Function

Function FindNetDrives
  Push $2
  Push $1
  Push $0
 
  StrCpy $2 ''
  StrCpy $0 0
 
loop:
  EnumRegKey $1 HKCU Network $0
  StrCmp $1 "" exit
  IfFileExists '$1:\*' 0 +2
  StrCpy '$2' '$2 $1'
  IntOp $0 $0 + 1
  goto loop
 
exit:
  StrCmp $2 '' nonetdrv done
 
nonetdrv: ;not found mapped network drive
  Push 'error'
  Exch 3
  Exch 2
  Exch
  goto end 
 
done:   ;found mapped network drives
  Push '$2'
  Exch 3
  Exch 2
  Exch
 
end:
  Pop $0
  Pop $1
  Pop $2
FunctionEnd

License

This function is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this function.

Permission is granted to anyone to use this header file for any purpose, including commercial applications, and to alter it and redistribute it freely.