Hello,
I'm looking to get the vBlank time in order to synchronize a camera to the vertical blank timing of the projector I have connected to my computer. I understand I can get the vBlank timing from from the DwmGetCompositionTimingInfo function.
I'm using basic net in VS2010 and have written the following code:
<System.Runtime.InteropServices.DllImport("dwmapi.dll")> _
Private Shared Function DwmGetCompositionTimingInfo(ByVal hwnd As IntPtr, ByRef DWM_TIMING_INFO As DWM_TIMING_INFO) As Integer
End Function
Private Structure DWM_TIMING_INFO
Public cbSize As UInt32
Public rateRefresh As UNSIGNED_RATIO
Public qpcRefreshPeriod As QPC_TIME
Public rateCompose As UNSIGNED_RATIO
Public qpcVBlank As QPC_TIME
Public cRefresh As DWM_FRAME_COUNT
Public cDXRefresh As UInteger
Public qpcCompose As QPC_TIME
Public cFrame As DWM_FRAME_COUNT
Public cDXPresent As UInteger
Public cRefreshFrame As DWM_FRAME_COUNT
Public cFrameSubmitted As DWM_FRAME_COUNT
Public cDXPresentSubmitted As UInteger
Public cFrameConfirmed As DWM_FRAME_COUNT
Public cDXPresentConfirmed As UInteger
Public cRefreshConfirmed As DWM_FRAME_COUNT
Public cDXRefreshConfirmed As UInteger
Public cFramesLate As DWM_FRAME_COUNT
Public cFramesOutstanding As UInteger
Public cFrameDisplayed As DWM_FRAME_COUNT
Public qpcFrameDisplayed As QPC_TIME
Public cRefreshFrameDisplayed As DWM_FRAME_COUNT
Public cFrameComplete As DWM_FRAME_COUNT
Public qpcFrameComplete As QPC_TIME
Public cFramePending As DWM_FRAME_COUNT
Public qpcFramePending As QPC_TIME
Public cFramesDisplayed As DWM_FRAME_COUNT
Public cFramesComplete As DWM_FRAME_COUNT
Public cFramesPending As DWM_FRAME_COUNT
Public cFramesAvailable As DWM_FRAME_COUNT
Public cFramesDropped As DWM_FRAME_COUNT
Public cFramesMissed As DWM_FRAME_COUNT
Public cRefreshNextDisplayed As DWM_FRAME_COUNT
Public cRefreshNextPresented As DWM_FRAME_COUNT
Public cRefreshesDisplayed As DWM_FRAME_COUNT
Public cRefreshesPresented As DWM_FRAME_COUNT
Public cRefreshStarted As DWM_FRAME_COUNT
Public cPixelsReceived As ULong
Public cPixelsDrawn As ULong
Public cBuffersEmpty As DWM_FRAME_COUNT
End Structure
Private Structure UNSIGNED_RATIO
Public uiNumerator As UInt32
Public uiDenominator As UInt32
End Structure
Private Structure QPC_TIME
Public QPC_TIME As ULong
End Structure
Private Structure DWM_FRAME_COUNT
Public DWM_FRAME_COUNT As ULong
End Structure
and am using it as:
Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
Dim dwmInfo As DWM_TIMING_INFO
Dim a As Integer = 0
a = DwmGetCompositionTimingInfo(Me.Handle, dwmInfo)
End Sub
but for all the DWM_TIMING_INFO structure I'm getting back all zeros. I'm not quite sure what I'm doing wrong. I'm really just looking for the refresh rate and vBlank time.
Any help would be very much appreciated.