cdtray
- June 24th, 2005
- Posted in Software
- Write comment
cdtray is a small program I wrote for a friend. It's pretty crappy. You even get to see a console window for a moment while the drive opens. All it does is open and close whatever drive you tell it to. That's what he wanted, that's what I gave him. I'm sure I could have made it prettier. I didn't. It was a 5-minute program. :)
To Protocol: the link has been fixed. You can now find the cdtray program here. In the future, please leave comments on an existing post rather than writing a draft post ;) [I fixed the problem that allowed you to do that in the first place].
Syntax examples:
cdtray.exe open D:
cdtray.exe close E:
The [lame] source code! :
Delphi
-
program ejectcd;
-
uses
-
SysUtils, MMSystem;
-
var
-
str, str2: string;
-
begin
-
if (ParamCount < 2) then halt;
-
str := lowercase(trim(ParamStr(1)));
-
str2 := 'open cdaudio!' + uppercase(trim(ParamStr(2))) + ' alias thedrive';
-
mciSendString(PAnsiChar(trim(str2)), nil, 0, 0);
-
if (str = 'close') then mciSendString('set thedrive door closed wait', nil, 0, 0);
-
if (str = 'open') then mciSendString('set thedrive door open wait', nil, 0, 0);
-
end.
Thainks again.^:)^
No problem. Hey, if you need any changes on it, let me know. Thanks for joining the site, by the way! Glad to have another reader. :)>-
I was looking for an answer to why my cd drive wont release/refresh the name of the last cd/dvd in the drive when i came across your utility.
SWEEET!
I've needed something like this frow a while, and i signed up for a logon just to say thanks for the util.
Keep rockin.
:D
Wow, I'm glad more people are liking it! It really is a sad program. It could have been made better ;)
Oh well. It's only a few lines of object pascal code. Thanks a bunch for signing up, I hope you become a frequent reader :)
Delphi 5 or 6 ?
Do you use free pascal or borland delphi?
I would like to get started in delphi but the personal borland delphi is no longer available.Free Pascal is …well…free pascal..
Lead me in the right direction. I also posted on Lunarsoft and Tarun suggested to ask you…:-?
It's actually Delphi 7. I use Borland's Delphi. I also have Freepascal and plan to migrate to that by using Lazarus. I understand that you don't like Freepascal, but that is because it is trying to be more like Turbo Pascal than Delphi. It's still object pascal though, and can do all the same things Delphi can. The only available Delphi Personal is 2005 Architect, and while it is an excellent upgrade to the IDE, it's a hell of a lot less stable (imho). It also generates larger code.
All you can do for now is try to get a copy of Delphi 7 [the best!] second hand… there's currently a copy on eBay [of Professional!] going for $100 USD… get it while you can (it's worth $400+, and there's a little over a day left on it). There's other ways to get it… see if Tarun knows of any ;)
i am having troble opening it it will not open can you help me ?
It's not a program you can double-click on. It's a command-line program (or you can make a shortcut to it). Either way, it requires extra syntax to be functional (i.e., specifying what to do and what drive to do it to).
The syntax is:
cdtray.exe open [drive letter including colon]or
cdtray.exe close [drive letter including colon]So,
cdtray.exe open D:or
cdtray.exe close E:or something.
Make a shortcut to the program using these parameters and it should work fine.
Appreciate it. I've been searching a while to find a program like yours and this seems to be the easyest and most adequate solution.
Wish it would need ony o_n_e shortcut to both open and close the drive, however. ;)
Yeah, it never was meant to be that sophisticated ;)
The source code is above, so grab FreePascal (or something) and make it work with one shortcut ;)
(I don't know the MCI commands to toggle or how to workaround that)