PB调用COM的代码,如何转换为VC++调用?

KcSoft 2009-04-17 10:48:21
中山锐旗软件公司的新农合系统PB调用COM的代码,如何转换为VC++调用?有他的hyjk.dll,也有接口说明。


PB调用示例
/***********变量定义***********/
oleobject loo_objOle //定义OLE对像
int li_rtn //连接返回值
string ls_rtn //返回字符串
String ls_hosinfo[7], ls_peopleinfo[8] //参数数组
/***********调用代码***********/

//参合人员查询
Try
//利用OLE连接COM对像
loo_objOle=create OLEObject //创建OLE对像
li_rtn = loo_objOle.connecttonewobject("hyjk") //成功返回:0
if li_rtn <> 0 then
messagebox("连接错误",string(li_rtn)) //未注册接口("hyjk"):-2 ,未找到文件"C:\合医接口\hyjk.dll": -3 。
return
end if

//创建实例
ls_rtn = loo_objOle.createinstace()
if ls_rtn <> "1" then
messagebox("创建错误",ls_rtn) //请检查配置环境
return
end if

ls_rtn = loo_objOle.checkpeople(ls_hosinfo[ ], ls_peopleinfo[ ]) //接口API函数(参考文档和测试程序)

messagebox("返回值",ls_rtn) //程序处理
catch (SoapException e1)
messagebox("Fail","Can't invoke service 'checkpeople'~n~r"+e1.getmessage())
catch (PBXRuntimeError e2)
messagebox("Fail","There is a runtime error when invoking Web service~n~r"+e2.getmessage())
catch (RuntimeError e3)
messagebox("Fail","There is an unknown error when invoking Web service~n~r"+e3.getmessage())
end try

//销毁实例
loo_objOle.destroyinstace()
//销毁对像
destroy loo_objOle
...全文
144 点赞 收藏 16
写回复
16 条回复
zqqxh 2009年08月07日
楼上的大哥:用delphi调用成功了吗?能否将解决方案粘出来供学习呀?
回复 点赞
hustcx 2009年04月19日
关注,有没有用delphi调用成功例子
接口文件可到http://hustcx.qupan.com/3040317.html下载
回复 点赞
KcSoft 2009年04月19日
[Quote=引用 8 楼 TianChong 的回复:]
你的DLL是否已在系统中注册啊?这可是关键的一步。

对了,我没有找到他们的hyjk.dll,和接口说明,您可以给我发一份吗?或加我QQ:30101,我常用VC及PB,交个朋友。
[/Quote]

