Writing an encoding program can encode, files as ", WME" files using files already configured.
This requires call () methods of IWMencoder. It is defined as:
HRESULT LOAD
BSTR BSTRFILENAME
), BSTR is a class similar to a CSTRING class, and BStrFileName contains the file name of the encoded file, the relative path.
HRESULT is 32-bit values used to report to users to users in COM. This name is easy to make this type of value as a handle pointing to a result.
This is actually not the case. It is a 32-bit value that can be divided into three regions. It can be understood as "Here's Result". When the return value is S_OK, it is successful.
S_OK is defined as 0. Support IrrorInfo interface when fails, and different errors have different error numbers.
Before using IWMencod, you need to define and initialize the COM library, and return a pointer to this interface.
HRESULT HR;
IWMencoder * Pencoder;
// Initialize the COM Library and Retrieve A Pointer
// TO an IWMencoder Interface.
HR = Coinitialize (NULL);
CoCreateInstance (CLSID_WMENCODER,
NULL,
CLSCTX_INPROC_SERVER,
IID_IWMENCODER,
(void **) & pencoder;
// Load .WME file
CCOMBSTR BSTRFILENAME (L "File_Name.WME");
HR = Pencoder-> Load (BStrFileName);
// You can use iWMencoder-> Save () to save the configuration file backup
// Prepare the encoding
HR = Pencoder-> preparetoencode (variant_true)
// Start the encoding
HR = Pencoder-> start ();
/ / At this point, IWMenCoder-> Get_RunState () can be obtained to get the state of the encoding process. 1 The representative is beginning, 2 representative is coding, 4 representatives are stopping, 5 representatives have stopped.
WMENC_ENCODER_STATE ENUMENCODERSTATE;
HR = Pencoder-> Get_RunState (& Enumencoderstate);
// The IF statement can be used to determine whether the encoding ends if the encoding is over, exiting the loop.
While (1)
{
IF (ENUMENCODERSTATE! = WMENC_ENCODER_RUNNING)
{
Break;
}
}
// Stop coding
HR = Pencoder-> stop ();
// Release the occupancy resource
HR = Pencoder-> Release ();
The header file required by the program is:
#include
#include
#include "wmencode.h"
Summary: This is the most basic program for encoding programming, encoding using the already configured file.
In the process of doing, there have been many problems, such as: HR meaning, CCOMBSTR type,
Initialization of COM. Especially when I finally encoded, I can't get the encoded content, because the program is over prematurely,
No encoded time. After the teacher's career, and teachings, finally finally completed. It is quite a lot from it.