icelander 发表于 2013-1-27 05:36:32

Tuxedo 入门 C++Builder下的Sample

一、配置文件

#(c) 2003 BEA Systems, Inc. All Rights Reserved.#ident"@(#) samples/atmi/simpapp/ubbsimple$Revision: 1.5 $"#Skeleton UBBCONFIG file for the TUXEDO Simple Application.#Replace the <bracketed> items with the appropriate values.*RESOURCESIPCKEY123456#Example:#IPCKEY123456DOMAINIDsimpappMASTERsimpleMAXACCESSERS10MAXSERVERS5MAXSERVICES10MODELSHMLDBALN*MACHINESDEFAULT:APPDIR="D:\temp"TUXCONFIG="D:\temp\tuxconfig"TUXDIR="C:\bea\tuxedo8.1"#Example:#APPDIR="/home/me/simpapp"#TUXCONFIG="/home/me/simpapp/tuxconfig"#TUXDIR="/usr/tuxedo"WANGZHIPCLMID=simpleMAXWSCLIENTS=5ULOGPFX="D:\temp\ULOG"#Example:#beatuxLMID=simple*GROUPSGROUP1LMID=simpleGRPNO=1OPENINFO=NONE#GROUP2#LMID=simpleGRPNO=2OPENINFO=NONE*SERVERSDEFAULT:CLOPT="-A"simpserv SRVGRP=GROUP1 SRVID=1WSL SRVGRP=GROUP1 SRVID=2 CLOPT="-A -- -n //127.0.0.1:3050 -m2 -M5 -x10"*SERVICESTOUPPER

二、 代码
/************************************************************   Copyright (C), 2001-2008, Multimedia Vision. Co., Ltd.FileName: ConvertMess.cppAuthor: WangzhiDate: 2008-01-10Description:          Tuxedo 测试,基于simple app 修改,C++ Builder 6   Version:Function List:History:      <author>    <time>       <version>   <desc>      Wangzhi    2008/1/10      1.0   build this moudle***********************************************************/#include <vcl.h>#include <atmi.h>      /* TUXEDO Header File */#include <fml32.h>   /* TUXEDO Header File */#include <tmenv.h>   /* TUXEDO Header File */#pragma hdrstop#include "ConvertMess.h"//---------------------------------------------------------------------------#pragma package(smart_init)#pragma resource "*.dfm"TConvertMessForm *ConvertMessForm;//---------------------------------------------------------------------------__fastcall TConvertMessForm::TConvertMessForm(TComponent* Owner)    : TForm(Owner){}//---------------------------------------------------------------------------void __fastcall TConvertMessForm::butConvertClick(TObject *Sender){    char* sendBuffer;         // 发送数据缓冲区    char* recvBuffer;         // 接收数据缓冲区    long sendBufLength;       // 发送数据长度    long recvBufLength;       // 接收数据长度    int iRet;    // 返回码    ShowErrorMessage("Werrer");    // 设置环境变量    tuxputenv("WSNADDR=//127.0.0.1:3050");    // 连接系统    if( -1 == tpinit((TPINIT *) NULL) )    {      ShowErrorMessage(tpstrerror(tperrno));      return;    }    // 计算发送缓冲长度    sendBufLength = strlen(txtMess->Text.c_str());    // 分配发送数据缓冲内存    sendBuffer = (char *) tpalloc("STRING", NULL, sendBufLength + 1);    if( NULL == sendBuffer) {ShowErrorMessage("Alloc Send Buffer Memory Failed!!");tpterm();      return;}    // 分配接收数据缓冲内存    recvBuffer = (char *) tpalloc("STRING", NULL, sendBufLength + 1);    if( NULL == recvBuffer)    {      ShowErrorMessage("Alloc Recive Buffer Memory Failed!!");      tpfree(sendBuffer);      tpterm();      return;    }    // 把要发送的数据放入缓冲区    StrCopy(sendBuffer, txtMess->Text.c_str());    // 调用服务    iRet = tpcall("TOUPPER", (char *)sendBuffer, 0, (char **)&recvBuffer,                  &recvBufLength, 0);    // 判断返回值,-1 为调用失败    if( -1 == iRet)    {      ShowErrorMessage(tpstrerror(tperrno));      tpfree(sendBuffer);      tpfree(recvBuffer);      tpterm();    }    else    {      txtConvert->Text = StrPas(recvBuffer);      tpfree(sendBuffer);      tpfree(recvBuffer);      tpterm();    }}//---------------------------------------------------------------------------void TConvertMessForm::ShowErrorMessage(char * errMess){    lblNotice->Caption = errMess;}
页: [1]
查看完整版本: Tuxedo 入门 C++Builder下的Sample