Microsoft KB Archive/933491

= How to create a .dll file that can parse an .asx file in the Windows SDK 4.0 =

Article ID: 933491

Article Last Modified on 8/30/2007

-

APPLIES TO


 * Microsoft Windows Software Development Kit 3.11

-



INTRODUCTION
An Advanced Stream Redirector (.asx) file is an XML file that references a URL for Microsoft Windows Media content that is stored on a server. For example, Microsoft Windows Media Player (WMP) can consume an .asx file and stream a series of Windows Media files.

After you install the Microsoft Windows Software Development Kit (SDK) 4.0, you can use the LoadLibrary API to create a .dll file that an application can use to consume .asx files. Because the application can use the functionality in the .dll file to consume .asx files, you do not have to have an external application.

This article describes how to create a .dll file that can parse an .asx file. This article also summarizes the functions that are available when you load the .dll file.



MORE INFORMATION
To use the .asx file parser .dll file, you must use the LoadLibrary API to obtain the process address of the CreateWMXEditor function. For example, use code that resembles the following: typedef HRESULT (WINAPI * PFNCreateWMXEditor)(IWMXEditor **ppEditor); HINSTANCE hInstanceTest = LoadLibrary( L&quot;wmxlist.dll&quot; );

if( NULL != hInstanceTest ) {       PFNCreateWMXEditor pfnCreate = (PFNCreateWMXEditor)GetProcAddress(hInstanceTest, &quot;CreateWMXEditor&quot; );

if( NULL != pfnCreate ) {           HRESULT hr; IWMXEditor *pEditor; hr = pfnCreate(&pEditor);

if( SUCCEEDED( hr ) ) {              // Use  editor here…. pEditor->Release; }       }       FreeLibrary( hInstanceTest); } To download the .asx file parser .dll file and the .asx file parser .h file, visit the following Microsoft Web sites:

http://download.microsoft.com/download/6/0/1/6013a168-1142-4099-9944-40c9659d681d/wmxlist.msi

http://download.microsoft.com/download/6/0/1/6013a168-1142-4099-9944-40c9659d681d/wmx.h

The following functions are available after you load the .asx file parser .dll file.

The HRESULT ValidateURL(const WCHAR *pkwszFilename) function
Determines whether a file is a valid playlist format.

Parameter
 * [in] pkwszFilename

Specifies the full path of the file to be validated.

Return values
 * NS_E_CURL_INVALIDPATH/NS_E_CURL_INVALIDURL

The path is invalid.
 * NS_E_WMX_UNRECOGNIZED_PLAYLIST_FORMAT

The playlist is invalid.
 * E_OUTOFMEMORY

There is insufficient memory to complete the operation.

The HRESULT ValidateData (const WCHAR *pkwszSourceFilename, BYTE *pbData, DWORD *pcbData) function
Determines whether the data buffer that is passed in the pbData parameter and in the pcbData parameter is a valid playlist format. The function also determines whether the URL that is passed in the pkwszSourceFilename parameter is complete and valid.

Parameters
 * [in] pkwszSourceFilename

Specifies the complete file path of the playlist that the pbData parameter or the cbData parameter represents.
 * [in] pbData

Points to a memory buffer that contains playlist data.
 * [in] pcbData

Points to a DWORD data type that contains the size in bytes of the playlist data.

Return values
 * NS_E_CURL_INVALIDPATH/NS_E_CURL_INVALIDURL

The path is invalid.
 * NS_E_WMX_UNRECOGNIZED_PLAYLIST_FORMAT

The playlist is invalid.
 * E_OUTOFMEMORY

There is insufficient memory to complete the operation.

The HRESULT OpenFromFile (const WCHAR *pkwszFilename, IWMXList **ppiList) function
Opens a valid playlist file or URL and extracts an IWMXList object from the file or from the URL.

Parameters
 * [in] pkwszFilename

Specifies the complete file path of a playlist to be opened.
 * [out] ppiList

If the operation is successful, the pointer contains the returned IWMXList object.

Return value
 * NS_E_CURL_INVALIDPATH/NS_E_CURL_INVALIDURL

The path is invalid.
 * NS_E_WMX_UNRECOGNIZED_PLAYLIST_FORMAT

The playlist is invalid.
 * E_OUTOFMEMORY

There is insufficient memory to complete the operation.

The HRESULT OpenFromMemory (const WCHAR *pkwszSourceFilename, BYTE *pbData, ULONG cbData, IWMXList **ppiList) function
Similar to the ValidateData function. This function validates the file name URL that is passed in. Then, the function uses the playlist data that is stored in the memory buffer to create the playlist.

Parameters
 * [in] pkwszSourceFilename

Specifies the complete file path of the playlist that the pbData parameter or the cbData parameter represents.
 * [in] pbData

Memory pointer to the playlist data.
 * [in] cbData

Size of the data in bytes that the pbData parameter represents.
 * [out] ppiList

If the operation is successful, the pointer contains the returned IWMXList object.

Return values
 * NS_E_CURL_INVALIDPATH/NS_E_CURL_INVALIDURL

The path is invalid.
 * NS_E_WMX_UNRECOGNIZED_PLAYLIST_FORMAT

The playlist is invalid.
 * E_OUTOFMEMORY

There is insufficient memory to complete the operation.

The HRESULT CreateList (IWMXList **ppiList, WMX_LIST_TYPE ListType) function
Creates a blank IWMXList object for more actions.

Parameters
 * [in] ListType

The type of the created IWMXList object.
 * [out] ppList

If the operation is successful, the pointer contains the returned IWMXList object.

Return values
 * E_POINTER

The ppList parameter is empty.
 * E_INVALIDARG

The ListType parameter is invalid.
 * E_OUTOFMEMORY

There is insufficient memory to complete the operation.

The HRESULT GetItemCount (ULONG *pulCount) function
Retrieves the count of the IWMXListItem objects in the current IWMXList object. The count is not recursive.

Parameter
 * [out] pulCount

The pointer to keep the retrieved count.

Return value
 * E_POINTER

The pulCount parameter is empty.

The HRESULT GetItem (ULONG ulIndex, IWMXListItem **ppiItem) function
Retrieves an IWMXListItem object in the current IWMXList object.

Parameters
 * [in] ulIndex

The index of the IWMXListItem object to be retrieved. The index is zero-based.
 * [out] ppiItem

The pointer to keep the retrieved IWMXListItem object. The caller releases the memory of the [out] ppiItem parameter.

Return values
 * E_POINTER

The ppiItem parameter is empty.
 * E_INVALIDARG

The ulIndex parameter is invalid.
 * NS_E_WMX_ITEM_DOES_NOT_EXIST

The ulIndex parameter is invalid.

The HRESULT SetItem (ULONG ulIndex, IWMXListItem *piItem) function
Replaces an IWMXListItem object in the current IWMXList object.

Parameter
 * [in] ulIndex

The index of the IWMXListItem object to be set. The index is zero-based.
 * [out] ppiItem

The IWMXListItem object to be set.

Return value
 * NS_E_WMX_ITEM_DOES_NOT_EXIST

The ulIndex parameter is not valid.
 * E_POINTER

The piItem parameter is empty.
 * NS_E_WMX_ITEM_UNSETTABLE

The item could not be replaced.

The HRESULT CreateItem (IWMXListItem **ppiItem, const WCHAR *pkwszType) function
Creates a blank IWMXListItem object.

Parameters
 * [in] pkwszType

The type of the created IWMXListItem object. The allowed types are as follows:
 * “TypeEntry”
 * “TypeEvents”
 * “TypeRepeat”
 * NULL

Represents the URL reference entry.
 * [out] ppiItem

The pointer to keep the created IWMXListItem object. The caller releases the memory of the [out] ppiItem parameter.

Return values
 * E_POINTER

The ppiItem parameter is empty.
 * NS_E_WMX_ITEM_TYPE_ILLEGAL

The pkwszType parameter is unknown.

The HRESULT AppendItem (IWMXListItem *piItem) function
Appends an IWMXListItem object to the end of the current IWMXList object.

Parameter
 * [in] piItem

The IWMXListItem object to be appended.

Return value
 * E_INVALIDARG

The piItem parameter is empty.
 * E_OUTOFMEMORY

There is insufficient memory to insert the item.

The HRESULT InsertItem ( IWMXListItem *piItem, ULONG ulIndex) function
Inserts an IWMXListItem object in the current IWMXList object.

Parameters
 * [in] piItem

The IWMXListItem object to be inserted.
 * [in] ulIndex

The position in which the IWMXListItem object is to be inserted. The index is zero-based.

Return values
 * E_POINTER

The piItem parameter is empty.
 * E_INVALIDARG

The ulIndex parameter is not valid.
 * E_OUTOFMEMORY

There is insufficient memory to insert the item.

The HRESULT RemoveItem (ULONG ulIndex) function
Removes an IWMXListItem object from the current IWMXList object.

Parameter
 * [in] ulIndex

The index of the IWMXListItem object to be removed. The index is zero-based.

Return value
 * E_INVALIDARG

The ulIndex parameter is an invalid index.

The HRESULT Save (const WCHAR *pkwszFilename) function
Saves the current IWMXList object to a file.

Parameter
 * [in] pkwszFilename

The pkwszFilename parameter that stores the complete file path where the playlist will be saved.

Return value
 * E_INVALIDARG

The pkwszFileName parameter is empty or is an invalid file name.

The HRESULT IsUrlList (VARIANT_BOOL *pfUrlList) function
Returns True in the pfUrlList parameter if the opened playlist is an .m3u playlist.

Parameter
 * [out] VARIANT_TRUE

Indicates that the playlist is an .m3u playlist.


 * [out] VARIANT_FALSE

Indicates that the playlist is not an .m3u playlist.

Return value
 * E_POINTER

The pfUrlList parameter is empty.

The IWMXListItem : public IUnknown interface
Note You can sometimes retrieve child items from an IWMXListItem object by using the IUnknown::QueryInterface interface to retrieve an IWMXList object.

The HRESULT GetAttributeCount (ULONG *pulCount) function
Retrieves the count of the attributes in the current IWMXListItem object.

Parameter
 * [out] pulCount

The pointer to keep the retrieved count.

Return value
 * E_POINTER

The pulCount parameter is empty.

The HRESULT GetAttributeName (ULONG ulIndex, BSTR *pbstrAttributeName) function
Retrieves an attribute name in the current IWMXListItem object.

Parameters
 * [in] ulIndex

The index of the IWMXListItem object to be retrieved. The index is zero-based.
 * [out] pbstrAttributeName

The pointer to keep the retrieved attribute name. The caller releases the memory of the [out] pbstrAttributeName parameter by using the SysFreeString function.

Return values
 * E_INVALIDARG

The requested index is out of range.
 * E_POINTER

The pbstrAttributeName parameter is empty.

The HRESULT GetAttribute (const WCHAR *pkwszAttributeName, BSTR * pbstrValue) function
Retrieves an attribute value in the current IWMXListItem object.

Parameters
 * [in] pkwszAttributeName

The attribute name.
 * [in] pbstrValue

The pointer to keep the retrieved attribute value. The caller releases the memory of the [in] pbstrValue parameter by using the SysFreeString function.

Return values
 * NS_E_WMX_ATTRIBUTE_DOES_NOT_EXIST

The attribute does not exist.
 * E_INVALIDARG

The pkwszAttributeName parameter is empty.
 * E_POINTER

The pbstrValue parameter is empty.

The HRESULT SetAttribute (const WCHAR *pkwszAttributeName, const WCHAR *pkwszValue) function
Sets an already existing attribute value in the current IWMXListItem object.

Parameters
 * pkwszAttributeName

The attribute name.
 * pkwszValue

The attribute value to be set.

Return values
 * NS_E_WMX_ATTRIBUTE_DOES_NOT_EXIST

The attribute does not exist.
 * NS_E_WMX_ATTRIBUTE_UNRETRIEVABLE

The property could not be retrieved.

The HRESULT AddAttribute (const WCHAR *pkwszAttributeName, const WCHAR *pkwszValue) function
Adds a new attribute value in the current IWMXListItem object.

Parameters
 * [in] pkwszAttributeName

The attribute name.
 * [in] pkwszValue

The attribute value to be set.

Return values
 * NS_E_WMX_ATTRIBUTE_ALREADY_EXISTS

The attribute already exists.
 * E_OUTOFMEMORY

There is insufficient memory to add the attribute.

The HRESULT RemoveAttribute (const WCHAR *pkwszAttributeName) function
Removes an attribute value in the current IWMXListItem object.

Parameter
 * [in] pkwszAttributeName

The attribute name.

Return value
 * S_OK

Keywords: kbtshoot kbinfo KB933491

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.