CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Location
    Temuco, CHILE
    Posts
    161

    Cool Hooking a 'new drive connected' like USB, etc...

    Hi every1:

    My question is simple, but I feel the answer that may come is way complicated:

    Can I, and if I can, how do I, receive a notification when a new drive appears in the system because of a storage device pugged in? I want to receive notofication when a USB disk or external recorder is connected to the PC.

    Next to that, assumming I have recceived notification that a new drive (for example N:\) appears, how can I access the information regarding to which drive letter is this new devide assigned?

    In other words, I want the following me-system dialogue to occur:
    system: "hey, a new SONY USB disk --for example-- has come in!",
    me: "is that so? well... where is it?"
    system: "I've put it at N:\ so that you can work with it".

    The background for this problem is as follows:

    I am interested in creating a program which enforces the connection of a certain device to a certain letter (or to retrieve the letter than corresponds to that specific drive). That's because I'm expecting the external disk to contain a certain file which wll be used as a configuration file. When the device "appears", I ask for the presence or abscence of this file.
    If the file exists, I want that drive to be accessible fro a certain, fixed drive letter (such as Z:\), by either changing the drive letter, if possible, or adding a new drive that is an alias of this one. That I can do by "SUBST" or by another way, don't worry.
    The problem comes because the machines where this program is to be executed, have different number of drives. For example Machine #1 has drives up to F: (two HDD partitions, one DVD reader and one net folder), whereas Machine #2 has only up to D: (system disk and a CD-reader). I'm assumming, of course, no machine has drives up to N:\. I want in any machine my drive to appear as a certain drive letter. An external program is to use data from a certain drive (N:\), and I can not, by the moment, change the configuration to adapt any new drive letter coming. Working the external software in a folder and then synchronizing to wherever the external disk is, is not an option, mostly because "that's not a challenge".

    Hope u can give me some ideas. I'm not very good at the Windows platf, or kinda-stuff, but I'll take any help as a starting point to learn something anew, Thanks in advance.

  2. #2
    Join Date
    Mar 2004
    Location
    Temuco, CHILE
    Posts
    161

    Error when posting

    Plz discard this post, I've put it in the wrong section -- it should be "Visual C++ Programming" issue, not necesarily WinAPI..

    Sorry every1!

    I'm going to move this post

  3. #3
    Join Date
    May 2004
    Posts
    45

    Re: Hooking a 'new drive connected' like USB, etc...

    Search MSDN for MediaArrival, DeviceArrival, AutoPlay and IHWEventHandler

  4. #4
    Join Date
    Mar 2004
    Location
    Temuco, CHILE
    Posts
    161

    Re: Hooking a 'new drive connected' like USB, etc...

    Thanks!

    Looking for the IHW Interface and DeviceArrival gives me some hints about what should be done (and undone)... Looks there are two things of it, one related to DirectX --the interface-- and the other a windows message (BBT_DEVICEARRIVAL). As I am not familiarized with DirectX, I will skip this partcular one for later.

    The other thing was SystemInfo, which provides the interface DeviceArrival, and as I am more familiarized with ATL and ActiveX, I will try this one first.


    I am very glad of your help.

    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured