C#调用C++ dll动态库(C#调用东软医保动态库)

因工作需要项目中涉及到调用东软医保接口相关操作,本次项目使用C#本地调用C++封装的dll动态库实现医保接口访问操作。

一、接口说明如下

3.1 用户接口函数
本系统提供给医院的是一个动态库接口,无用户界面,输入输出均通过DLL完成。
程序文件名:SiInterface.dll
对外提供的接口函数:
- 初始化函数:
int INIT(char * pErrMsg)
参数说明:
pErrMsg:动态库初始化错误信息。
功能描述:
检查整个运行环境:包括网络环境、运行所需文件、参数等的检查
本地临时文件的清除,比如获取照片信息交易所生成的本地jpg文件。
返回值: 成功:返回0 ;  失败:返回 -1
- 交易函数:
int BUSINESS_HANDLE_EX (  char* inputData,
						 char* otherParam,	
                          char* outputData)
功能描述:HIS系统开发商需要向医保中心发送业务请求的通用函数
输入参数:inputData  
		输入参数:otherParam
输出参数:outputData char* 
返回值:成功:返回0 ;  失败:返回 <0
输入输出参数是以“^、$、|”分割的字符串
参数说明:
入参格式: otherParam
       此入参为异地就医改造新增入参,签到签退交易的时候传‘|||’,读卡交易传‘统筹区号|||’,其他交易统一传入下面的格式
			统筹区号|个人编号|身份证号|
入参格式: inputData
      业务编号^医疗机构编号^操作员编号^业务周期号^医院交易流水号^中心编码^入参^联机标志^

二、测试调用demo Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace interfacetest
{
    class Program
    {
        [DllImport("SiInterface.dll", EntryPoint = "INIT")]

        public static extern int INIT(StringBuilder str);
        
        static void Main(string[] args)
        {
            StringBuilder buf = new StringBuilder(1024);//指定的buf大小必须大于传入的字符长度
            int res = INIT(buf);
            string rs = buf.ToString();
            Console.WriteLine(rs);
            Console.ReadKey();
        }
    }
}

三、调用效果
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Qcg0223/article/details/111941490