次の方法で共有


WMRMProtect.WriteFile

banner art

Previous Next

WMRMProtect.WriteFile

The WriteFile method writes an encrypted file with an updated content header.

Syntax

  WMRMProtect
  .WriteFile(
  bstrFileName
  )

Parameters

bstrFileName

[in] String containing the path and name of the encrypted output file to be generated.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns a number in the error object.

Return code Description
0x80004005 An unspecified error occurred.
0x80070057 The specified parameter is not valid.

Remarks

Only the header is updated. The remainder of the file is unchanged.

Example Code

      Dim sKID, sCID, sSeed, sKey, sHeader
    Dim sPrivKey, sPubKey
    Dim HeaderObj
    Dim KeysObj
    Dim ProtectObj

' Create objects.

    Set HeaderObj = Server.CreateObject("Wmrmobjs.WMRMHeader")
    Set KeysObj = Server.CreateObject("Wmrmobjs.WMRMKeys")
    Set ProtectObj = Server.CreateObject("Wmrmobjs.WMRMProtect")





































' Replace XXX with the packaging server's private key. 

    = "XXX"

' Sign the header.



' Retrieve the string containing the header.

    sHeader = HeaderObj.Header

' Set the header string into the WMRMProtect object.

    ProtectObj.Header = sHeader

' Set the key into the WMRMProtect object.

    ProtectObj.Key = sKey

' Specify the name of the file to be protected.

    ProtectObj.InputFile = "c:\input_file.wmv"

' Generate a protected file.

    ProtectObj.ProtectFile("c:\output_file_1.wmv")

' If you change the header, you can use the WriteFile()
' method to update the protected file without forcing 
' Windows Media Rights Manager to again encrypt the
' content. For example, the following illustrates how 
' to protect the file after adding attributes to the header.

    ProtectObj.InputFile=("C:\output_file_1.wmv")
    HeaderObj.Header = ProtectObj.Header

    HeaderObj.Attribute("Author") = "name of the author"
    HeaderObj.Attribute("ContentDistributor") = "name of the distributor"
   
    ProtectObj.Header = HeaderObj.Header
    ProtectObj.WriteFile("c:\output_file_2.wmv")

Requirements

Version: Windows Media Rights Manager 7 SDK or later

Reference: wmrmobjs 1.0 Type Library

Library: wmrmobjs.dll

Platform: Windows Server 2003

See Also

Previous Next

© 2007 Microsoft Corporation. All rights reserved.