Old 3rd February 2012, 08:46   #1
C_10
Junior Member
 
Join Date: Feb 2012
Posts: 15
How to detect flash drive

Hi,

I want to detect a USB flash drive once the user connect it.
It should look like this:
code:
; Disable next button while USB flash drive not identified
GetDlgItem $0 $HWNDPARENT 1 ; next=1, cancel=2, back=3
EnableWindow $0 0
loop:
${If}
# usb is detected
${Else}
Goto loop
${EndIf}
; Enable next button
GetDlgItem $0 $HWNDPARENT 1
EnableWindow $0 1



I hope you have some ideas,
Thanks!
C_10 is offline   Reply With Quote
Old 3rd February 2012, 09:10   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
See this recent thread: http://forums.winamp.com/showthread.php?t=341152
MSG is offline   Reply With Quote
Old 7th February 2012, 11:34   #3
C_10
Junior Member
 
Join Date: Feb 2012
Posts: 15
Thanks! It works
C_10 is offline   Reply With Quote
Old 7th February 2012, 13:40   #4
C_10
Junior Member
 
Join Date: Feb 2012
Posts: 15
Now first of all my custom function search the flash drive and then I can see text/label/image and so on...
But i want it the other way round...

How can I do this?

code:
Function customFunction
nsDialogs::Create 1018
; Text, label, image
...
; Disable next button while USB flash drive not identified
GetDlgItem $0 $HWNDPARENT 1 ; next=1, cancel=2, back=3
EnableWindow $0 0
; Search flash drive
...
; Enable next button
GetDlgItem $0 $HWNDPARENT 1
EnableWindow $0 1
nsDialogs::Show
${NSD_FreeImage} $Image
FunctionEnd



Thanks
C_10 is offline   Reply With Quote
Old 10th February 2012, 07:48   #5
C_10
Junior Member
 
Join Date: Feb 2012
Posts: 15
Hmm, perhaps I should attach some images.

While searching the flash drive I can't see the images/labels (see attachments).
But I want that you can see the page with all components first, and after that the installer should search the flash drive.

I hope you understand what I mean, please help
Attached Thumbnails
Click image for larger version

Name:	shouldLookLikeThis.jpg
Views:	268
Size:	34.9 KB
ID:	49442   Click image for larger version

Name:	whileSearching.jpg
Views:	272
Size:	26.7 KB
ID:	49443  
C_10 is offline   Reply With Quote
Old 10th February 2012, 08:29   #6
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Once you do nsDialogs::Show, the installer will wait until the Next button is pressed (or any other button which has a callback function defined). The installer cannot wait for two things at the same time (Next button and flash drive). So you'll need to do the flashdrive search in the page's leave function. The page would then say "please insert the flash drive and click Next to continue". If in the leave function no drive is found, call abort and the installer will stay on the 'please insert' page.
MSG is offline   Reply With Quote
Old 10th February 2012, 09:20   #7
C_10
Junior Member
 
Join Date: Feb 2012
Posts: 15
Thanks MSG! That's a good idea, but I've one problem:

Quote:
So you'll need to do the flashdrive search in the page's leave function
I've a custom page, so I can't use "!define MUI_PAGE_CUSTOMFUNCTION_LEAVE"
Can I copy the flashdrive search after
nsDialogs::Show
${NSD_FreeImage} $Image
and make so my own customFunction leave?

code:
Function customFunction
nsDialogs::Create 1018
; Text, label, image
...
nsDialogs::Show
${NSD_FreeImage} $Image

; search flash drive
...
MessageBox MB_YESNO "Leave Function TEST! Go to next page?" IDYES +2
Abort

FunctionEnd



I can see the MessageBox, but when I click on "No", I'm on the next page anyway...
C_10 is offline   Reply With Quote
Old 10th February 2012, 09:58   #8
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Page custom customFunction customLeaveFunction

http://nsis.sourceforge.net/Docs/Chapter4.html#4.5.4
MSG is offline   Reply With Quote
Old 10th February 2012, 11:14   #9
C_10
Junior Member
 
Join Date: Feb 2012
Posts: 15
Thanks again MSG!!!

My problem is solved
C_10 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
detect, flash drive, usb

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump