/    Sign up×
Community /Pin to ProfileBookmark

Is this possible in Javascript

All,

Please bear with me since I am very, very new to Javascript and the likes ?

I am trying to write a simple (at least I thought it would be) application in PHP with some javascript. This simple code would basically allow to count the number of CD drives on the client. I’ve taken a look at MSDN and the WMP API and from what I can tell I have the correct code, but nothing is happening. Can anyone provide a helping hand? Code is as follows: –

<html>
<head>
<title>TEST</title>
</head>
<body>
<object id=”Player”
classid=”clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6″
height=”160″
width=”120″>
<param name=”uiMode” value=”full”>
<param name=”autoStart” value=”false”>
<param name=”enabled” value=”true”>
</object>
<?php
echo ‘WMP Test’;
?>
<script language=”javascript”>
{
var mycount=0;
var message;
mycount = Player.cdromcollection.count;
message=”I am here”;
alert(message);
if (mycount == 0)
{
message=”No CD Rom Drives Available”;
alert(message);
}
}
</script>
</body>
</html>

Nothing seems to happen at all, apart from the printing of the test “WMP Test” and the WMP being visible. The alert is not showing. If I take out the line:

mycount = Player.cdromcollection.count

Then the alert(message); in the following line is coming up.

There are no javascript errors so I am at a loss as to why mycount = Player.cdromcollection.count is not working. It’s what is specified on the MSDN pages.

Thanks in advance for any help and/or pointers ?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@MjhLkwdSep 23.2005 — [CODE]<HTML>
<Head>
<Script type="text/javascript">

var cdPossible = new Array('G:','H:','I:');
var driveList = "";

function listDrives(){

driveList = "";
for (i=0; i<cdPossible.length; i++)
{
driveList += checkExist(cdPossible[i])
}
alert(driveList);
}

</Script>

<Script type="text/vbscript">

Function checkExist(driveSpec)

Set fso = CreateObject("Scripting.FileSystemObject")
If fso.DriveExists(driveSpec) Then
checkExist = driveSpec
Else
checkExist = ""
End If
Set fso = Nothing

End Function

</Script>
</Head>
<Body>

<input type='button' value='Create Drive List' onclick="listDrives()">

</Body>
</HTML>[/CODE]
Copy linkTweet thisAlerts:
@dtwconsultingauthorSep 24.2005 — Mike,

Thanks for the script. I gave it a try and it's pretty close but I don't think this script can differentiate between a regular HD and a CDROM drive.
Copy linkTweet thisAlerts:
@MjhLkwdSep 24.2005 — Posted in error.
Copy linkTweet thisAlerts:
@felgallSep 24.2005 — Most of it is written in vbscript which only runs on IE. It can't be done with other web browsers.
Copy linkTweet thisAlerts:
@dtwconsultingauthorSep 25.2005 — Felgall,

Thanks for the info. This is just something I am working on for myself so I'm fine if it just works in IE. In an ideal world of course that's not great and I am far from a Microsoft fan ? In fact, I was trying to read a CD and get the information from CDDB. When I finally stopped messing around, I realised that there are examples that are downloadable from the CDDB both in Javascript and VBScript that will do what I need. Now the fun begins to get that information back to PHP and into a MySQL DB with a nice web front end presentation ?

Thanks all.

Much appreciated.
×

Success!

Help @dtwconsulting spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...