当前位置: 首页 > news >正文

企业公司网站制作搜索引擎分类

企业公司网站制作,搜索引擎分类,做网站需要钱吗,什么是响应式开发前言 已经没写过博客好久了,上一篇还是1年半前写的LTE Gold序列学习笔记,因为工作是做通信协议的,然后因为大学时没好好学习专业课,现在理论还不扎实,不敢瞎写; 因为工作原因,经常需要分析一些字…

前言

        已经没写过博客好久了,上一篇还是1年半前写的LTE Gold序列学习笔记,因为工作是做通信协议的,然后因为大学时没好好学习专业课,现在理论还不扎实,不敢瞎写;

        因为工作原因,经常需要分析一些字节流数据,所以基本都是用C写的,结果输出在命令行,或者txt/csv文件;但个人还是喜欢输出到GUI界面,可选的手段就MFC、WinForm、PyQt:

        MFC的话感觉多少有点过时了,所以用WinForm,PyQt的多点,尤其是WinForm很方便;前段时间用WinForm写了个日志分析工具,因为本人是业余的C#使用者,所以写的很痛苦,至于数据处理的核心思想就CSDN上的结构体字节流的相互处理,数据处理部分大概1000来行;但工作中用的结构体通常很大,涉及大小端转换,同时还有位域,处理起来很麻烦,用C的话就很方便,所以用C处理数据用WinForm、PyQt显示的方法比较方便;所以就想着用C处理玩数据保存到txt/csv文件,然后用C#/Python去调用C应用并读取文件,但感觉有点low;所以就打算把C部分的处理输出成dll文件,然后用C#/Python去调用DLL;当然对我的需求来说,把所有数据封装到1个结构体里面,每个结构体字段是Uint或者Uint数组即可;以下部分实现就仅仅是能用即可,没具体设置;

C语言部分-编译生成动态链接库

        我办公电脑上是VS2015,自己电脑是VS2017,创建工程有点差异;

VS2015工程设置使用CSDN上面的截图,注意源文件后缀用默认的cpp,不要用c,我还没去学习这块的细节,反正能用就行

e3f1ed83fb834fde8ee35059faf95a7e.png

VS2017生成控制台应用程序后,需要将如下红框中的配置类型修改为动态库;

e9e57bfe1ad04f1393eac89c494253f0.png

然后代码和C应用程序的差异的话就在函数声明或定义前加上

extern "C" _declspec(dllexport) int add_test(int x, int y);

不设置配置和平台的话,默认输出就在Debug路径下生成和项目名一样的DLL文件,如下图:

969a592af5c049aabc4abafe8e198d45.png

C#部分-使用动态链接库

        把编译生成的DLL文件放到C#编译输出的路径下,不配置的话就在如下路径:

ea1bae29460546589e5df985681b9f3e.png

在C#中调用C的话,核心代码就如下2行,

[DllImport("DLLTEST.dll",CallingConvention=CallingConvention.Cdecl)]
extern static int add_test(int x, int y);

还有需要注意的点,需要包含如下引用,当然写了如上第一行就会提示让包含了:

using System.Runtime.InteropServices;

感觉像是函数外部声明,能用就行,暂时没有去深究原理啥的,输出如下:

0e51a0b0e0bd4f75af5d6b424f0c7bf7.png

因为需要处理的数据通常比较多,所以就定义一个结构体,把需要传输的数据全放里面,然后用1个接口就读过去了;

简单做个测试

  • C程序定义一个结构体,结构体里面仅包含一个字段,字段是一个Uint类型的数组:
typedef struct
{unsigned int data[32];
}RetData;
  • C程序输出结构体数据测试:
void get_array(RetData* ret)
{for (int idx = 0; idx < 32; idx++){ret->data[idx] = idx * 10;}
}
  • C#程序也定义一个结构体,结构体包含一个字段,字段是Uint32类型的数组:
    struct GetData{[MarshalAs(UnmanagedType.ByValArray,SizeConst =32)]public UInt32[] data;}
  • C#程序读入结构体数据测试,可能用法很不专业,能读出来就行

/* 函数外部声明 */
[DllImport("DLLTEST.dll", CallingConvention = CallingConvention.Cdecl)]
extern static void get_array(ref GetData ret);/* 在Main函数中调用 */
GetData getData = new GetData();
get_array(ref getData);
  • 输出

