Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect media player

Status
Not open for further replies.

Vec

IS-IT--Management
Jan 29, 2002
418
US
How do I detect if Windows Media Player is installed? I made a media player dependant MP3 Player and want it to first check if media player is installed, if not, give a msgbox that indicates they need it.

-
radium.gif

Looking Toward The Future
 
This is a lot more difficult than it looks. You need to first find the related program for say MPG. The following should help...

'General Declarations
Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long

'In the sub.
Dim ProgramExec As String
Dim RetVal As Long
Dim ProgramLen As Integer
Dim Dummy As String
Dim FileNum as integer

' First, create a known, Media file
Open temp.mpg For Output As #FileNum
Print #FileNum "Any Text"
Close #FileNum

' Now your ready to find the associated program.
ProgramExec = String(260, 32)
RetVal = FindExecutable(temp.mpg, Dummy, ProgramExec)
'Format the output
ProgramExec = Left$(ProgramExec, InStr(ProgramExec, Chr$(0)) - 1)

' Is an application is found
If RetVal <= 32 Or IsEmpty(BrowserExec) Then ' Error
MsgBox &quot;Could not find associated Program&quot;
End If

Craig

&quot;Procrastination is the art of keeping up with yesterday.&quot;
 
It's gotta be easier than that! I just want to know if it is present, can't we just look for the driver or something?

Also your code has an error, the following comes up red:
Print #FileNum &quot;Any Text&quot;

Why are we printing anyway?

-
radium.gif

Looking Toward The Future
 
The first problem is, the DLL's are shared. so they could have a different media player installed, or they could have deleted their media player without deleting the DLL's. If it's a DLL your looking for than you could do a search for that. There is another post in this forum on searching for files... (I would suggest looking for the executable)

The code given will tell you for sure what the associated program is, and whether or not it's working. The Print line could be removed, I only used it so that the file we made would not be empty. You only need to make the file so that your program can find Media player from the file extension. Oh I forgot you should also add the line
Kill temp.mpg
to remove the temp file.

But in retrospect, if you had Real Player as your default player for MPG's it would come back with that file instead.

From looking at the MSDN site I see that almost all versions of Media player have the same EXE name, so your best bet is to look for the wmplayer.exe file. I suggest looking at the following link to create your search routine for the file.



Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top