Tuxedo's function is much, all applications use them. These functions are included in the development
A certain dynamic library in the package. Below
Tpinit, TpCall, Tpterm, Tpfree, Tpalloc, Fget32, FCHG32, FLDOCC32 Several functions are
Examples describe the programming method under this subset. (Not very accurate)
1. First find the dynamic library where these functions are located. After parsing, the above function is found.
In "WTUXWS32.DLL", "libfml32.dll" two dynamic libraries. How good, have these two movements
When the application is released, they can take them. No need to pop up
Dynamic library positioning is wrong. And slow, after the study found that there is these two DLLs, they
The operation requires the following 6 DLL: libbuft.dll, libngine.dll, libfml.dll, libgpnet.dll, libtux.dll, libwsc.dll. Haha. Finally, the parsing is complete.
Ok, put these files Copy out of your project directory. A great. Hurry and go to the next step.
2, configure the compilation environment. This is very important. In order to make everyone programmed, we do some small actions. in
BCB installation directory (ie the directory of $ (BCB) ID) establishes a tuxedo / directory,
The / bin /, / include /, / / lib / several directory copies in the Tuxedo development package are in this directory. Then, in Option | Directories / Conditionals, include include Path: $ (BCB) / Tuxedo / Include Library Path: $ (BCB) / Tuxedo / Lib, the environment is set. In your engineering include: #include
Is it not good? This is nothing, depending on the personal programming environment. I am used to using the function in the structure name, because you are not very familiar with them, sometimes forgetting the name, put it in the structure, using the BCB automatic prompt function, you can easily find it ( Think of the function you need. I have defined the following structure: typedef struct _FunTuxedo {int (_TMDLLENTRY * tpcall) (char _TM_FAR *, char _TM_FAR *, long, char _TM_FAR * _TM_FAR *, long _TM_FAR *, long); int (_TMDLLENTRY * tpinit) (TPINIT _TM_FAR * ); Int (_tmdllentry * tpterm); void (_tmdllenTry * tpfree) (char _tm_far *); char * (_tmdllenTry * tpalloc) (char_tm_far *, char _tm_far *, long); int (_tmdllenTry * fget32) FBFR32 _TM_FAR *, FLDID32, FLDOCC32, char _TM_FAR *, FLDLEN32 _TM_FAR *); int (_TMDLLENTRY * Fchg32) (FBFR32 _TM_FAR *, FLDID32, FLDOCC32, char _TM_FAR *, FLDLEN32); FLDOCC32 (_TMDLLENTRY * Foccur32) (FBFR32 _TM_FAR *, FLDID32); hmodule hlibfml32; // libfml32.dll dynamic library HMODULE HWTUXWS32; // wtuxws32.dll dynamic library handle} Funtuxedo, * pfuntuxedo; here, I add two dynamic library handles to the structure because I intend to dynamically Use the Tuxedo middleware. It is convenient for me to release them. The next section introduces loading / release them 4 loading, release the middleware (Based on the Funtuxedo structure) Ha, which is easy to use to loadLibrary, FreeElibrary, getProcaddress three functions.
The loading code is as follows: pfuntuxedo pfun; // loading fchg32, fget32 by libfml32.dll pfun-> hlibfml32 = loadingLibrary ("libfml32.dll"); if (pfun-> hlibfml32 == null) {return -1;} (FarProc & PFUN-> FCHG32 = (FARPROC) GetProcaddress (PFUN-> Hlibfml32, "FCHG32"); (FarProc &) PFUN-> FGET32 = (FarProc) getProcadDress (PFUN-> HLIBFML32, "FarProc &) PFUN -> FOCCUR32 = (FARPROC) GetProcaddress (PFUN-> Hlibfml32, "FOCCUR32"); if (PFUN-> FCHG32 == NULL || PFUN-> FGET32 == NULL || PFUN-> FOCCUR32 == NULL) {freeelibrary PFUN-> HLIBFML32); PFUN-> HLIBFML32 = null; return-2;} // loading tpinit, tpalloc, tpfree, tpinit, tpterm by wtuxws32.dll pfun-> hws32 = loadingLibrary ("wtuxws32.dll"); if ( pFun-> hWtuxws32 == NULL) {FreeLibrary (pFun-> hLibfml32); pFun-> hLibfml32 = NULL; return -3;} (FARPROC &) pFun-> tpcall = (FARPROC) GetProcAddress (pFun-> hWtuxws32, "tpacall "); (FarProc &) PFUN-> TPalloc = (FarProc) getProcaddress (PFUN-> HWTUXWS32, "TPalloc"); (FarProc &) PFUN-> TPFree = (FarProc) getProcaddress (PFUN-> HWTUXWS32, "TPFree"); (FarProc); &) pfun-> tpinit = (farProc) getProcaddress (PFUN-> HWTUXWS32, "TPINIT"); (FarProc &) PFUN-> TpterM = (FarProc) getProcAddress (PFUN-> HWTUXWS32, "TpterM"); if (PFUN- > tpcall == null || pfun-> tpalloc ==
Null || PFUN-> TPFREE == NULL || PFUN-> Tpinit == NULL || pfun-> tpterm == null) {freeelibrary (PFUN-> HLIBFML32); PFUN-> Hlibfml32 = null; freeelibrary (PFUN-> HWTUXWS32); PFUN-> HWTUXWS32 = null; return-4;} is simple when released, only freelibrary (pfun-> hlibfml32); freeelibrary (pfun-> hwtuxws32); (Note: Freelibrary (dllhandle) does not have problems in the traditional situation. But in
BEA's DLL, the Freelibrary of MS is not in, when the app
When exiting, there will be illegal address access issues. I checked several times, as long as I was called TpCall
There is a problem when exiting. )
The compromise is to use try-catch, do not use freeelibrary when released.
When the application exits, finally use freelibraryandexitthread, otherwise even
You can use FreeElibrary and can't capture an exception via Catch. Ha ha.
5, use. Example: ... content check. PFuntuxedo PFUN; Char * PsendBuff; Long Lret; Short Sret; INT IRET; / / Middleware Service PsendBuff = PFUN-> Tpalloc (...); if (psendbuff == null) {Return Err_tuxedo;} PRECVBUFF = pfun-> tpalloc (...); if (precvbuff == null) {pfun-> Tpfree (psendbuff); return err_tuxedo;} try {itt = pfun-> fchg32 (...); if (IRet == -1) {throw (1);} // Establish connection IRet = PFUN-> TPinit (null); if (IRet == -1) {throw (2);} iret = pfun-> tpcall (...) ; If (IRET == -1) {throw (3);} IRET = PFUN-> TpterM (); if (IRET == -1) {throw (4);} Iret = PFUN-> FGET32 (... ); If (IRET == -1) {throw (4);} pfun-> tpfree (psendbuff); pfun-> tpfree (precvbuff);} catch (int err) {PFUN-> Tpfree (psendbuff); PFUN- > Tpfree (precvbuff); Return Err;} catch (...) {return err_unknown;} // This can handle the received data result // ... 6, compile.