<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>
		<title>Cycling 74  &#187;  Topic: How to eject a cd?</title>
		<atom:link href="http://cycling74.com/forums/topic/how-to-eject-a-cd/feed" rel="self" type="application/rss+xml" />
		<link>http://cycling74.com/forums/topic/how-to-eject-a-cd/feed</link>
		<description></description>
		<pubDate>Tue, 18 Jun 2013 13:57:46 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.2.4</generator>
		<language></language>

		
														
					
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-24609</guid>
					<title><![CDATA[How to eject a cd?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-24609</link>
					<pubDate>Sat, 25 Feb 2006 05:23:41 +0000</pubDate>
					<dc:creator>Leafcutter John</dc:creator>

					<description>
						<![CDATA[
						<p>I&#8217;m developing a standalone which samples audio from cd&#8217;s and i&#8217;m having a hard time working out a nice way for the user to be able to eject the CD from within the app. </p>
<p>I searched and found this shell method in the archive:</p>
<p>
echo %s | sudo diskutil eject &#8216;/Volumes/%s&#8217;</p>
<p>Where the first symbol is the root password and the second symbol the volume name.</p>
<p>I don&#8217;t really want the user to have to enter their password just to eject a CD. Is there a method using applescript or something even more simple?</p>
<p>p.s. i don&#8217;t have a clue about applescript so please go easy on me if you have an example.</p>
<p>thanks,</p>
<p>john.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71455</guid>
					<title><![CDATA[Re: How to eject a cd?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71455</link>
					<pubDate>Sat, 25 Feb 2006 09:07:13 +0000</pubDate>
					<dc:creator>f.e</dc:creator>

					<description>
						<![CDATA[
						<p>&#8230; not of any interest for you, but i made a script for [pyext] that <br />
works on windows. Any CD could be open, read, and ejected. The only <br />
thing we canno&#8217;t do is to read .cdda files (windows specific files for <br />
audio-cd) because python thread seems too slow. But i guess making an <br />
installer that put python 2.4, then pyext, then the cd module on your <br />
client&#8217;s machine is not what you expect !</p>
<p>Anyway, if there&#8217;s no solution with AS, take a look at koders.com. <br />
There&#8217;s some examples of how to do this in Java. Some on forums say it&#8217;s <br />
not possible without external lib. Some say yes with sun&#8217;s api only. <br />
Worth a look.</p>
<p>best</p>
<p>f.e</p>
<p>If you plan to make it for windows, here&#8217;s the source for handling cd <br />
eject in c++ :</p>
<p>   1. #include <windows .h><br />
   2. #include <winioctl .h><br />
   3. #include <tchar .h><br />
   4. #include <stdio .h><br />
   5.  <br />
   6.    // Prototypes<br />
   7.  <br />
   8.    BOOL EjectVolume(TCHAR cDriveLetter);<br />
   9.  <br />
  10.    HANDLE OpenVolume(TCHAR cDriveLetter);<br />
  11.    BOOL LockVolume(HANDLE hVolume);<br />
  12.    BOOL DismountVolume(HANDLE hVolume);<br />
  13.    BOOL PreventRemovalOfVolume(HANDLE hVolume, BOOL fPrevent);<br />
  14.    BOOL AutoEjectVolume(HANDLE hVolume);<br />
  15.    BOOL CloseVolume(HANDLE hVolume);<br />
  16.  <br />
  17.    LPTSTR szVolumeFormat = TEXT(&#8220;\\.\%c:&#8221;);<br />
  18.    LPTSTR szRootFormat = TEXT(&#8220;%c:\&#8221;);<br />
  19.    LPTSTR szErrorFormat = TEXT(&#8220;Error %d: %sn&#8221;);<br />
  20.  <br />
  21.    |void| ReportError(LPTSTR szMsg)<br />
  22.    {<br />
  23.        _tprintf(szErrorFormat, GetLastError(), szMsg);<br />
  24.    }<br />
  25.  <br />
  26.    HANDLE OpenVolume(TCHAR cDriveLetter)<br />
  27.    {<br />
  28.        HANDLE hVolume;<br />
  29.        UINT uDriveType;<br />
  30.        TCHAR szVolumeName[8];<br />
  31.        TCHAR szRootName[5];<br />
  32.        DWORD dwAccessFlags;<br />
  33.  <br />
  34.        wsprintf(szRootName, szRootFormat, cDriveLetter);<br />
  35.  <br />
  36.        uDriveType = GetDriveType(szRootName);<br />
  37.        |switch|(uDriveType) {<br />
  38.        |case| DRIVE_REMOVABLE:<br />
  39.            dwAccessFlags = GENERIC_READ | GENERIC_WRITE;<br />
  40.            |break|;<br />
  41.        |case| DRIVE_CDROM:<br />
  42.            dwAccessFlags = GENERIC_READ;<br />
  43.            |break|;<br />
  44.        |default|:<br />
  45.            _tprintf(TEXT(&#8220;Cannot eject. Drive type is incorrect.n&#8221;));<br />
  46.            |return| INVALID_HANDLE_VALUE;<br />
  47.        }<br />
  48.  <br />
  49.        wsprintf(szVolumeName, szVolumeFormat, cDriveLetter);<br />
  50.  <br />
  51.        hVolume = CreateFile( szVolumeName,<br />
  52.                                dwAccessFlags,<br />
  53.                                FILE_SHARE_READ | FILE_SHARE_WRITE,<br />
  54.                                NULL,<br />
  55.                                OPEN_EXISTING,<br />
  56.                                0,<br />
  57.                                NULL );<br />
  58.        |if| (hVolume == INVALID_HANDLE_VALUE)<br />
  59.            ReportError(TEXT(&#8220;CreateFile&#8221;));<br />
  60.  <br />
  61.        |return| hVolume;<br />
  62.    }<br />
  63.  <br />
  64.    BOOL CloseVolume(HANDLE hVolume)<br />
  65.    {<br />
  66.        |return| CloseHandle(hVolume);<br />
  67.    }<br />
  68.  <br />
  69. #define LOCK_TIMEOUT 10000 // 10 Seconds<br />
  70.   #define LOCK_RETRIES 20<br />
  71.  <br />
  72.    BOOL LockVolume(HANDLE hVolume)<br />
  73.    {<br />
  74.        DWORD dwBytesReturned;<br />
  75.        DWORD dwSleepAmount;<br />
  76.        |int| nTryCount;<br />
  77.  <br />
  78.        dwSleepAmount = LOCK_TIMEOUT / LOCK_RETRIES;<br />
  79.  <br />
  80.        // Do this in a loop until a timeout period has expired<br />
  81.        |for| (nTryCount = 0; nTryCount < LOCK_RETRIES; nTryCount++) {<br />
  82.            |if| (DeviceIoControl(hVolume,<br />
  83.                                FSCTL_LOCK_VOLUME,<br />
  84.                                NULL, 0,<br />
  85.                                NULL, 0,<br />
  86.                                &#038;dwBytesReturned,<br />
  87.                                NULL))<br />
  88.                |return| TRUE;<br />
  89.  <br />
  90.            Sleep(dwSleepAmount);<br />
  91.        }<br />
  92.  <br />
  93.        |return| FALSE;<br />
  94.    }<br />
  95.  <br />
  96.    BOOL DismountVolume(HANDLE hVolume)<br />
  97.    {<br />
  98.        DWORD dwBytesReturned;<br />
  99.  <br />
 100.        |return| DeviceIoControl( hVolume,<br />
 101.                                FSCTL_DISMOUNT_VOLUME,<br />
 102.                                NULL, 0,<br />
 103.                                NULL, 0,<br />
 104.                                &#038;dwBytesReturned,<br />
 105.                                NULL);<br />
 106.    }<br />
 107.  <br />
 108.    BOOL PreventRemovalOfVolume(HANDLE hVolume, BOOL fPreventRemoval)<br />
 109.    {<br />
 110.        DWORD dwBytesReturned;<br />
 111.        PREVENT_MEDIA_REMOVAL PMRBuffer;<br />
 112.  <br />
 113.        PMRBuffer.PreventMediaRemoval = fPreventRemoval;<br />
 114.  <br />
 115.        |return| DeviceIoControl( hVolume,<br />
 116.                                IOCTL_STORAGE_MEDIA_REMOVAL,<br />
 117.                                &#038;PMRBuffer,<br />
      |sizeof|(PREVENT_MEDIA_REMOVAL),<br />
 118.                                NULL, 0,<br />
 119.                                &#038;dwBytesReturned,<br />
 120.                                NULL);<br />
 121.    }<br />
 122.  <br />
 123.    AutoEjectVolume(HANDLE hVolume)<br />
 124.    {<br />
 125.        DWORD dwBytesReturned;<br />
 126.  <br />
 127.        |return| DeviceIoControl( hVolume,<br />
 128.                                IOCTL_STORAGE_EJECT_MEDIA,<br />
 129.                                NULL, 0,<br />
 130.                                NULL, 0,<br />
 131.                                &#038;dwBytesReturned,<br />
 132.                                NULL);<br />
 133.    }<br />
 134.  <br />
 135.    BOOL EjectVolume(TCHAR cDriveLetter)<br />
 136.    {<br />
 137.        HANDLE hVolume;<br />
 138.  <br />
 139.        BOOL fRemoveSafely = FALSE;<br />
 140.        BOOL fAutoEject = FALSE;<br />
 141.  <br />
 142.        // Open the volume.<br />
 143.        hVolume = OpenVolume(cDriveLetter);<br />
 144.        |if| (hVolume == INVALID_HANDLE_VALUE)<br />
 145.            |return| FALSE;<br />
 146.  <br />
 147.        // Lock and dismount the volume.<br />
 148.        |if| (LockVolume(hVolume) &#038;&#038; DismountVolume(hVolume)) {<br />
 149.            fRemoveSafely = TRUE;<br />
 150.  <br />
 151.            // Set prevent removal to false and eject the volume.<br />
 152.            |if| (PreventRemovalOfVolume(hVolume, FALSE) &#038;&#038;<br />
 153.                AutoEjectVolume(hVolume))<br />
 154.                fAutoEject = TRUE;<br />
 155.        }<br />
 156.  <br />
 157.        // Close the volume so other processes can use the drive.<br />
 158.        |if| (!CloseVolume(hVolume))<br />
 159.            |return| FALSE;<br />
 160.  <br />
 161.        |if| (fAutoEject)<br />
 162.            printf(&#8220;Media in Drive %c has been ejected safely.n&#8221;,<br />
 163.                   cDriveLetter);<br />
 164.        |else| {<br />
 165.            |if| (fRemoveSafely)<br />
 166.                printf(&#8220;Media in Drive %c can be safely removed.n&#8221;,<br />
 167.                cDriveLetter);<br />
 168.        }<br />
 169.  <br />
 170.        |return| TRUE;<br />
 171.    }<br />
 172.  <br />
 173.    |void| Usage()<br />
 174.    {<br />
 175.        printf(&#8220;Usage: Eject <drive letter>nn&#8221;);<br />
 176.        |return| ;<br />
 177.    }<br />
 178.  <br />
 179.    |void| main(|int| argc, |char| * argv[])<br />
 180.    {<br />
 181.        |if| (argc != 2) {<br />
 182.            Usage();<br />
 183.            |return| ;<br />
 184.        }<br />
 185.  <br />
 186.        |if| (!EjectVolume(argv[1][0]))<br />
 187.            printf(&#8220;Failure ejecting drive %c.n&#8221;, argv[1][0]);<br />
 188.  <br />
 189.        |return| ;<br />
 190.    }</drive></stdio></tchar></winioctl></windows></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71456</guid>
					<title><![CDATA[Re: How to eject a cd?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71456</link>
					<pubDate>Sat, 25 Feb 2006 09:35:51 +0000</pubDate>
					<dc:creator>bdawes@mac.com</dc:creator>

					<description>
						<![CDATA[
						<p>John,</p>
<p>take a look at <a href="http://www.osxfaq.com/tips/unix-tricks/week22/" rel="nofollow">http://www.osxfaq.com/tips/unix-tricks/week22/</a> <br />
wednesday.ws use disktool rather than diskutil &#8211; this doesn&#8217;t require  <br />
root access but you&#8217;ll have to run disktool -l to find out the name  <br />
of the cd &#8211; then you just use disktool -e disk1 (if it was disk1).</p>
<p>Hope that helps.</p>
<p>Bren.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71457</guid>
					<title><![CDATA[Re: How to eject a cd?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71457</link>
					<pubDate>Sat, 25 Feb 2006 15:13:19 +0000</pubDate>
					<dc:creator>Leafcutter John</dc:creator>

					<description>
						<![CDATA[
						<p>Thanks very much Bren using disktool works for me. </p>
<p>I&#8217;m not quite sure how i&#8217;m going to parse the data from the disktool -l I don&#8217;t want to accidently unmount anything other than the cd&#8230;.</p>
<p>best,</p>
<p>john.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71458</guid>
					<title><![CDATA[Re: How to eject a cd?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71458</link>
					<pubDate>Sat, 25 Feb 2006 15:32:29 +0000</pubDate>
					<dc:creator>Leafcutter John</dc:creator>

					<description>
						<![CDATA[
						<p>Is the internal CD always disk1 ?&#8230;&#8230;.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71459</guid>
					<title><![CDATA[Re: How to eject a cd?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71459</link>
					<pubDate>Sat, 25 Feb 2006 18:18:25 +0000</pubDate>
					<dc:creator>Emmanuel Jourdan</dc:creator>

					<description>
						<![CDATA[
						<p></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71460</guid>
					<title><![CDATA[Re: How to eject a cd?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71460</link>
					<pubDate>Sat, 25 Feb 2006 20:31:48 +0000</pubDate>
					<dc:creator>John Nowak</dc:creator>

					<description>
						<![CDATA[
						<p>
On Feb 25, 2006, at 5:23 AM, Leafcutter John wrote:</p>
<p>> I&#8217;m developing a standalone which samples audio from cd&#8217;s and i&#8217;m  <br />
> having a hard time working out a nice way for the user to be able  <br />
> to eject the CD from within the app.<br />
><br />
> I searched and found this shell method in the archive:<br />
> echo %s | sudo diskutil eject &#8216;/Volumes/%s&#8217;<br />
><br />
> Where the first symbol is the root password and the second symbol  <br />
> the volume name.<br />
><br />
> I don&#8217;t really want the user to have to enter their password just  <br />
> to eject a CD.</p>
<p>You do not need to use your password to eject a CD-ROM. Just  <br />
&#8220;diskutil eject &#8216;the_path&#8217;&#8221;.</p>
<p>- John</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71461</guid>
					<title><![CDATA[Re: How to eject a cd?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71461</link>
					<pubDate>Sat, 25 Feb 2006 21:02:57 +0000</pubDate>
					<dc:creator>Roman Thilenius</dc:creator>

					<description>
						<![CDATA[
						<p>
> On a mac, since 10.3 you can use the drutil CLI: &#8220;drutil tray eject&#8221;  <br />
> will do the trick.<br />
> <br />
> HTH,<br />
> ej</p>
<p>
right, that is a [shell] job :)</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71462</guid>
					<title><![CDATA[Re: How to eject a cd?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-eject-a-cd/#post-71462</link>
					<pubDate>Sat, 25 Feb 2006 22:42:40 +0000</pubDate>
					<dc:creator>Leafcutter John</dc:creator>

					<description>
						<![CDATA[
						<p>Thanks for the help everyone, it&#8217;s much appreciated.</p>
<p>Emmanuel&#8217;s method is simple and perfect for what i want. </p>
<p>best wishes to all,</p>
<p>john.</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