应该已经注册了,因为他的例子已经可以运行起来了,也已经创建接口成功了,不知道PB调用和VC调用他们的注册方式是不是一样?
回复 点赞
KcSoft 2009年04月19日
今天我听到内部消息,有人想将全省的乡镇卫生院的信息系统都强压下去做,所以只提供PB开发语言的例子,根本不提供别的开发语言的例子,不给别的公司机会,我们严重鄙视这种行为,很多卫生院都已经用了我们公司的系统,又要再出钱购买别人的产品,他们很可怜啊。大家帮帮忙,让我们做出来,不赚钱也要做出来啊!
回复 点赞
KcSoft 2009年04月19日
virtual HRESULT __stdcall raw_canceloutpatientcompensation (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_gethospitalizationcompensationresult (
short ai_row,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_getoutpatientcompensationresult (
short ai_row,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_checkoutpatientcompensationstate (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_checkpeopledetail (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_uploaddiagnosisandtreatdata (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
SAFEARRAY * * as_in2,
SAFEARRAY * * as_in3,
SAFEARRAY * * as_in4,
SAFEARRAY * * as_in5,
SAFEARRAY * * as_in6,
SAFEARRAY * * as_in7,
SAFEARRAY * * as_in8,
SAFEARRAY * * ad_in9,
SAFEARRAY * * ad_in10,
SAFEARRAY * * ad_in11,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_uploadmedicinedata (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
SAFEARRAY * * as_in2,
SAFEARRAY * * as_in3,
SAFEARRAY * * as_in4,
SAFEARRAY * * as_in5,
SAFEARRAY * * as_in6,
SAFEARRAY * * as_in7,
SAFEARRAY * * as_in8,
SAFEARRAY * * as_in9,
SAFEARRAY * * as_in10,
SAFEARRAY * * ad_in11,
SAFEARRAY * * ad_in12,
SAFEARRAY * * ad_in13,
BSTR * FuncRetVal ) = 0;
};

struct __declspec(uuid("401714c6-b61a-4e13-b745-3745ad757b00"))
COClass_concustom;
// [ default ] interface Iconcustom

//
// Wrapper method implementations
//

#include "e:\hyjktest\release\hyjk.tli"

#pragma pack(pop)
回复 点赞
KcSoft 2009年04月19日
//
// Raw methods provided by interface
//

virtual HRESULT __stdcall put_isc_conn (
IDispatch * argvalue ) = 0;
virtual HRESULT __stdcall get_isc_conn (
IDispatch * * argvalue ) = 0;
virtual HRESULT __stdcall put_iproxy_obj (
IDispatch * argvalue ) = 0;
virtual HRESULT __stdcall get_iproxy_obj (
IDispatch * * argvalue ) = 0;
virtual HRESULT __stdcall put_is_proxy_name (
BSTR argvalue ) = 0;
virtual HRESULT __stdcall get_is_proxy_name (
BSTR * argvalue ) = 0;
virtual HRESULT __stdcall put_ii_ret (
short argvalue ) = 0;
virtual HRESULT __stdcall get_ii_ret (
short * argvalue ) = 0;
virtual HRESULT __stdcall put_is_result (
SAFEARRAY * * argvalue ) = 0;
virtual HRESULT __stdcall get_is_result (
SAFEARRAY * * argvalue ) = 0;
virtual HRESULT __stdcall put_is_calc_m (
SAFEARRAY * * argvalue ) = 0;
virtual HRESULT __stdcall get_is_calc_m (
SAFEARRAY * * argvalue ) = 0;
virtual HRESULT __stdcall put_is_calc_z (
SAFEARRAY * * argvalue ) = 0;
virtual HRESULT __stdcall get_is_calc_z (
SAFEARRAY * * argvalue ) = 0;
virtual HRESULT __stdcall put_ib_finish (
VARIANT_BOOL argvalue ) = 0;
virtual HRESULT __stdcall get_ib_finish (
VARIANT_BOOL * argvalue ) = 0;
virtual HRESULT __stdcall put_is_message (
BSTR argvalue ) = 0;
virtual HRESULT __stdcall get_is_message (
BSTR * argvalue ) = 0;
virtual HRESULT __stdcall put_is_version (
BSTR argvalue ) = 0;
virtual HRESULT __stdcall get_is_version (
BSTR * argvalue ) = 0;
virtual HRESULT __stdcall put_is_url (
BSTR argvalue ) = 0;
virtual HRESULT __stdcall get_is_url (
BSTR * argvalue ) = 0;
virtual HRESULT __stdcall put_is_code (
BSTR argvalue ) = 0;
virtual HRESULT __stdcall get_is_code (
BSTR * argvalue ) = 0;
virtual HRESULT __stdcall raw_getvolumeinformationa (
BSTR lprootpathname,
BSTR * lpvolumenamebuffer,
unsigned long nvolumenamesize,
unsigned long * lpvolumeserialnumber,
unsigned long * lpmaximumcomponentlength,
unsigned long * lpfilesystemflags,
BSTR * lpfilesystemnamebuffer,
unsigned long nfilesystemnamesize,
VARIANT_BOOL * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_ysm_getmac (
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_f_getnonull_s (
BSTR as_str,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_f_getnonull (
double ad_num,
double * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_destroyinstace ( ) = 0;
virtual HRESULT __stdcall raw_get_mac (
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_get_serialnumber (
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_encrypt (
BSTR as_str,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_createinstace (
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_checkpeople (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_hospitalizationcheckin (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
SAFEARRAY * * as_in2,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_cancelhospitalizationcheckin (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_checkhospitalizationcheckinstate (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_checkdetaileddatastate (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_canceldetaileddata (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_getwrongcheckcomputationdatanumber (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_getwrongcheckcomputationdata (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_translate (
BSTR as_parm,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_getwrongcheckcomputationdataresult (
short ai_row,
short ai_col,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_transfertreatmentcheckin (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_canceltransfertreatmentcheckin (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_checktransfertreatmentcheckinstate (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_counthospitalizationcompensation (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
SAFEARRAY * * as_in2,
SAFEARRAY * * ad_in3,
SAFEARRAY * * ad_in4,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_checkhospitalizationcompensationstate (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_gethospitalizationcompensationvalue (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_cancelhospitalizationcompensation (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_getoutpatientcompensationvalue (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
BSTR * FuncRetVal ) = 0;
virtual HRESULT __stdcall raw_countoutpatientcompensation (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
SAFEARRAY * * as_in2,
SAFEARRAY * * ad_in3,
SAFEARRAY * * ad_in4,
BSTR * FuncRetVal ) = 0;
回复 点赞
KcSoft 2009年04月19日
// Created by Microsoft (R) C/C++ Compiler Version 12.00.8168.0 (6f6507a9).
//
// e:\hyjktest\release\hyjk.tlh
//
// C++ source equivalent of Win32 type library E:\\hyjktest\\Release\\hyjk.dll
// compiler-generated file created 04/19/09 at 02:18:05 - DO NOT EDIT!

#pragma once
#pragma pack(push, 8)

#include <comdef.h>

//
// Forward references and typedefs
//

struct __declspec(uuid("6b2dd44f-44ae-464c-aaf2-1e9a27b469be"))
/* dual interface */ Iconcustom;
struct /* coclass */ COClass_concustom;

//
// Smart pointer typedef declarations
//

_COM_SMARTPTR_TYPEDEF(Iconcustom, __uuidof(Iconcustom));

//
// Type library items
//

struct __declspec(uuid("6b2dd44f-44ae-464c-aaf2-1e9a27b469be"))
Iconcustom : IDispatch
{
//
// Property data
//

__declspec(property(get=Getisc_conn,put=Putisc_conn))
IDispatchPtr isc_conn;
__declspec(property(get=Getiproxy_obj,put=Putiproxy_obj))
IDispatchPtr iproxy_obj;
__declspec(property(get=Getis_proxy_name,put=Putis_proxy_name))
_bstr_t is_proxy_name;
__declspec(property(get=Getii_ret,put=Putii_ret))
short ii_ret;
__declspec(property(get=Getib_finish,put=Putib_finish))
VARIANT_BOOL ib_finish;
__declspec(property(get=Getis_message,put=Putis_message))
_bstr_t is_message;
__declspec(property(get=Getis_version,put=Putis_version))
_bstr_t is_version;
__declspec(property(get=Getis_url,put=Putis_url))
_bstr_t is_url;
__declspec(property(get=Getis_code,put=Putis_code))
_bstr_t is_code;

//
// Wrapper methods for error-handling
//

void Putisc_conn (
IDispatch * argvalue );
IDispatchPtr Getisc_conn ( );
void Putiproxy_obj (
IDispatch * argvalue );
IDispatchPtr Getiproxy_obj ( );
void Putis_proxy_name (
_bstr_t argvalue );
_bstr_t Getis_proxy_name ( );
void Putii_ret (
short argvalue );
short Getii_ret ( );
void Putis_result (
SAFEARRAY * * argvalue );
SAFEARRAY * Getis_result ( );
void Putis_calc_m (
SAFEARRAY * * argvalue );
SAFEARRAY * Getis_calc_m ( );
void Putis_calc_z (
SAFEARRAY * * argvalue );
SAFEARRAY * Getis_calc_z ( );
void Putib_finish (
VARIANT_BOOL argvalue );
VARIANT_BOOL Getib_finish ( );
void Putis_message (
_bstr_t argvalue );
_bstr_t Getis_message ( );
void Putis_version (
_bstr_t argvalue );
_bstr_t Getis_version ( );
void Putis_url (
_bstr_t argvalue );
_bstr_t Getis_url ( );
void Putis_code (
_bstr_t argvalue );
_bstr_t Getis_code ( );
VARIANT_BOOL getvolumeinformationa (
_bstr_t lprootpathname,
BSTR * lpvolumenamebuffer,
unsigned long nvolumenamesize,
unsigned long * lpvolumeserialnumber,
unsigned long * lpmaximumcomponentlength,
unsigned long * lpfilesystemflags,
BSTR * lpfilesystemnamebuffer,
unsigned long nfilesystemnamesize );
_bstr_t ysm_getmac ( );
_bstr_t f_getnonull_s (
_bstr_t as_str );
double f_getnonull (
double ad_num );
HRESULT destroyinstace ( );
_bstr_t get_mac ( );
_bstr_t get_serialnumber ( );
_bstr_t encrypt (
_bstr_t as_str );
_bstr_t createinstace ( );
_bstr_t checkpeople (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t hospitalizationcheckin (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
SAFEARRAY * * as_in2 );
_bstr_t cancelhospitalizationcheckin (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t checkhospitalizationcheckinstate (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t checkdetaileddatastate (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t canceldetaileddata (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t getwrongcheckcomputationdatanumber (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t getwrongcheckcomputationdata (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t translate (
_bstr_t as_parm );
_bstr_t getwrongcheckcomputationdataresult (
short ai_row,
short ai_col );
_bstr_t transfertreatmentcheckin (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t canceltransfertreatmentcheckin (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t checktransfertreatmentcheckinstate (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t counthospitalizationcompensation (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
SAFEARRAY * * as_in2,
SAFEARRAY * * ad_in3,
SAFEARRAY * * ad_in4 );
_bstr_t checkhospitalizationcompensationstate (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t gethospitalizationcompensationvalue (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t cancelhospitalizationcompensation (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t getoutpatientcompensationvalue (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t countoutpatientcompensation (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
SAFEARRAY * * as_in2,
SAFEARRAY * * ad_in3,
SAFEARRAY * * ad_in4 );
_bstr_t canceloutpatientcompensation (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t gethospitalizationcompensationresult (
short ai_row );
_bstr_t getoutpatientcompensationresult (
short ai_row );
_bstr_t checkoutpatientcompensationstate (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t checkpeopledetail (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1 );
_bstr_t uploaddiagnosisandtreatdata (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
SAFEARRAY * * as_in2,
SAFEARRAY * * as_in3,
SAFEARRAY * * as_in4,
SAFEARRAY * * as_in5,
SAFEARRAY * * as_in6,
SAFEARRAY * * as_in7,
SAFEARRAY * * as_in8,
SAFEARRAY * * ad_in9,
SAFEARRAY * * ad_in10,
SAFEARRAY * * ad_in11 );
_bstr_t uploadmedicinedata (
SAFEARRAY * * as_in0,
SAFEARRAY * * as_in1,
SAFEARRAY * * as_in2,
SAFEARRAY * * as_in3,
SAFEARRAY * * as_in4,
SAFEARRAY * * as_in5,
SAFEARRAY * * as_in6,
SAFEARRAY * * as_in7,
SAFEARRAY * * as_in8,
SAFEARRAY * * as_in9,
SAFEARRAY * * as_in10,
SAFEARRAY * * ad_in11,
SAFEARRAY * * ad_in12,
SAFEARRAY * * ad_in13 );
回复 点赞
菜牛 2009年04月18日
__uuidof()操作符中的参数应该是一个接口的名称而不是接口类型,类似Concustom这样的,你找找,或者把hyjk.dll发给我(Mackz@sina.com)或者把tlh文件贴出来。
回复 点赞
TianChong 2009年04月18日
你的DLL是否已在系统中注册啊?这可是关键的一步。

对了,我没有找到他们的hyjk.dll,和接口说明,您可以给我发一份吗?或加我QQ:30101,我常用VC及PB,交个朋友。
回复 点赞
KcSoft 2009年04月17日
我已经import将hyjk.dll加进来了,也看到所有函数的原型,但是不知道怎么调用,网上查了很多资料都无法解决,请大家帮帮忙.不知道中山锐旗,都做到省项目了,连VC++调用的例子都没有,不可能全部医院信息系统都用PB做吧?。
回复 点赞
hust_terry 2009年04月17日
看明白函数调用关系,将COM加载到C++工程中,自己调一下应该就行。这种自动转换没见过。
回复 点赞
KcSoft 2009年04月17日
已经编译通过了,VC++6。0
回复 点赞
KcSoft 2009年04月17日
[Quote=引用 4 楼 hust_terry 的回复:]
除了找人家要个vc++的例子这个捷径外,你就只能看懂PB例子的逻辑然后参照着自己写了。

我们做的都是提供VC的例子,人家C#的看懂来照着逻辑来调。
[/Quote]

人家公司没有,说是全省都按PB方式提供,纳闷呀,一个开发省项目的公司。

我已经用import方式加进了DLL,但是总是在
IconcustomPtr.CreateInstance(__uuidof(Iconcustom));这一步失败,说是没有注册类型。
只有DLL文件,不知道是不是缺少了tlb文件?急呀!
回复 点赞
persistence_motivate 2009年04月17日
虽然不懂,也来留下个脚印11
回复 点赞
hust_terry 2009年04月17日
除了找人家要个vc++的例子这个捷径外,你就只能看懂PB例子的逻辑然后参照着自己写了。

我们做的都是提供VC的例子,人家C#的看懂来照着逻辑来调。
回复 点赞
KcSoft 2009年04月17日
UP
回复 点赞
发动态
发帖子
VC/MFC
创建于2007-09-28

7895

社区成员

42.1w+

社区内容

VC/MFC相关问题讨论
社区公告
暂无公告