|
|
|
IServiceProvider Interface |
|
IID_IServiceProvider |
{6D5140C1-7436-11CE-8034-00AA006009FA} |
|
The
IServiceProvider interface is a generic access mechanism to locate a
globally unique identifier (GUID) identified service. |
|
Methods in VTable order |
|
|
IUnknown Methods |
Description |
|
QueryInterface |
Returns pointers to supported interfaces. |
|
AddRef |
Increments reference count. |
|
Release |
Decrements reference count. |
|
IServiceProvider Members |
Description |
|
QueryService |
Acts as the factory method for any services exposed through an implementation of IServiceProvider. |
|
QueryService |
|
FUNCTION
IServiceProvider_QueryService
( _ , BYREF guidService AS GUID _ , BYREF riid AS GUID _ , BYREF ppv AS DWORD _ ) AS LONG
|
|
IserviceProvider interface implementation |
$IID_IServiceProvider = GUID$("{6D5140C1-7436-11CE-8034-00AA006009FA")
' ****************************************************************************************
' IServiceProvider interface
' ****************************************************************************************
TYPE IServiceProviderVtbl
' IUnknown methods
pQueryInterface AS DWORD ' // QueryInterface method
pAddRef AS DWORD ' // AddRef method
pRelease AS DWORD ' // Release method
' IServiceProvider members
pQueryService AS DWORD ' // QueryService method
' Custom data
pVtblAddr AS DWORD ' // Address of the virtual table
cRef AS DWORD ' // Reference count
END TYPE
' ****************************************************************************************
' ****************************************************************************************
' Builds the IServiceProvider Virtual Table
' Returns a cookie that is a pointer to a IServiceProviderVtbl structure.
' ****************************************************************************************
FUNCTION IServiceProvider_BuildVtbl () AS DWORD
LOCAL pVtbl AS IServiceProviderVtbl PTR
LOCAL pUnk AS IServiceProviderVtbl PTR
pVtbl = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, SIZEOF(@pVtbl))
IF pVtbl = 0 THEN EXIT FUNCTION
@pVtbl.pQueryInterface = CODEPTR(IServiceProvider_QueryInterface)
@pVtbl.pAddRef = CODEPTR(IServiceProvider_AddRef)
@pVtbl.pRelease = CODEPTR(IServiceProvider_Release)
@pVtbl.pQueryService = CODEPTR(IServiceProvider_QueryService)
@pVtbl.pVtblAddr = pVtbl
@pVtbl.cRef = 1
pUnk = VARPTR(@pVtbl.pVtblAddr)
FUNCTION = pUnk
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IServiceProvider_QueryInterface method
' Returns the IUnknown of our class and increments the reference counter.
' ****************************************************************************************
FUNCTION IServiceProvider_QueryInterface (BYVAL pCookie AS IServiceProviderVtbl PTR, BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS LONG
IF riid = $IID_IServiceProvider THEN
ppvObj = pCookie
INCR @@pCookie.cRef
FUNCTION = %S_OK
ELSE
FUNCTION = %E_NOINTERFACE
END IF
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IServiceProvider_AddRef method
' Increments the reference counter.
' ****************************************************************************************
FUNCTION IServiceProvider_AddRef (BYVAL pCookie AS IServiceProviderVtbl PTR) AS DWORD
INCR @@pCookie.cRef
FUNCTION = @@pCookie.cRef
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IServiceProvider_Release method
' Releases our class if there is only a reference to him and decrements the reference counter.
' ****************************************************************************************
FUNCTION IServiceProvider_Release (BYVAL pCookie AS IServiceProviderVtbl 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
' ****************************************************************************************
' ****************************************************************************************
' Acts as the factory method for any services exposed through an implementation of
' IServiceProvider.
' ****************************************************************************************
FUNCTION IServiceProvider_QueryService (BYVAL pCookie AS IServiceProviderVtbl PTR, BYREF guidService AS GUID, BYREF riid AS GUID, BYREF ppv AS DWORD) AS LONG
' Put your code here
' FUNCTION = %S_OK, %E_NOINTERFACE, %E_OUTOFMEMORY, or %E_UNEXPECTED
END FUNCTION
' ****************************************************************************************
|
Page last updated on Monday, 03 April 2006 20:25:35 +0200