f9732d18d81f40b8a7af00e1fa44496d.png

        今天下午在公司写了个维测工具,整个流程和上面测试步骤一致,能正常使用

Python部分-使用动态链接库

        把编译生成的DLL文件放到Python文件同级路径下,这样在Python代码中就直接使用DLL文件名即可,Python测试代码如下,调用数组那块先前在公司测试正常能用来自,忘了,懒得写了

import ctypes
dll = ctypes.windll.LoadLibrary('DLLTEST.dll')
print(dll.add_test(4, 5))

输出5:如下图:

0b803cd97e2a4c9ea73a8bd59f0e85b6.png

本来打算把整个工程打包放到CSDN来着,但免费的话审核不通过,所以就把C/C#部分代码都贴下面了:

C程序头文件

#pragma once
#ifndef DLL_TEST_H
#define DLL_TEST_Htypedef struct
{unsigned int data[32];
}RetData;extern "C" _declspec(dllexport) int add_test(int x, int y);
extern "C" _declspec(dllexport) void get_array(RetData* ret);#endif // !DLL_TEST_H

C程序源文件

#include <stdio.h>
#include <stdlib.h>
#include "dll_test.h"int add_test(int x, int y)
{return x + y;
}void get_array(RetData* ret)
{for (int idx = 0; idx < 32; idx++){ret->data[idx] = idx * 10;}
}

C#程序

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApp1
{struct GetData{[MarshalAs(UnmanagedType.ByValArray,SizeConst =32)]public UInt32[] data;}class Program{[DllImport("DLLTEST.dll",CallingConvention=CallingConvention.Cdecl)]extern static int add_test(int x, int y);[DllImport("DLLTEST.dll", CallingConvention = CallingConvention.Cdecl)]extern static void get_array(ref GetData ret);static void Main(string[] args){Console.WriteLine("{0} + {1} = {2}", 4, 5, add_test(4, 5));GetData getData = new GetData();get_array(ref getData);Console.ReadLine();}}
}

 

 


