Unmounting a AFP volume (removing it from desktop)

Ask a Question related to Mac Programming, Design and Development.

  1. #1

    Default Unmounting a AFP volume (removing it from desktop)

    Hello everybody,

    Hopefully someone can give me help figuring out a way to make this
    work. What I'm trying to do is simply unmount an AFP volume, with this
    I mean to remove it from the desktop. I have tried the Carbon
    "UnmountVol" function, but although returns me no error, the volume
    still appears on my desktop ... this is my code:

    OSErr osErr;
    osErr = UnmountVol("\pMyVolume", 0); // osErr = noErr

    Do I need to call another function after that?? ... I have tried the
    MoreFiles "UnmountAndEject" function with the same results :

    OSErr osErr;
    osErr = UnmountAndEject("\pMyVolume", 0); // osErr = noErr

    Any ideas?
    Thanks in advance ...

    Roberto
    Jorge Guest

  2. Similar Questions and Discussions

    1. Problem unmounting a NFS filesystem
      Hello everybody, I'm having a 'little' problem while unmounting a NFS filesystem. Some days ago I change the IP address of a lab machine that was...
    2. when volume changes a beep sounds at the new volume
      A beep sounds every time a change the volume. I have turned off all the windows sounds in control pannel -> Sounds. I've looked in every other...
    3. removing desktop icons
      I'm new to XP and haven't yet been able to find the method of removing the desktop icons for "shortcut to web sites" and "contains letters,...
    4. [SOLVED] forcibly unmounting and bash history
      First of all, why didn't post it to the list? Do you think it's too OT? But, on the other hand, both your mails were no help and also misleading....
    5. Removing desktop icon from one account is removing from all accounts
      Using XP Professional. I want the Guest account to have only a few icons. The other two accounts should have many more. When I remove the icon...
  3. #2

    Default Re: Unmounting a AFP volume (removing it from desktop)

    In article <4beb34a4.0309031110.256b2f23@posting.google.com >,
    [email]rgasparini29@yahoo.com[/email] (Jorge) wrote:
    > Hopefully someone can give me help figuring out a way to make this
    > work. What I'm trying to do is simply unmount an AFP volume, with this
    > I mean to remove it from the desktop. I have tried the Carbon
    > "UnmountVol" function, but although returns me no error, the volume
    > still appears on my desktop ... this is my code:
    >
    > OSErr osErr;
    > osErr = UnmountVol("\pMyVolume", 0); // osErr = noErr
    >
    > Do I need to call another function after that?? ... I have tried the
    > MoreFiles "UnmountAndEject" function with the same results :
    >
    > OSErr osErr;
    > osErr = UnmountAndEject("\pMyVolume", 0); // osErr = noErr
    >
    > Any ideas?
    Try adding a trailing ":", as in:

    osErr = UnmountAndEject("\pMyVolume:", 0);

    or, try using applescript: open script editor, then paste in:

    tell application "Finder"
    eject alias "MyVolume:"
    end

    If that works, (and it does for me.) you can look up some of my previous
    postings on pasting compiled appleScript into the resource fork of your
    application, then calling the compiled appleScript with parameters from
    C/C++ code.
    -- David Phillip Oster
    David Phillip Oster Guest

  4. #3

    Default Re: Unmounting a AFP volume (removing it from desktop)

    Thanks David,

    The first option doesn't work, the result is the same. But I'm gonna
    check the applescript alternative ...

    Thank you!
    Regards ...


    David Phillip Oster <oster@ieee.org> wrote in message news:<oster-0FBE53.14514703092003@news.sf.sbcglobal.net>...
    > In article <4beb34a4.0309031110.256b2f23@posting.google.com >,
    > [email]rgasparini29@yahoo.com[/email] (Jorge) wrote:
    >
    > > Hopefully someone can give me help figuring out a way to make this
    > > work. What I'm trying to do is simply unmount an AFP volume, with this
    > > I mean to remove it from the desktop. I have tried the Carbon
    > > "UnmountVol" function, but although returns me no error, the volume
    > > still appears on my desktop ... this is my code:
    > >
    > > OSErr osErr;
    > > osErr = UnmountVol("\pMyVolume", 0); // osErr = noErr
    > >
    > > Do I need to call another function after that?? ... I have tried the
    > > MoreFiles "UnmountAndEject" function with the same results :
    > >
    > > OSErr osErr;
    > > osErr = UnmountAndEject("\pMyVolume", 0); // osErr = noErr
    > >
    > > Any ideas?
    >
    > Try adding a trailing ":", as in:
    >
    > osErr = UnmountAndEject("\pMyVolume:", 0);
    >
    > or, try using applescript: open script editor, then paste in:
    >
    > tell application "Finder"
    > eject alias "MyVolume:"
    > end
    >
    > If that works, (and it does for me.) you can look up some of my previous
    > postings on pasting compiled appleScript into the resource fork of your
    > application, then calling the compiled appleScript with parameters from
    > C/C++ code.
    > -- David Phillip Oster
    Jorge Guest

  5. #4

    Default Re: Unmounting a AFP volume (removing it from desktop)

    I wrote:
    > tell application "Finder"
    > eject alias "MyVolume:"
    > end
    That is what I use.

    In article <4beb34a4.0309040714.2649e3de@posting.google.com >,
    [email]rgasparini29@yahoo.com[/email] (Jorge) wrote:
    > The first option doesn't work, the result is the same. But I'm gonna
    > check the applescript alternative ...
    >
    In C++, using part of PowerPlant, it looks like this:

    static void TellFinderEject(ConstStringPtr inPathS){
    StAEDescriptor ae;
    OSType sig = 'MACS';
    StAEDescriptor aeDest(typeApplSignature, &sig, sizeof sig);
    StAEDescriptor aeAH;
    FSSpec fs;
    ThrowIfOSErr_(FSMakeFSSpec(0, 0, inPathS, &fs));
    AliasHandle ah = NULL;
    ThrowIfOSErr_(NewAliasMinimal(&fs, &ah));
    HLock((Handle) ah);
    UAEDesc::AddPtr(aeAH, 0, typeAlias, *ah, GetHandleSize((Handle) ah));
    if(NULL != ah){
    DisposeHandle((Handle) ah);
    }
    ThrowIfOSErr_(AECreateAppleEvent(kAEFinderSuite, kAEEject, aeDest,
    kAutoGenerateReturnID, kAnyTransactionID, ae));
    UAEDesc::AddKeyDesc(ae, keyDirectObject, aeAH);
    UAppleEventsMgr::SendAppleEvent(ae);
    }

    and I call it like this:

    TellFinderEject("\pMyVolume:");
    David Phillip Oster Guest

  6. #5

    Default Re: Unmounting a AFP volume (removing it from desktop)

    Per discussion on carbon development list a couple of weeks ago you should
    avoid making minimal aliases when sending events to Finder in Mac OS X
    because they might not be properly resolved (it is some weird limitation of
    OS X Finder). You should create full alias instead.

    Tom
    Abracode


    On 9/4/03 11:00 AM, in article
    [email]oster-6C3B60.08593904092003@news.sf.sbcglobal.net[/email], "David Phillip Oster"
    <oster@ieee.org> wrote:
    > I wrote:
    >> tell application "Finder"
    >> eject alias "MyVolume:"
    >> end
    >
    > That is what I use.
    >
    > In article <4beb34a4.0309040714.2649e3de@posting.google.com >,
    > [email]rgasparini29@yahoo.com[/email] (Jorge) wrote:
    >
    >> The first option doesn't work, the result is the same. But I'm gonna
    >> check the applescript alternative ...
    >>
    >
    > In C++, using part of PowerPlant, it looks like this:
    >
    > static void TellFinderEject(ConstStringPtr inPathS){
    > StAEDescriptor ae;
    > OSType sig = 'MACS';
    > StAEDescriptor aeDest(typeApplSignature, &sig, sizeof sig);
    > StAEDescriptor aeAH;
    > FSSpec fs;
    > ThrowIfOSErr_(FSMakeFSSpec(0, 0, inPathS, &fs));
    > AliasHandle ah = NULL;
    > ThrowIfOSErr_(NewAliasMinimal(&fs, &ah));
    > HLock((Handle) ah);
    > UAEDesc::AddPtr(aeAH, 0, typeAlias, *ah, GetHandleSize((Handle) ah));
    > if(NULL != ah){
    > DisposeHandle((Handle) ah);
    > }
    > ThrowIfOSErr_(AECreateAppleEvent(kAEFinderSuite, kAEEject, aeDest,
    > kAutoGenerateReturnID, kAnyTransactionID, ae));
    > UAEDesc::AddKeyDesc(ae, keyDirectObject, aeAH);
    > UAppleEventsMgr::SendAppleEvent(ae);
    > }
    >
    > and I call it like this:
    >
    > TellFinderEject("\pMyVolume:");
    Guest

  7. #6

    Default Re: Unmounting a AFP volume (removing it from desktop)

    In article <BB7CCD90.D51%tom@abracode.com>, <tom@abracode.com> wrote:
    > Per discussion on carbon development list a couple of weeks ago you should
    > avoid making minimal aliases when sending events to Finder in Mac OS X
    > because they might not be properly resolved (it is some weird limitation of
    > OS X Finder). You should create full alias instead.
    >
    > Tom
    > Abracode
    Thank you! I'll change it at once.
    David Phillip Oster Guest

  8. #7

    Default Re: Unmounting a AFP volume (removing it from desktop)

    But, is there any way to unmount an AFP volume using CarbonLib? ... I
    have read in previous posts that the better way is tell the Finder to
    unmount it. How can I send programmatically an apple event to the
    Finder to unmount the volume?? ... I think the finder event is
    "kAEEject" ...

    Regards, and thanks in advance ...
    Rob


    David Phillip Oster <oster@ieee.org> wrote in message news:<oster-D3A2EF.20571604092003@news.sf.sbcglobal.net>...
    > In article <BB7CCD90.D51%tom@abracode.com>, <tom@abracode.com> wrote:
    >
    > > Per discussion on carbon development list a couple of weeks ago you should
    > > avoid making minimal aliases when sending events to Finder in Mac OS X
    > > because they might not be properly resolved (it is some weird limitation of
    > > OS X Finder). You should create full alias instead.
    > >
    > > Tom
    > > Abracode
    >
    > Thank you! I'll change it at once.
    Jorge Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139