I want to write a Windows service (in c#) or a powershell script that connects my laptop automatically (at boot or key combination) to my MS wireless display adapter for screen mirroring. In Windows 10 I can only do it manually by going to the notifications and click Connect>MS Wireless adapter>connect.
What I found is that there is a Miracast API but there is not much documentation on how to use it.
I also found this documentation on MiraDisp.dll and there are two functions OpenMiracastSession and CloseMiracastSession.
The problem is I don't know how to use these functions in c#. I know I will probably have to use pInvoke. Can anyone point me in the right direction?
To automate and control Miracast, you want to write a
UWP
app using theWindows.Media.Casting
namespace and Windows Universal Samples.They can be written in many common languages including C#, C++, Javascript, and Visual Basic.
Windows provided two sets of functional sample programs to demonstrate what you can do with Miracast that can be opened and launched as Visual Studio solutions (.sln).
Basic Casting
Advanced Casting
Because UWP apps are designed to be made available on the Windows app store, they have specific requirements and regulations for functioning. (I recommend researching these.)
Also avoid the pitfall I made when I started writing a generic program and then wondered where the Universal Windows library was:
Starting a UWP project