Click here to Skip to main content
16,006,382 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Variation on string manipulation Pin
Luc Pattyn17-Sep-09 14:44
sitebuilderLuc Pattyn17-Sep-09 14:44 
AnswerRe: Variation on string manipulation Pin
Steven J Jowett18-Sep-09 2:56
Steven J Jowett18-Sep-09 2:56 
AnswerRe: Variation on string manipulation Pin
Hurricane300018-Sep-09 7:00
Hurricane300018-Sep-09 7:00 
AnswerRe: Variation on string manipulation Pin
BluesEnd19-Sep-09 14:13
BluesEnd19-Sep-09 14:13 
GeneralRe: Variation on string manipulation Pin
Dave Kreskowiak19-Sep-09 14:26
mveDave Kreskowiak19-Sep-09 14:26 
QuestionRead file name from USB flash drive & based on file name copy few files on USB flash drive - all through an application Pin
Sagar Mishra17-Sep-09 13:45
Sagar Mishra17-Sep-09 13:45 
AnswerRe: Read file name from USB flash drive & based on file name copy few files on USB flash drive - all through an application Pin
Christian Graus17-Sep-09 14:01
protectorChristian Graus17-Sep-09 14:01 
AnswerRe: Read file name from USB flash drive & based on file name copy few files on USB flash drive - all through an application Pin
Luc Pattyn17-Sep-09 14:55
sitebuilderLuc Pattyn17-Sep-09 14:55 
Hi,

nothing strange about that. Here are some pointers:

1.
inserting/removing a device generates a Windows message, which you can capture by overriding WndProc in your Form; here is a skeleton method for that (sorry it is C# code, VB.NET code can do similar things):

// warning: not sure the values are the same for every windows version! They work well on XP and Vista.
			WM_DEVICECHANGE = 0x0219,
			DBT_DEVICEARRIVAL= 0x8000,
			DBT_DEVICEREMOVECOMPLETE= 0x8004,

protected override void WndProc(ref Message m) {
	if (m.Msg==WM_DEVICECHANGE) {
		int wParam=(int)m.WParam;
		int lParam=(int)m.LParam;
		log("WM_DEVICECHANGE wParam="+wParam.ToString("X8")+" lParam="+lParam.ToString("X8"));
		if (wParam==DBT_DEVICEARRIVAL) DeviceAdded();
		else if (wParam==DBT_DEVICEREMOVECOMPLETE) DeviceRemoved();
	}
}

DeviceAdded() would be your method where most of the action is.

2.
rather than having text files to identify the users, I would use the unique ID that seems to be present in most if not all USB memory sticks; it can be obtained using WMI. Advantage is it is much more tamper proof, users could easily change their text file (unless you somehow encrypted it).

3.
warning: depending on USB stick manufacturer, Windows version, and/or system settings, the stick may or may not be cached; when it is, you need to use "Safely remove hardware" otherwise the next time the stick gets inserted in some system, a dialog "Should I scan and fix..." would appear.

Smile | :)

Luc Pattyn

Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.

Local announcement (Antwerp region): Lange Wapper? Neen!


modified on Thursday, September 17, 2009 9:25 PM

GeneralRe: Read file name from USB flash drive & based on file name copy few files on USB flash drive - all through an application Pin
Sagar Mishra17-Sep-09 15:34
Sagar Mishra17-Sep-09 15:34 
GeneralRe: Read file name from USB flash drive & based on file name copy few files on USB flash drive - all through an application Pin
Luc Pattyn17-Sep-09 15:45
sitebuilderLuc Pattyn17-Sep-09 15:45 
AnswerRe: Read file name from USB flash drive & based on file name copy few files on USB flash drive - all through an application Pin
darkelv17-Sep-09 16:29
darkelv17-Sep-09 16:29 
AnswerRe: Read file name from USB flash drive & based on file name copy few files on USB flash drive - all through an application Pin
Dave Kreskowiak18-Sep-09 1:42
mveDave Kreskowiak18-Sep-09 1:42 
GeneralRe: Read file name from USB flash drive & based on file name copy few files on USB flash drive - all through an application Pin
Luc Pattyn18-Sep-09 2:52
sitebuilderLuc Pattyn18-Sep-09 2:52 
QuestionAnonymous browser Pin
raggabox17-Sep-09 6:24
raggabox17-Sep-09 6:24 
AnswerRe: Anonymous browser Pin
Dave Kreskowiak17-Sep-09 6:43
mveDave Kreskowiak17-Sep-09 6:43 
GeneralRe: Anonymous browser Pin
raggabox17-Sep-09 6:59
raggabox17-Sep-09 6:59 
GeneralRe: Anonymous browser Pin
Dave Kreskowiak17-Sep-09 7:23
mveDave Kreskowiak17-Sep-09 7:23 
GeneralRe: Anonymous browser Pin
raggabox17-Sep-09 7:30
raggabox17-Sep-09 7:30 
GeneralRe: Anonymous browser Pin
DJ Matthews17-Sep-09 7:37
DJ Matthews17-Sep-09 7:37 
GeneralRe: Anonymous browser Pin
raggabox17-Sep-09 9:12
raggabox17-Sep-09 9:12 
GeneralRe: Anonymous browser Pin
Dave Kreskowiak17-Sep-09 15:16
mveDave Kreskowiak17-Sep-09 15:16 
QuestionRight Click Menu Pin
led12317-Sep-09 5:37
led12317-Sep-09 5:37 
Questionhow to format [modified] Pin
rbjanaki17-Sep-09 3:05
rbjanaki17-Sep-09 3:05 
AnswerRe: how to format Pin
Luc Pattyn17-Sep-09 4:32
sitebuilderLuc Pattyn17-Sep-09 4:32 
GeneralRe: how to format Pin
rbjanaki17-Sep-09 5:19
rbjanaki17-Sep-09 5:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.