MkParseDisplayName

Converts a string into a moniker that identifies the object named by the string. This is the inverse of the IMoniker::GetDisplayName operation, which retrieves the display name associated with a moniker.

WINOLEAPI MkParseDisplayName(

LPBC pbc,
//Bind context to be used
LPCOLESTR szUserName,
//Display name
ULONG FAR *pchEaten,
//Receives number of characters consumed
LPMONIKER FAR *ppmk
//Receives moniker built from display name
);

Parameters

pbc

Points to the binding context to be used in this binding operation.

szUserName

Points to a zero-terminated string containing the display name to be parsed. For Win32 applications, the LPOLESTR type indicates a wide character string (two bytes per character); otherwise, the string has one byte per character.

pchEaten

Receives the number of characters of szUserName that were consumed. If the function is successful, *pchEaten is the length of szUserName; otherwise, it is the number of characters successfully parsed.

ppmk

Receives a pointer to the moniker that was built from szUserName. The returned pointer is NULL if an error occurs; if non-NULL, the function has called IUnknown::AddRef on the parameter and the caller is responsible for calling IUnknown::Release.

Return Values

S_OK

Indicates the parse operation was successful and the moniker was created.

MK_E_SYNTAX

Indicates an error in the syntax of a filename or an error in the syntax of the resulting composite moniker.

E_OUTOFMEMORY

Indicates insufficient memory.

In addition, the return value can be any of the error return values from IMoniker::BindToObject, IOleItemContainer::GetObject, or IParseDisplayName::ParseDisplayName.

Comments

The MkParseDisplayName function parses a human-readable name into a moniker that can be used to identify a link source. The resulting moniker can be a simple moniker (such as a file moniker), or it can be a generic composite made up of the component moniker pieces. For example, the following display name:

"c:\mydir\somefile!item 1"

could be parsed into the following generic composite moniker:

(FileMoniker based on "c:\mydir\somefile") (pics/OLE00090002.gif) (ItemMoniker based on "item 1")

The most common situation in which you need to call MkParseDisplayName is in the implementation of the standard Links dialog, which allows an end-user to specify the source of a linked object by typing in a string. You may also need to call MkParseDisplayName if your application supports a macro language that permits remote references (reference to elements outside of the document).

Note that parsing a display name often requires activating the same objects that would be activated during a binding operation. Therefore, parsing a display name can be as expensive as binding to the object that it refers. Objects that are bound during the parsing operation are cached in the passed-in bind context. If you plan to bind the moniker returned by MkParseDisplayName, the best time to do so is immediately after the function returns, using the same bind context; this removes the need to activate objects a second time.

The MkParseDisplayName function parses as much of the display name as it understands into a moniker. The function then calls IMoniker::ParseDisplayName on the newly created moniker, passing the remainder of the display name. The moniker returned by IMoniker::ParseDisplayName is composed onto the end of the existing moniker and, if any of the display name remains unparsed, IMoniker::ParseDisplayName is called on the result of the composition. This process is repeated until the entire display name has been parsed.

The MkParseDisplayName function attempts the following strategies to parse the beginning of the display name, using the first one that succeeds:

  1. The function looks in the Running Object Table for file monikers corresponding to all prefixes of szDisplayName that consist solely of valid filename characters. This strategy can identify documents that are as yet unsaved.

  2. The function checks the maximal prefix of szDisplayName, which consists solely of valid filename characters, to see if an OLE 1 document is registered by that name (this may require some DDE broadcasts). In this case, the returned moniker is an internal moniker provided by the OLE 1 compatibility layer of OLE 2.

  3. The function consults the file system to check whether a prefix of szDisplayName matches an existing file. The filename can be drive absolute, drive relative, working-directory relative, or begin with an explicit network share name. This is the common case.

  4. If the initial character of szDisplayName is an '@', the function finds the longest string immediately following it that conforms to the legal ProgID syntax. The function converts this string to a CLSID using the CLSIDFromProgID function. If the CLSID represents an OLE 2 class, the function loads the corresponding class object and asks for an IParseDisplayName interface pointer. The resulting IParseDisplayName interface is then given the whole string to parse, starting with the '@'. If the CLSID represents an OLE 1 class, then the function treats the string following the ProgID as an OLE1/DDE link designator having <filename>!<item> syntax.

See Also

IMoniker::ParseDisplayName, IMoniker::GetDisplayName
, IParseDisplayName

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database