News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

ShellExecute and Registry

Started by Mikl__, June 15, 2017, 12:58:34 AM

Previous topic - Next topic

Mikl__

The simplest program that starts playing a video file
include win64a.inc
.code
WinMain proc
sub esp,7*8
mov qword ptr [rsp + 28h],SW_SHOWNORMAL
xor ecx,ecx
mov [rsp + 20h],rcx
xor r9d,r9d
mov r8d,offset szFilm
mov edx,offset szNoTxt
invoke ShellExecute
invoke ExitProcess,0
WinMain endp
SzFilm db 'movie3.wmv'
SzNoTxt db 0
end
Inside ShellExecute is ShellExecuteEx, to which the structure address of the SHELLEXECUTEINFO type is passed
include win64a.inc
.code
WinMain proc
sub esp,7*8
mov ecx,offset sie
invoke ShellExecuteEx
invoke ExitProcess,0
WinMain endp
sie dd 70h, 1500h, 0, 0
dq szNoTxt
dq szFilm
dq 0,0
dd 1,0
dq 7 dup (0)
szFilm db 'movie3.wmv'
szNoTxt db 0
end
But what is inside ShellExecuteEx? It is intuitively clear what is happening
  • Read the registry, where the program finds out which application is associated with the extension ".wmv"
  • Further from the registry we find the path to the application that will play the video file
  • A command line is created of the type '"C:\Program Files (x86)\Windows Media Player\wmplayer.exe" "E:\Uncle Remus tales\37\37c\movie3.wmv"',0
    Which is passed to the function CreateProcess
Tell me what branches of the registry I need to watch and analyze, so that the program has a universal application?

jj2007

Quote from: Mikl__ on June 15, 2017, 12:58:34 AMTell me what branches of the registry I need to watch and analyze, so that the program has a universal application?

It's not that simple. Some time ago I posted a proggie that is supposed to play videos.

The good news is that on my Win7-64 it can handle wmv, mkv, webm, swf, flv, mp4, mpg, avi and asf. Plus the audio formats cda, mp3, mid and wav.

The bad news is that on your pc it may handle nothing at all. It depends entirely on the codecs installed. I have worked hard to understand this business, and all I can say is that it is an incredible mess :eusa_boohoo:

My proggie uses DirectShow. Before I tried the older MCI, and all I can is "they are different". They are both from Microsoft, but codecs that work on MCI will not work with DShow and vice versa. It is really a can of worms.

What you achieve with ShellExecute is simply to launch the player (WMP or third party, e.g. VLC or FLV) that the user associated with a particular ending. Example:include \masm32\MasmBasic\MasmBasic.inc
  Init
  ShEx "sample.swf"
EndOfCode


If the file exists, after a few seconds Firefox opens and shows me a boring blank page with "Activate Adobe Flash" in the middle. If I click on that link, FF asks me again if I want to allow Flash to run, and if I agree (I shouldn't :bgrin:), after a while I can see the video. Great.

In this respect, DShow is more versatile because it picks automatically a codec if it is installed, i.e. no user intervention needed; and you can construct your own GUI around it.