• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >vc/mfc > 老大们,来看看,小问题!高分!

老大们,来看看,小问题!高分!

作者:佚名 字体:[增加 减小] 来源:互联网 时间:2017-06-04

佚名通过本文主要向大家介绍了 老大们,来看看,小问题!高分!等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 老大们,来看看,小问题!高分!
描述:

我写了一个active,在add method
假设我现在要返回一个BYTE形的,
(0x01 0x02 0x88 0x99 ...)
怎么样返回这样的一个16进制
我想可以作为一串字符串,但我在add method时,
在return type 中不知道 返回哪一个
要怎么做呢,
谢谢了


解决方案1:

呵呵,UP!

解决方案2:

CString ReadStr = "12345";
CString mstr;
CString out = "";
int x = ReadStr.GetLength();
for( int i = 0; i < x; ++i )
{
   mstr.Format(" 0X%02X ",ReadStr.GetAt(i));
   out += mstr;
}
结果是 输出 out 为 0x31 0x32 0x33 0x34 0x35

解决方案3:

帮你顶!

解决方案4:

其实没有必要这样
别人在做二次开发时,只是拿你的值和0xAA比较,
在机器中它们是相等170的呀
你只返回170就可以了
我想是这样的

解决方案5:

up

解决方案6:

CString::operator [ ] 
TCHAR operator []( int nIndex ) const;
Parameters
nIndex
Zero-based index of a character in the string.
Remarks
You can think of a CString object as an array of characters. The overloaded subscript ([]) operator returns a single character specified by the zero-based index in nIndex. This operator is a convenient substitute for the GetAt member function.
Important   You can use the subscript ([]) operator to get the value of a character in a CString, but you cannot use it to change the value of a character in a CString.
Example
The following example demonstrates the use of CString::operator [ ].
// example for CString::operator [ ]
CString s( "abc" );
ASSERT( s[1] == 'b' );
CString Overview |  Class Members |  Hierarchy Chart
See Also   CString::GetAt, CString::SetAt

解决方案7:

CString::GetAt
TCHAR GetAt( int nIndex ) const;
Return Value
A TCHAR containing the character at the specified position in the string.
Parameters
nIndex
Zero-based index of the character in the CString object. The nIndex parameter must be greater than or equal to 0 and less than the value returned by GetLength. The Debug version of the Microsoft Foundation Class Library validates the bounds of nIndex; the Release version does not.
Remarks
You can think of a CString object as an array of characters. The GetAt member function returns a single character specified by an index number. The overloaded subscript ([]) operator is a convenient alias for GetAt.
Example
The following example demonstrates the use of CString::GetAt.
// example for CString::GetAt
CString s( "abcdef" );
ASSERT( s.GetAt(2) == 'c' );
CString Overview |  Class Members |  Hierarchy Chart
See Also   CString::GetAt, CString::GetLength, CString::operator []

解决方案8:

好象CString有一个Format方法,可以将数字以指定形式输出,记不大清了
到MSDN中找Format吧

解决方案9:

up

解决方案10:

BYTE * CTsView::GetStr()
{
CString ReadStr=_T("ajsdfasjoerewjrekw");
BYTE *pbStr;    
      //ReadStr = SerialPort.Read();
      //SerialPort.PortClose();
UINT nLen=ReadStr.GetLength();
         pbStr=new BYTE[nLen-7];
memcpy((void *)pbStr,(void *)(LPCTSTR)ReadStr.Mid(7),nLen-7);        
       return pbStr;
}
不知道这样行不行!

解决方案11:

char * GetStr()
{
CString ReadStr;
ReadStr = SerialPort.Read();
SerialPort.PortClose();
return  ReadStr.Mid(7);//或者为6,8
}

解决方案12:

返回值是DWORD的(HRESULT)。
要取值只能传参数进去。
通过参数取出来。

解决方案13:

看你的客户对象而定:变体形、安全数组、BYTE* 都行


分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 老大们,来看看,小问题!高分!

相关文章

  • 2017-06-05 dll的输出函数和输出类能否有命名空间
  • 2017-06-04 谁有通用的opcserver测试软件的下载地址?
  • 2017-06-04 如何让CEDIT支持拖放?
  • 2017-06-04 MFC对话框
  • 2017-06-04 把VC自带的realplayer嵌入到程序后使用release和静态连接需怎么配制
  • 2017-06-04 求助!串口调试问题?!
  • 2017-06-05 自己编写的dll,调试的时候,调用dll的程序出现了下面的异常情况?请指点,分不够在加
  • 2017-06-05 问个内存映射的问题
  • 2017-06-04 VC制作OCX如何实现安全接口
  • 2017-06-04 VC60往已有一些格式和数据的模板EXCEL中写入数据的问题

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 如何完成具有打印和打印预览功能的OCX
    • IDispatch是个什么东西?我怎么老是在这个出错。
    • ActiveX控件拦截IE的打印事件
    • VC编写串口通信时用到MSComm控件遇到的问题
    • 如果一个ATL控件要用到MFC程序中,那么这个控件是否也要支持MFC
    • 请问,什么情况下会造成软件在没有任何提示的情况下,突然消失?
    • 如何才能把EVENTMSG数据保存出来?
    • 请教ATL工程中几个小问题
    • 急求关于日期类型的
    • 一个关于com组件中参数类型的问题

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有