Three topics - help greatly appreciated!
-
- How to get a list of all drive letters and names, including USB-memory sticks, eg. "D: Removable drive"? Am I right that every drive has an individual ID-number or name? If so, how to get this name/ID from vb.net? I would like to compare if the two USB sticks are the same when used one after the other in the same USB-port. 2) What code snippet would tell my app to make "foo.exe" start on every Windows log in? 3) Is there an API to compress a folder into a zip-file or is the only way to use some 3rd party command line application?
-
- How to get a list of all drive letters and names, including USB-memory sticks, eg. "D: Removable drive"? Am I right that every drive has an individual ID-number or name? If so, how to get this name/ID from vb.net? I would like to compare if the two USB sticks are the same when used one after the other in the same USB-port. 2) What code snippet would tell my app to make "foo.exe" start on every Windows log in? 3) Is there an API to compress a folder into a zip-file or is the only way to use some 3rd party command line application?
1 - The System.IO namespace has a class that returns a list of all drives. All drives do have a semi unique ID/name, that would require WMI. They can have a name given to them when formatted, .NET can see that, I suspect most USB drives wouldn't have it. 2 - none, as your app would not be running. Put a shortcut to foo.exe in the run registry key ( I search for runonce, to find it, it's the first one above ), or in the Startup folder of the start menu 3 - are you using .NET 2.0 ? If so, there is zip support in the framework.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
- How to get a list of all drive letters and names, including USB-memory sticks, eg. "D: Removable drive"? Am I right that every drive has an individual ID-number or name? If so, how to get this name/ID from vb.net? I would like to compare if the two USB sticks are the same when used one after the other in the same USB-port. 2) What code snippet would tell my app to make "foo.exe" start on every Windows log in? 3) Is there an API to compress a folder into a zip-file or is the only way to use some 3rd party command line application?
You can place a shortcut to your app or that exe in the start menu:
start->all programs->startup
. or you can create a value in the registry subkey:HKEY_CURRENTUSER\SOFTWARE\MICROSOFT\WINDOWS\CURRENT VERSION\RUN
that references your program.Posted by The ANZAC
-
1 - The System.IO namespace has a class that returns a list of all drives. All drives do have a semi unique ID/name, that would require WMI. They can have a name given to them when formatted, .NET can see that, I suspect most USB drives wouldn't have it. 2 - none, as your app would not be running. Put a shortcut to foo.exe in the run registry key ( I search for runonce, to find it, it's the first one above ), or in the Startup folder of the start menu 3 - are you using .NET 2.0 ? If so, there is zip support in the framework.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
1. Yes, I am using .NET 2.0. How to use this zip support. Could you give me an example code to zip folder and all its subdirectories in "C:\temp\" to folder "D:\here" with the file name "myfold.zip". 2. How to make a registry entry for the startup? Could you give me an example code.
-
1 - The System.IO namespace has a class that returns a list of all drives. All drives do have a semi unique ID/name, that would require WMI. They can have a name given to them when formatted, .NET can see that, I suspect most USB drives wouldn't have it. 2 - none, as your app would not be running. Put a shortcut to foo.exe in the run registry key ( I search for runonce, to find it, it's the first one above ), or in the Startup folder of the start menu 3 - are you using .NET 2.0 ? If so, there is zip support in the framework.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
So, what would be the best way to recognize if the inserted USB memory stick / USB hardrive is the same as the one used before?
-
So, what would be the best way to recognize if the inserted USB memory stick / USB hardrive is the same as the one used before?
This is used to detect when someone inserts or removes a USB drive, cd or dvd, provising plug and play is still on. It also tells you what kind of drive is used so I hope this can point you in the right direction or at least allows you to snip bits out.
Private Const GWL_WNDPROC As Long = (-4) Private Const WM_DEVICECHANGE As Long = &H219 Private Const DBT_DEVNODES_CHANGED As Long = &H7 Private Const DBT_DEVICEARRIVAL As Long = &H8000& Private Const DBT_DEVICEREMOVECOMPLETE As Long = &H8004& Private Const DBT_DEVTYP_VOLUME As Long = &H2 ' Logical volume Private Const DBT_DEVTYP_DEVICEINTERFACE As Long = &H5 ' Device interface class Private Const DBTF_MEDIA As Long = &H1 ' Media comings and goings Private Const DBTF_NET As Long = &H2 ' Network volume Private Enum DriveType As Integer DRIVE_UNKNOWN = 0 DRIVE_NO_ROOT_DIR = 1 DRIVE_REMOVABLE = 2 DRIVE_FIXED = 3 DRIVE_REMOTE = 4 DRIVE_CDROM = 5 DRIVE_RAMDISK = 6 End Enum Private Structure DEV_BROADCAST_HDR Public dbch_size As Integer Public dbch_devicetype As Integer Public dbch_reserved As Integer End Structure Private Structure DEV_BROADCAST_VOLUME Public dbcv_size As Integer Public dbcv_devicetype As Integer Public dbcv_reserved As Integer Public dbcv_unitmask As Integer Public dbcv_Flags As Short End Structure Private Declare Auto Function GetDriveType Lib "kernel32.dll" (ByVal nDrive As String) As DriveType Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = WM_DEVICECHANGE Then Dim WParam As Int32 = m.WParam.ToInt32() Dim dInfo As String = "" Select Case WParam Case DBT_DEVICEARRIVAL dInfo = showInfo(m, WParam) If Me.advancedMode Then If MsgBox("New Drive Detected: " & dInfo & vbCrLf & "Would you like to view the images on the drive?", CType(MsgBoxStyle.Question + MsgBoxStyle.YesNo, MsgBoxStyle), "New Drive Detected") = MsgBoxResult.Yes Then 'Me.treeBrowse_ExpTreeNodeSelected(Split$(dInfo, ":")(0) & ":\", ) loadImages(Split$(dInfo, ":")(0) & ":\") End If Else loadImagesUploader(Split$(dInfo, ":")(0) & ":\") End If