c++ - 如何编写c++ dll函数来获取com端口阅读

标签 c++ function dll

我是 c++ 的新手,我试图从 c++ 中的函数读取 COM 端口 下面是代码说明,谁能帮我完成这个? 该函数应该按照评论获取值,请帮助我 谢谢你

int ComPortReading( short, wchar_t * Data[], wchar_t **Output, SIZE_T *OutputSize )
{
int result = 1;
if( Data[0] )
{
    *OutputSize = 50;
    *Output = (wchar_t *) CoTaskMemAlloc(*OutputSize);

    if( *Output )
    {
        wchar_t *EndPtr;

        double v11 = wcstod(Data[0], &EndPtr);  // Port Name
        double v12 = wcstod(Data[1], &EndPtr);  // Baud Rate
        double v13 = wcstod(Data[2], &EndPtr);  // Data Bits
        double v14 = wcstod(Data[3], &EndPtr);  // Stop Bits
        double v15 = wcstod(Data[4], &EndPtr);  // Parity

 // Need to write code here to read COM port
       // Com port settings can be taken from the above v11 - v15 values

        swprintf(*Output, L"%.10lf", v11);
        result = 0;
    }
}

return result;
}

最佳答案

我建议使用一个库,它封装了困难的东西。例如this library on CodeProject或来自 Boost.Asio 的实现.

关于c++ - 如何编写c++ dll函数来获取com端口阅读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12181259/

相关文章:

c++ - qnetwork没有回复状态码或错误,但失败

c++ - 两个整数相乘时结果完全不相关?

c++ - const 指针成员和 operator=

c# - pinvoke将ascii字符数组返回给c#

c++ - 如何构建源代码以 checkin 需要很长时间构建的二进制文件

c++ - Cython VS C++ 性能比较?

c++ - 在 C++ 中包含函数时遇到问题

javascript - JavaScript 中最简单的自修改函数?

c++ - 传递函数参数的求值顺序 - F1( int F2( int& x ), int x ) 的操作顺序

PostgreSQL:在where子句中使用函数参数