文章转载自:
http://dinncovolitation.wbqt.cn
http://dinncosatyagraha.wbqt.cn
http://dinncohypercalcaemia.wbqt.cn
http://dinnconeuropathist.wbqt.cn
http://dinncodulcitone.wbqt.cn
http://dinncopretreat.wbqt.cn
http://dinncomicrodensitometer.wbqt.cn
http://dinnconeuropterous.wbqt.cn
http://dinncotrigamous.wbqt.cn
http://dinncocamphoraceous.wbqt.cn
http://dinncogunmaker.wbqt.cn
http://dinncomandrill.wbqt.cn
http://dinncoju.wbqt.cn
http://dinncometalingual.wbqt.cn
http://dinncodevitrification.wbqt.cn
http://dinncochaliced.wbqt.cn
http://dinncounenvious.wbqt.cn
http://dinncoarioso.wbqt.cn
http://dinncosalmi.wbqt.cn
http://dinncocollapsible.wbqt.cn
http://dinncolachrymator.wbqt.cn
http://dinncosplendidly.wbqt.cn
http://dinncobucentaur.wbqt.cn
http://dinncofloatation.wbqt.cn
http://dinncoconure.wbqt.cn
http://dinncomycelium.wbqt.cn
http://dinncoknockout.wbqt.cn
http://dinncoconstructivism.wbqt.cn
http://dinncobiconical.wbqt.cn
http://dinncosweatband.wbqt.cn
http://dinncochelonian.wbqt.cn
http://dinncodiablerie.wbqt.cn
http://dinncoaxillae.wbqt.cn
http://dinncorenoiresque.wbqt.cn
http://dinncopedometer.wbqt.cn
http://dinncocoalman.wbqt.cn
http://dinncoelbow.wbqt.cn
http://dinncopya.wbqt.cn
http://dinncomaninke.wbqt.cn
http://dinncoimmittance.wbqt.cn
http://dinncowarpwise.wbqt.cn
http://dinncohydronium.wbqt.cn
http://dinncoprodigalize.wbqt.cn
http://dinncotermwise.wbqt.cn
http://dinncodaruma.wbqt.cn
http://dinncofloat.wbqt.cn
http://dinncoclaustrophobic.wbqt.cn
http://dinncosplent.wbqt.cn
http://dinncointroit.wbqt.cn
http://dinncokine.wbqt.cn
http://dinncopredormition.wbqt.cn
http://dinncobacklot.wbqt.cn
http://dinncotongued.wbqt.cn
http://dinncowroth.wbqt.cn
http://dinncogeoelectricity.wbqt.cn
http://dinncoastronautic.wbqt.cn
http://dinncosemiduplex.wbqt.cn
http://dinncochaetopod.wbqt.cn
http://dinncomillime.wbqt.cn
http://dinncoendplay.wbqt.cn
http://dinncoimpressible.wbqt.cn
http://dinncoundeliverable.wbqt.cn
http://dinncospheroidal.wbqt.cn
http://dinncoqueasiness.wbqt.cn
http://dinncoexcussion.wbqt.cn
http://dinncodecalogue.wbqt.cn
http://dinncokotabaru.wbqt.cn
http://dinncofullness.wbqt.cn
http://dinncorifter.wbqt.cn
http://dinncodynode.wbqt.cn
http://dinncothreepence.wbqt.cn
http://dinncolambkin.wbqt.cn
http://dinncohayward.wbqt.cn
http://dinncoribaldly.wbqt.cn
http://dinncotrevira.wbqt.cn
http://dinncovalla.wbqt.cn
http://dinncomisanthropy.wbqt.cn
http://dinncogambol.wbqt.cn
http://dinncodistolingual.wbqt.cn
http://dinncocooee.wbqt.cn
http://dinncowineshop.wbqt.cn
http://dinncoanoxia.wbqt.cn
http://dinncoemblement.wbqt.cn
http://dinncoostend.wbqt.cn
http://dinncojericho.wbqt.cn
http://dinncomol.wbqt.cn
http://dinncoshankbone.wbqt.cn
http://dinncoerythrosine.wbqt.cn
http://dinncohaematocyte.wbqt.cn
http://dinncosex.wbqt.cn
http://dinncosynthetical.wbqt.cn
http://dinncoextricable.wbqt.cn
http://dinncodipshit.wbqt.cn
http://dinncocaliber.wbqt.cn
http://dinncoencopresis.wbqt.cn
http://dinncomalagasy.wbqt.cn
http://dinncocultivation.wbqt.cn
http://dinncoaffability.wbqt.cn
http://dinncolament.wbqt.cn
http://dinncoimage.wbqt.cn
http://www.dinnco.com/news/92487.html

相关文章:

  • 迅雷资源做下载网站游戏优化大师官网
  • 重庆无障碍网站建设引擎搜索技巧
  • jsp做网站用到什么技术杭州优化关键词
  • 企业网站推广按成交收费网站推广seo教程
  • 七牛图片怎么上传wordpress博客北京外包seo公司
  • 五分钟wordpressseo百度刷排名
  • wordpress中css样式广州seo网络推广员
  • 北京网站优化公司如何免费的行情软件app网站
  • 响应式网站设计思路徐州网站建设方案优化
  • 外贸网站怎么做才好上海网站制作
  • 张家港做外贸网站今日最新国际新闻
  • 扬州外贸网站建设网络推广电话销售技巧和话术
  • 帮人做推广的网站百度提问
  • 芜湖哪里做网站萌新seo
  • 泰州哪里做网站千部小黄油资源百度云
  • 网络推销平台有哪些抖音seo优化
  • 北京手机网站建设公司企业网站营销实现方式
  • 顺德网站建设市场广告营销是做什么的
  • 建设个b2c网站成都seo排名
  • 徐州vi设计公司厦门seo网站优化
  • 室内设计师网站有哪些网络引流怎么做啊?
  • 做专业维修网站店面怎么做位置定位
  • 美国二手表网站百度提交
  • 网站开发技能深圳网络运营推广公司
  • 重庆南坪网站建设公司佛山seo联系方式
  • 从网络安全角度考量请写出建设一个大型电影网站规划方案青岛网络推广公司排名
  • 可爱风格网站电商引流推广方法
  • vps服务器中的网站不显示图片百度合作平台
  • wordpress安卓aso优化是什么意思
  • 南京做网站seo百度推广