short*->long*? 急救!简单问题送高分!

sheng_hu 2002-08-01 10:06:28
我在使用Windows Media Encoder SDK编程时,使用如下代码:

HRESULT hr;
IWMEncBroadcast* pBroadcast;

USES_CONVERSION;

//保存广播端口
short PortNum;
hr = pEncoder->get_Broadcast(&pBroadcast);
hr = pBroadcast->get_PortNumber(WMENC_PROTOCOL_HTTP,&PortNum);
g_VideoEncoderOutputInf[iIndex].iGbdk = (long) PortNum;

但编译时却报告如下错误:

D:\SLencoder\EncoderView.cpp(1514) : error C2664: 'get_PortNumber' : cannot convert parameter 2 from 'short *' to 'long *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Error executing cl.exe.

>>>>>>
>>>>>>为什么?请高手指点解决方法.......^_^
...全文
41 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sheng_hu 2002-08-01
  • 打赏
  • 举报
回复
这是Windows Media Encoder SDK help中关于get_PortNumber()函数的说明:


IWMEncBroadcast::get_PortNumber
The get_PortNumber method retrieves the port number used for broadcasting encoded content.

Syntax

HRESULT get_PortNumber(
WMENC_BROADCAST_PROTOCOL enumProtocol,
short* piPort
);
Parameters

enumProtocol

[in] short containing the protocol for transmitting encoded content. Currently, this must be the following value.

Value Number Meaning
WMENC_PROTOCOL_HTTP 1 The transmission uses the HTTP protocol.


piPort

[out] Pointer to a short containing the port number.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code Number Description
E_POINTER 0x80004003 The pointer to the port number is NULL.
E_INVALIDARG 0x80070057 The protocol is invalid.


Remarks

Only the HTTP protocol can be used. To specify a port number, use the IWMEncBroadcast::put_PortNumber method.

Example

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncBroadcast* pBrdcst;
short PortNum;

// Initialize the COM library and retrieve a pointer to the
// IWMEncoder interface.
hr = CoInitialize(NULL);

CoCreateInstance(CLSID_WMEncoder,
NULL,
CLSCTX_INPROC_SERVER,
IID_IWMEncoder,
(void**) &pEncoder);

// Retrieve a pointer to the IWMEncBroadcast interface.
hr = pEncoder->get_Broadcast(&pBrdcst);

// Retrieve the port number. The port number defaults to zero.
hr = pBrdcst->get_PortNumber(WMENC_PROTOCOL_HTTP, &PortNum);

// Set the port number.
PortNum = 2356;
hr = pBrdcst->put_PortNumber(WMENC_PROTOCOL_HTTP, PortNum);

wistaria 2002-08-01
  • 打赏
  • 举报
回复
try
hr = pBroadcast->get_PortNumber(WMENC_PROTOCOL_HTTP,(long*)&PortNum);
tomPeakz 2002-08-01
  • 打赏
  • 举报
回复
人家需要的是LONG型的变量,你传递short的怎么可以呢?强制转换一下或者
传递LONG型的数据。

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