|
|
|
IMoniker Interface |
|
IID_IMoniker |
{0000000F-0000-0000-C000-000000000046} |
|
The IMoniker interface contains methods that allow you to use a moniker object, which contains information that uniquely identifies a COM object. An object that has a pointer to the moniker object's IMoniker interface can locate, activate, and get access to the identified object without having any other specific information on where the object is actually located in a distributed system.
|
|
Methods in VTable order |
|
|
IUnknown Methods |
Description |
|
QueryInterface |
Returns pointers to supported interfaces. |
|
AddRef |
Increments reference count. |
|
Release |
Decrements reference count. |
|
IPersist Method |
Description |
|
GetClassID |
Returns the class identifier (CLSID) for the component object. |
|
IPersistStream Methods |
Description |
|
IsDirty |
Checks the object for changes since it was last saved. |
|
Load |
Initializes an object from the stream where it was previously saved. |
|
Save |
Saves an object into the specified stream and indicates whether the object should reset its dirty flag. |
|
GetSizeMax |
Return the size in bytes of the stream needed to save the object. |
|
IMoniker Methods |
Description |
|
BindToObject |
Binds to the object named by the moniker. |
|
BindToStorage |
Binds to the object's storage. |
|
Reduce |
Reduces the moniker to simplest form. |
|
ComposeWith |
Composes with another moniker. |
|
Enum |
Enumerates component monikers. |
|
IsEqual |
Compares with another moniker. |
|
Hash |
Returns a hash value. |
|
IsRunning |
Checks whether object is running. |
|
GetTimeOfLastChange |
Returns time the object was last changed. |
|
Inverse |
Returns the inverse of the moniker. |
|
CommonPrefixWith |
Finds the prefix that the moniker has in common with another moniker. |
|
RelativePathTo |
Constructs a relative moniker between the moniker and another. |
|
GetDisplayName |
Returns the display name. |
|
ParseDisplayName |
Converts a display name into a moniker. |
|
IsSystemMoniker |
Checks whether moniker is one of the system-supplied types. |
|
BindToObject |
|
FUNCTION IMoniker_BindToObject ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL pmkToLeft AS DWORD _ , BYREF riidResult AS GUID _ , BYREF ppvResult AS DWORD _
) AS
LONG
|
|
FUNCTION IMoniker_BindToObject ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL pmkToLeft AS DWORD _ , BYREF riidResult AS GUID _ , BYREF ppvResult AS DWORD _
) AS
LONG END FUNCTION
|
|
Example |
|
The following function emulates the Visual Basic function GetObject.
' ****************************************************************************************
' Emulates the Visual Basic GetObject function
' ****************************************************************************************
FUNCTION TB_GetObjectDispatch (BYVAL strDisplayName AS STRING, BYREF vObj AS VARIANT) AS LONG
LOCAL hr AS LONG ' // HRESULT
LOCAL pbc AS DWORD ' // Pointer to the new bind context
LOCAL pmk AS DWORD ' // IMoniker interface pointer
LOCAL pObj AS DWORD ' // Interface pointer
LOCAL pcchEaten AS DWORD ' // Number of characters successfully parsed
LOCAL IID_IDispatch AS GUID ' // IDispatch inyterface identifier
LOCAL pvObj AS VARIANTAPI PTR ' // Pointer to a VARIANTAPI structure
IID_IDispatch = GUID$("{00020400-0000-0000-c000-000000000046}")
' // Creates a new bind context.
hr = CreateBindCtx(0, pbc)
IF hr = %S_OK AND ISTRUE pbc THEN
' // Converts a string into a moniker that identifies the object named by the string.
strDisplayName = UCODE$(strDisplayName & $NUL)
hr = MkParseDisplayNameEx(pbc, strDisplayName, pcchEaten, pmk)
IF hr = %S_OK AND ISTRUE pmk THEN
' // Uses the moniker to bind to the object it identifies.
' // The binding process involves finding the object, putting it into the running
' // state if necessary, and supplying the caller with a pointer to a specified
' // interface on the identified object.
hr = IMoniker_BindToObject(pmk, pbc, %NULL, IID_IDispatch, pObj)
IF hr = %S_OK THEN
' // Makes a dispatch variant containing the reference to the object.
' // Note: No need to call AddRef because IMoniker_BindToObject has
' // already called it.
vObj = EMPTY ' // Make sure is empty to avoid memory leaks
pvObj = VARPTR(vObj) ' // Get the VARIANT address
@pvObj.vt = %VT_DISPATCH ' // Mark it as containing a dispatch variable
@pvObj.vd.pdispVal = pObj ' // Set the dispatch pointer address
END IF
END IF
END IF
IF ISTRUE pmk THEN IUnknown_Release pmk
IF ISTRUE pbc THEN IUnknown_Release pbc
FUNCTION = hr
END FUNCTION
' ****************************************************************************************
|
|
BindToStorage |
|
FUNCTION IMoniker_BindToStorage ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL pmkToLeft AS DWORD _ , BYREF riid AS GUID _ , BYREF ppvObj AS DWORD -
) AS LONG
|
|
FUNCTION IMoniker_BindToStorage ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL pmkToLeft AS DWORD _ , BYREF riid AS GUID _ , BYREF ppvObj AS DWORD -
) AS LONG
! push eax
|
|
Reduce |
|
FUNCTION IMoniker_Reduce ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL dwReduceHowFar AS DWORD _ , BYREF ppmkToLeft AS DWORD _ , BYREF ppmkReduced AS DWORD _
) AS
LONG
|
|
FUNCTION IMoniker_Reduce ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL dwReduceHowFar AS DWORD _ , BYREF ppmkToLeft AS DWORD _ , BYREF ppmkReduced AS DWORD _
) AS
LONG
! push ppmkReduced
|
|
ComposeWith |
|
FUNCTION IMoniker_ComposeWith ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pmkRight AS DWORD _ , BYVAL fOnlyIfNotGeneric AS LONG _ , BYREF ppmkComposite AS DWORD _
) AS LONG
|
|
FUNCTION IMoniker_ComposeWith ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pmkRight AS DWORD _ , BYVAL fOnlyIfNotGeneric AS LONG _ , BYREF ppmkComposite AS DWORD _
) AS LONG
|
|
Enum |
|
FUNCTION IMoniker_Enum ( _ BYVAL pthis AS DWORD PTR _ , BYVAL fForward AS LONG _ , BYREF ppenumMoniker AS DWORD _
) AS LONG
|
|
FUNCTION IMoniker_Enum ( _ BYVAL pthis AS DWORD PTR _ , BYVAL fForward AS LONG _ , BYREF ppenumMoniker AS DWORD _
) AS LONG
|
|
IsEqual |
|
FUNCTION IMoniker_IsEqual ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pmkOtherMoniker AS DWORD _
) AS LONG
|
|
FUNCTION IMoniker_IsEqual ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pmkOtherMoniker AS DWORD _
) AS LONG
|
|
Hash |
|
FUNCTION IMoniker_Hash ( _ BYVAL pthis AS DWORD PTR _ , BYREF pdwHash AS DWORD _
)
AS LONG
|
|
FUNCTION IMoniker_Hash ( _ BYVAL pthis AS DWORD PTR _ , BYREF pdwHash AS DWORD _
)
AS LONG
|
|
IsRunning |
|
FUNCTION IMoniker_IsRunning ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL pmkToLeft AS DWORD _ , BYVAL pmkNewlyRunning AS DWORD _
)
AS LONG
|
|
FUNCTION IMoniker_IsRunning ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL pmkToLeft AS DWORD _ , BYVAL pmkNewlyRunning AS DWORD _
)
AS LONG
|
|
GetTimeOfLastChange |
|
FUNCTION IMoniker_GetTimeOfLastChange ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL pmkToLeft AS DWORD _ , BYREF pfileTime AS FILETIME _
) AS
LONG
|
|
FUNCTION IMoniker_GetTimeOfLastChange ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL pmkToLeft AS DWORD _ , BYREF pfileTime AS FILETIME _
) AS
LONG
! push eax
|
|
Inverse |
|
FUNCTION IMoniker_Inverse ( _ BYVAL pthis AS DWORD PTR _ , BYREF ppmk AS DWORD _
)
AS LONG
|
|
FUNCTION IMoniker_Inverse ( _ BYVAL pthis AS DWORD PTR _ , BYREF ppmk AS DWORD _
)
AS LONG
! push ppmk
|
|
CommonPrefixWith |
|
FUNCTION IMoniker_CommonPrefixWith ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pmkOther AS DWORD _ , BYREF ppmkPrefix AS DWORD _
) AS
LONG
|
|
FUNCTION IMoniker_CommonPrefixWith ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pmkOther AS DWORD _ , BYREF ppmkPrefix AS DWORD _
) AS
LONG
|
|
RelativePathTo |
|
FUNCTION IMoniker_RelativePathTo ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pmkOther AS DWORD _ , BYREF ppmkRelPath AS DWORD _
) AS
LONG
|
|
FUNCTION IMoniker_RelativePathTo ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pmkOther AS DWORD _ , BYREF ppmkRelPath AS DWORD _
) AS
LONG
|
|
GetDisplayName |
|
DECLARE FUNCTION Proto_IMoniker_GetDisplayName ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL pmkToLeft AS DWORD _ , BYREF ppszDisplayName AS DWORD _
) AS LONG FUNCTION IMoniker_GetDisplayName ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL pmkToLeft AS DWORD _ , BYREF strDisplayName AS STRING _
)
AS LONG LOCAL HRESULT AS LONG LOCAL ppszDisplayName AS DWORD LOCAL bstrlen AS LONG strDisplayName = "" CALL DWORD @@pthis[20]
USING Proto_IMoniker_GetDisplayName (pthis,
pbc, pmkToLeft, ppszDisplayName) TO HRESULT
END FUNCTION |
|
Example |
|
The following example shows the display names of all the objects currently registered in the Running Object Table (ROT)
#COMPILE EXE
FUNCTION PBMAIN
' Get a pointer to the moniker enumerator
|
|
ParseDisplayName |
|
FUNCTION IMoniker_ParseDisplayName ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL pmkToLeft AS DWORD _ , BYVAL strDisplayName AS STRING _ , BYREF pchEaten AS LONG _ , BYREF ppmkOut AS DWORD _
)
AS LONG LOCAL HRESULT AS LONG strDiaplayName = UCODE$(strDisplayName & $NUL)
CALL DWORD @@pthis[21]
USING IMoniker_ParseDisplayName (pthis,
pbc, pmkToLeft, strDisplayName, pchEaten, ppmkOut)
TO HRESULT
|
|
FUNCTION IMoniker_ParseDisplayName ( _ BYVAL pthis AS DWORD PTR _ , BYVAL pbc AS DWORD _ , BYVAL pmkToLeft AS DWORD _ , BYVAL strDisplayName AS STRING _ , BYREF pchEaten AS LONG _ , BYREF ppmkOut AS DWORD _
)
AS LONG LOCAL pbstrDisplayName AS STRING strDisplayName = UCODE$(strDisplayName & $NUL) pbstrDisplayName = STRPTR(dtrDisplayName)
! push ppmkOut
|
|
IsSystemMoniker |
|
FUNCTION IMoniker_IsSystemMoniker ( _ BYVAL pthis AS DWORD PTR _ , BYREF pdwMksys AS DWORD _
) AS
LONG
|
|
FUNCTION IMoniker_IsSystemMoniker ( _ BYVAL pthis AS DWORD PTR _ , BYREF pdwMksys AS DWORD _
) AS
LONG
|
Page last updated on Monday, 20 March 2006 01:31:30 +0100