|
|
|
IQueryCancelAutoplay Interface |
|
IID_IQueryCancelAutoPlay |
{DDEFE873-6997-4e68-BE26-39B633ADBE12} |
|
The IQueryCancelAutoPlay interface programmatically overrides AutoPlay or AutoRun, which allows you to customize the location and type of content that is launched when media is inserted.
Remarks
Note IQueryCancelAutoPlay is intended only for use by user-launched applications that are running. It should not be handled by invisible or background service applications to prevent the normal AutoPlay/AutoRun feature from being invoked. Giving the user a choice of what happens when media and devices are inserted into the system is a key feature of the platform. This feature is designed specifically to improve and personalize the user experience and should not be inhibited by background services.
A valid use of IQueryCancelAutoPlay is illustrated in the following scenario. Assume that you have, through AutoPlay, previously designated application A to handle video camera events. For video editing, however, you prefer application B. You open application B, begin editing some previously filmed video, and then decide to add some new content to the video being edited. Application B's import function prompts you to turn on the video camera so that the new content can be accessed. Normally, this video device activation would trigger the launch of the device-associated application A. Fortunately, using IQueryCancelAutoPlay, application B has canceled AutoPlay processing of video camera events while you are editing video content. In this case, the cancellation of Autoplay by application B has created a better user experience.
|
|
Methods in VTable order |
|
|
IUnknown Methods |
Description |
|
QueryInterface |
Returns pointers to supported interfaces. |
|
AddRef |
Increments reference count. |
|
Release |
Decrements reference count. |
|
IQueryCancelAutoPlay Method |
Description |
|
AllowAutoPlay |
Applications register an instance of the IQueryCancelAutoPlay interface in the running object table (ROT). Before the Shell starts AutoRun or AutoPlay when the user inserts new media, it checks the ROT for a component implementing IQueryCancelAutoPlay. If it finds one, the Shell calls that implementation's IQueryCancelAutoPlay::AllowAutoPlay method to determine whether it should proceed, and using what restrictions. |
|
IQueryCancelAutoPlay interface implementation |
$IID_IQueryCancelAutoPlay = GUID$("{DDEFE873-6997-4e68-BE26-39B633ADBE12}")
' ****************************************************************************************
' IQueryCancelAutoPlay interface
' ****************************************************************************************
TYPE IQueryCancelAutoPlayVtbl
' IUnknown methods
pQueryInterface AS DWORD ' // QueryInterface method
pAddRef AS DWORD ' // AddRef method
pRelease AS DWORD ' // Release method
' IQueryCancelAutoPlay member
pAllowAutoPlay AS DWORD ' // AllowAutoPlay method
' Custom data
pVtblAddr AS DWORD ' // Address of the virtual table
cRef AS DWORD ' // Reference count
END TYPE
' ****************************************************************************************
' ****************************************************************************************
' Builds the IQueryCancelAutoPlay Virtual Table
' Returns a cookie that is a pointer to a IQueryCancelAutoPlayVtbl structure.
' ****************************************************************************************
FUNCTION IQueryCancelAutoPlay_BuildVtbl () AS DWORD
LOCAL pVtbl AS IQueryCancelAutoPlayVtbl PTR
LOCAL pUnk AS IQueryCancelAutoPlayVtbl PTR
pVtbl = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, SIZEOF(@pVtbl))
IF pVtbl = 0 THEN EXIT FUNCTION
@pVtbl.pQueryInterface = CODEPTR(IQueryCancelAutoPlay_QueryInterface)
@pVtbl.pAddRef = CODEPTR(IQueryCancelAutoPlay_AddRef)
@pVtbl.pRelease = CODEPTR(IQueryCancelAutoPlay_Release)
@pVtbl.pAllowAutoPlay = CODEPTR(IQueryCancelAutoPlay_AllowAutoPlay)
@pVtbl.pVtblAddr = pVtbl
@pVtbl.cRef = 1
pUnk = VARPTR(@pVtbl.pVtblAddr)
FUNCTION = pUnk
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IQueryCancelAutoPlay_QueryInterface method
' Returns the IUnknown of our class and increments the reference counter.
' ****************************************************************************************
FUNCTION IQueryCancelAutoPlay_QueryInterface (BYVAL pCookie AS IQueryCancelAutoPlayVtbl PTR, BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS LONG
IF riid = $IID_IQueryCancelAutoPlay THEN
ppvObj = pCookie
INCR @@pCookie.cRef
FUNCTION = %S_OK
ELSE
FUNCTION = %E_NOINTERFACE
END IF
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IQueryCancelAutoPlay_AddRef method
' Increments the reference counter.
' ****************************************************************************************
FUNCTION IQueryCancelAutoPlay_AddRef (BYVAL pCookie AS IQueryCancelAutoPlayVtbl PTR) AS DWORD
INCR @@pCookie.cRef
FUNCTION = @@pCookie.cRef
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IQueryCancelAutoPlay_Release method
' Releases our class if there is only a reference to him and decrements the reference counter.
' ****************************************************************************************
FUNCTION IQueryCancelAutoPlay_Release (BYVAL pCookie AS IQueryCancelAutoPlayVtbl PTR) AS DWORD
DECR @@pCookie.cRef
FUNCTION = @@pCookie.cRef
IF @@pCookie.cRef = 0 THEN
IF ISTRUE @@pCookie.pVtblAddr THEN
HeapFree(GetProcessHeap(), 0, BYVAL @@pCookie.pVtblAddr)
END IF
END IF
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' This method AllowAutoPlays an object that contains an implementation of the IQueryCancelAutoPlay
' interface.
' ****************************************************************************************
FUNCTION IQueryCancelAutoPlay_AllowAutoPlay (BYVAL pCookie AS IQueryCancelAutoPlayVtbl PTR, BYVAL pszPath AS DWORD, BYVAL dwContentType AS DWORD, BYVAL pszLabel AS DWORD, BYVAL dwSerialNumber AS DWORD) AS LONG
' Put your code here
END FUNCTION
' ****************************************************************************************
|
Page last updated on Monday, 03 April 2006 20:43:01 +0200