MQサポートパック
〜VBで開発用〜
0.改定履歴
- 1999.02.13 初版
1.はじめに
このドキュメントでは,MQのサポートパックのRead Meを翻訳しただけのものである.
このファイルには,サポートパックのファイルの中身の意味とか,インストール方法などがかかれている.
2.取得
MQ Clientは,以下のURLで取得することが出来る.(無料)
- Transaction Systems SupportPacs for MQSeries
3.内容
MQSeries Visual Basic Support for Windows Statement Licensed Materials - Property of IBM SupportPac MA04 (c) Copyright IBM Corp. 1996, 1999 All rights reserved. U.S. Government Users Restricted Rights - use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Status: Version 1 Release 5 CHANGES FOR VERSION 1 RELEASE 5 Ver1R5に加えられた変更内容. Added support for MQSeries Version 5 MQ V5をサポート. Client or server programs including Calls, Structures and Constants specific to Version 5. クライアントとサーバは,Ver5に特有の関数呼出し,構造体と定数を使って プログラムを作成できる. Added support for Visual Basic Version 6 VB V6に対応. SupportPac can be used with Visual Basic Version 3 (16-bit), Visual Basic Version 4 (16-bit and 32-bit), Visual Basic Version 5 (32-bit) and Visual Basic Version 6 (32-bit). このサポートパックは,VBのVer3(16bit)とVB Ver4(16,32bit)と,VB5,6 (32bit)で使用することが出来る. Common interface module CMQB.BAS 共通のインタフェイスモジュール"CMQB.BAS". Replaced CMQB4.BAS and CMQB5.BAS with a common module CMQB.BAS which includes support for MQSeries V5 Calls, Structures and Constants. This should be used with Visual Basic 4, Visual Basic 5 or Visual Basic 6 projects. CMQB4.BAS,CMQB5.BASファイルを,MQの新しい機能を使うために,CMQB.BAS に置き換えて使ってください. PLATFORM PREREQUISITES プラットホーム必要条件 MQSeries V2 or V5 Client (Windows 3.1, 95/98 or NT) Either Client SupportPac for Microsoft Windows 3.1, Windows 95/98 or Windows NT Or Windows client code from an MQSeries server product MQSeries V2 or V5 Server (Windows 3.1 or NT) Either MQSeries for Windows NT - V5.0 Or MQSeries for Windows NT - V2.0 (Now out of service) Or MQSeries for Windows V2.0 (Now out of service) (Note: MQSeries for Windows V2.1 has Visual Basic support included) Microsoft Visual Basic Either Visual Basic Version 3 (16-bit applications) Or Visual Basic Version 4 (16-bit or 32-bit applications) Or Visual Basic Version 5 (32-bit applications) Or Visual Basic Version 6 (32-bit applications) SUPPORTED ENVIRONMENTS 支持された環境 MQSeries Version 5 Client or server programs supported including Calls, Structures and Constants specific to Version 5. MQ V5の全ての構造体と定数と関数をサポートしているC/Sプログラム. MQSeries Version 2 Supported except for specific MQSeries Version 5 Calls, Structures and Constants. MQ V5に特化した構造体と定数と関数をサポートしているC/Sプログラム. MQSeries for Windows V2.0 A 16-bit only product. 16-bit only programs can only be written using Visual Basic 3 or Visual Basic 4. VB V3か,VB V4で作成された16bitプロダクトのみ. MQSeries for Windows V2.1 Not supported - this product already includes native support for Visual Basic. サポートしません. INTRODUCTION 紹介 This SupportPac is designed to extend the range of options for MQSeries customers using a Windows 3.1, Windows 95/98, Windows NT environment by enabling the use of Microsoft's Visual Basic product. このサポートパックは,MQSeriesをWIn3.1,95,98,NTの環境下で,VBを使って 使用用途を広げる事を目的に提供されている. Using this SupportPac you can use Visual Basic to develop Windows 3.1, Windows 95/98, Windows NT graphical user interfaces for IBM MQSeries applications. あなたが,サポートパックを使ってVBでWin3.1,95,98,NT上でMQのGUIアプリ ケーションを作成することが出来る. To understand this SupportPac, you must be familiar with MQSeries concepts. このサポートパックを理解するためには,MQの概念を勉強しとかにゃなら ん. SUPPORTPAC CONTENT サポートパックの内容 This SupportPac contains Visual Basic source code to allow MQSeries applications to be written using Visual Basic. Also included are sample programs illustrating how the MQSeries API is invoked using Visual Basic 4, Visual Basic 5 or Visual Basic 6 and additional DLLs required for Windows NT. このサポートパックは,MQのアプリをVBで使えるようにするためのVBソース を含んでいる. VB4を使って,MQ APIがどの様に適用されるか実例で説明しているサンプルが 含まれている. VB5とVB6は,WindowsNTの為に追加のDLLを必要とする. OVERVIEW OF VISUAL BASIC / MQSERIES INTERFACE VBとMQインタフェイスの外観 INSTALLATION インストール方法 Change to the directory where the SupportPac is loaded and type: サポートパックをインストールしたディレクトリで,次のコマンドを入力 しなさい. SETUP C:\MQM The installation program copies sample files, bindings for Visual Basic and this README.WRI file. If MQ is installed in a different directory change the above command appropriately. このインストールプログラムでは,VBのサンプルファイルと,READ MEファイ ルをコピーする. もし,MQが違うディレクトリにインストールされている場合は,先のコマン ドのパスを変更して適切に実行する. SELECTING AND CONFIGURING THE APPROPRIATE .BAS FILE .BASファイルを適切に選択して設定する Visual Basic 4, Visual Basic 5, or Visual Basic 6 users should always include CMQB.BAS in their projects. VB4〜6で,"CMQB.BAS"ファイルをプロジェクトに入れる. Existing programs should be changed to include CMQB.BAS either when migrating to a higher level of Visual Basic or when using MQSeries version 5 Calls, Structures or Constants which require this release of the SupportPac. 既存のMQプログラムは,新しいバージョンのVBに変更する場合や,MQ V5の新 しい関数,構造体,定数を使用する場合は,"CMQB.BAS"をプロジェクトに入 れる様に変更する事を推奨する. The selection between 16 and 32 bit mode is made automatically in this file. 16bit,32bitモードは,このCMQB.BASファイルが自動的に選択される. The selection between MQSeries server and MQSeries client is made based on the MQType conditional compilation constant. MQ Server,MQ ClientのMQTypeは,暫定的に定数を編集して選択される. This constant should be set in the Visual Basic project file. この定数は,VBのプロジェクトファイルに入れられるべきである. From the Visual Basic IDE, select the menu item Project->Project Options... the tabbed dialog item Make and fill in the field Conditional Compilation Arguments, valid values are: VB IDEを使う場合は,[プロジェクト]メニューの[プロジェクトオプション] を選択して,ダイアログの[Make and fill]の[条件つき編集]引数に,以下の 項目を正確に入力する. MQType = 1 MQSeries Server MQType = 2 MQSeries Client ※IDEとは,コンパイル,デバッグなどをGUIで統合化してできる開発環境. ここではハードディスクなどの規格のIDEでは無い. [条件つき編集]って,条件付コンパイルオプションかな? VB4でメニューをチェックしてみたけど,該当するものは [実行]→[オプション]→[詳細設定] かとおもう. Visual Basic 3 users should include CMQB3.BAS (for server applications) or CMQB3C.BAS (for client applications). VB V3のユーザは,"CMQB3.BAS"をMQアプリの為にインクルードする. There is no MQType variable to set because the choice of server or client is determined by the included file. 変数MQTypeによって,そのプログラムがクライアント用なのかサーバ用なの かがセットされる. Visual Basic 3 users should consider migrating existing 16-bit applications to Visual Basic 4, or a higher level of Visual Basic for 32-bit applications, which use CMQB.BAS VB3のユーザは,16bitアプリをVB4にしてしまうか,さらに16bitアプリを 32bitアプリにアップグレードするか,よ〜く考える必要があります. PROBLEM DETERMINATION 問題判別 Before using the SupportPac, verify the existing configuration using supplied samples provided with either the client or server. サポートパックを使う前に,供給されたサンプルでクライアントかサーバ と一緒に,設定を検証しておいてください. These verify the interface and MQ using C calls. それらは,MQのC言語インタフェイスを使って実証します. The Visual Basic interface will only work if the environment is correctly configured for the base product. もし,環境が正しく設定されていれば,VBインタフェイスも正しく動きま す. SAMPLE CODE サンプルコード Samples are provided for Visual Basic Version 4, Visual Basic 5 or Visual Basic 6 and use CMQB.BAS to make calls to an MQ server. サンプルでは,VB4〜6で"CMQB.BAS"を使ってMQ Serverに接続するものです. By changing the setting for MQType=1 to MQType=2, calls can be made to a client. 環境変数MQType=1から2に変更することで,MQインタフェイスをクライアント として変更することが出来ます. These samples are stored in Visual Basic 4 format. これらのサンプルは,フォーマットは,VB4ファイル形式です. Once they are loaded and saved in a higher level of Visual Basic, they cannot be reused in Visual Basic 4. もし,VB4よりバージョンの高いVBで読み込んで保存した場合,これらの ファイルは,VB4では使えなくなりますので注意が必要です. If this is a requirement, they should be backed up before use. もし,必要だったらバックアップしておけばよいでしょう. Each sample can be run from the Visual Basic IDE by loading the project file into Visual Basic 4, Visual Basic 5, Visual Basic 6 and selecting Start from the Run menu. VB-IDEによって,VB4,VB5,VB6ソースをプロジェクトファイルに読み込んで使 う事が出来る. Alternatively each client or server project can be compiled to an executable by selecting 交互にクライアントかサーバのプロジェクトをコンパイルすることによっ て,実行モジュールを作成することが出来る. Make MyProject.exe... from the File menu. Users of Visual Basic 3 can create their own programs by including CMQB3.BAS (for server applications) or CMQB3C.BAS (for clients applications) in their project file. VB3のユーザは,VBのプロジェクトに,サーバ用"CMQB3.BAS"かクライアント 用"CMQB3C.BAS"を使ってプログラムを作成することが出来る. The following project files are installed in the vb\samples directory: 次のVB用プロジェクトファイルは,VB\SAMPLESにインストールされる. AMQSPUTB.VBP Sample code for putting data on a queue. "AMQSPUTB.VBP"は,キューにデータをプットする為のサンプル. AMQSGETB.VBP Sample code for getting data from a queue. "AMQSGETB.VBP"は,キューからデータをゲットするためのサンプル. AMQSBCGB.VBP show code for browsing a queue. "AMQSBCGB.VBP"は,キューの中身を参照するサンプル. STRINGS.VBP Sample which issues MQPUT and MQGET calls for strings and a user defined Type data. "STRINGS.VBP"は,MQPUTかMQGETのどちらかを呼び出す文字列とユーザ定義 データである. MQTRIVS.VBP Server sample code for a simple demonstration of major MQSeries calls. MQTRIV.FRM has the form with push buttons and code. "MQTRIVS.VBP"は,良く使われるMQの簡単なデモを行なうサーバ用サンプルで す. "MQTRIV.FRM"は,画面(フォーム)とボタンを押すサンプルです. MQTRIVC.VBP Client sample code for a simple demonstration of major MQSeries calls. MQTRIV.FRM has the form with push buttons and code. "MQTRIVC.VBP"は,良く使われるMQの簡単なデモを行なうクライアント用サン プルです. "MQTRIV.FRM"は,画面(フォーム)とボタンを押すサンプルです. VISUAL BASIC CALLS BY REFERENCE OR BY VALUE? VB用関数呼出しの,リファレンスマニュアルと値は? Visual Basic defines all calls by reference by default. VBのすべての関数呼出しは,デフォルトでリファレンスで定義されている. The ByVal keyword is used to pass by value. (VBの)ByValキーワードを使って値をMQ提供の関数に渡すことが出来る. Where a parameter is used only for input, it is declared ByVal. パラメータが入力のみの場合,その変数はByValで宣言している必要がある. Strings are always declared ByVal which forces Visual Basic to convert the internal form of the string ( length and string ) to a null terminated string as used by the C compiler. 文字列(Strings)は,VBでストリングの内部形式を変更するか,Cコンパイラ で使用するNULLで終了される文字列のどちらかが必要になるので,いつも ByValで宣言する. (ByValは,関数に対して"値渡し".ポインタ渡しでは無い) Although the ByVal can be omitted, in the call, the keyword enhances readability. Except for strings, calls with ByVal are calls by value, on return from the function, the parameter is not changed. 関数呼出しのときにByValキーワードを省略できるとしても,このキーワー ドを入れておけばソースコードが読みやすくなる.文字列を除いて,ByVal により関数呼出しは,値で行なわれる. しかし,ByValを使っている場合, 関数からの戻り値として編集できないので注意する.(VBのヘルプでByValを 参照してみてください) MQGET, MQPUT, MQPUT1 BUFFER DEFINITION MQGET,MQPUT,MQPUT1のバッファの定義 For MQPUT the length of the buffer passed should match the length of the buffer: MQPUTの為のバッファ長は,次のようにして計算すればよい. BufLen = Len(MyBuffer) For MQGET the length of the passed string for the returned data must be large enough to contain this data. This can be achieved by defining the string explicitly: MQGETの為の文字列のバッファは,データを含むために十分に大きな領域を 定義して置く必要がある. これは,次のサンプルのように,明確に文字列を定義しておくことによって 達成できる. Dim MyString as String * 32 つまり,VBの省略宣言,"Dim MyString as String"なんてのじゃダメって ことかのぉ. Or by explicitly setting the length at run time: あるいは,プログラム実行時に,次のように明確に長さをセットする. MyString32 = String(32," ") この場合,MyString32に,32文字分のスペースをセットしている. If the length of the returned string is relatively unknown, use a value which is known to be larger. もし,返却される値が不明な場合,出来るだけ大きな領域を使用するように 宣言しておきなさい. If the length is too small, the returned data will not contain the data. もし,返却される値があまりにも小さい場合には,返却値は(ヘッダ以外の) データを含まないでしょう. Because this is potentially dangerous and because MQ cannot determine the size of the passed string, there is an intermediary piece of Visual Basic code to check the passed length with the declared length of the buffer. 潜在的で危険(プログラムのバグを引き起こす)なのと,MQが文字列のサイズ を確定することが出来ないの仕様があるで,VBの中でバッファ長を十分に定 義して置いて欲しいってこと. (VBは宣言がルーズなのでね) If the buffer is too small, the call returns before calling MQSeries. もし,バッファがとても小さい場合には,MQ関数を呼び出す時にエラーにな る. その時は,次のような定数で返却値が帰ってくる. MQRC_STORAGE_NOT_AVAILABLE (2071, X'817') Insufficient storage available 利用できる十分な空き領域がありません. The calls which Put and Get data require a definition for the data buffer. データPUTする場合とGETする場合にデータバッファの定義が必要です. The C definition defines this as a pointer to a character string. C言語の場合は,キャラクタ型文字列へのポインタが必要です. This allows the C programmer to pass a pointer to another type of data for example an integer or a structure. これは,Cプログラマが,整数か構造をサンプルの為に引き渡すのを許可する 為です. In Visual Basic the definition of the buffer is: VBの場合は,次のようにバッファを定義してください. By Val Buffer as String This is required to force the conversion of Visual Basic strings into C Type strings which are null terminated strings. これは,VBの文字列を,C言語のストリング(NULLで終了)にコンバートする 為に必要です. To pass another type of data - for example an integer, or a user defined Type, use the alternate calls: 他のタイプのデータを渡す,たとえば整数とかユーザ定義体の場合,交互に 呼び出す必要がある. Function Alternate Definition MQPUT MQPUTANY MQGET MQGETANY MQPUT1 MQPUT1ANY These calls define the data buffer as: これらの呼出しは,バッファを定義する. Buffer as Any VBでanyで定義すると,データ型のチェックを禁止して,任意の値を関数に 引き渡せる. These definitions use an alias for the real call to MQPUT, MQGET or MQPUT1 and are required because Visual Basic does not provide function overloading and requires type checking. これらの定義は,VBからタイプ(型)のチェックをせずに負荷をかけないで MQPUT,MQGETかMQPUT1をエイリアスによって呼び出す事を可能にする. ※エイリアス DLLの中にある呼び出す関数に別名を付けられる. If the buffer is a string, the call must specify: もしバッファが文字列の場合,呼出しは次のように記述されなければならな い. Buffer as String DLLS USED IN MQSERIES IMPLEMENTATIONS ON WINDOWS PLATFORMS WindowsプラットホームでMQSerieseのDLLを使うためには There are several implementations of MQSeries that may be called from Visual Basic on Windows platforms. Windowsプラットホーム上のVBから,MQSeriesの機能を使うためには,いくつ かの条件を実行する必要がある. They all present the same interface (MQPUT etc) to Visual Basic. VBに,MQPUTなどのいくつかのインターフェイスを提供する. The different implemenations are selected by linking to the correct Dynamic Linked Library (DLL), as set in the DECLARE statement in the MQSeries Visual Basic .BAS files. 必要な機能を持っているDLLを選択して,VBの".BAS"ファイル内で,DLLを DECLARE文で宣言して使ってね. CLIENT AND SERVER クライアントとサーバ. The MQSeries server implements a queue manager on the machine in which the Visual Basic application is running. MQ Serverは,VBアプリが稼働しているマシンでのQueue Managerを実行す る. The MQSeries client generally gives access to an MQSeries queue manager on another machine (though it is possible to configure client access to a local queue manager). 一般的に言ってローカルなQueue Managerへのクライアントアクセスを設定す ることは可能だが,MQ Clientは他のマシンの上のQueue Managerにアクセス させることが出来る. DLLS USED BY THE MQSERIES VISUAL BASIC SUPPORT MQでVBによってDLLを使うことをサポートします. The following information is not needed for Visual Basic programmers, and should not be required for simple MQSeries installations. 次の情報は,VBプログラマには不要で,単純なMQのインストールにも不要な 話である. It is included to help with complications arising from non-standard MQSeries installations. これは,複雑に発生する標準のMQインストールじゃないもののヘルプであ る. The DLLs used from Visual Basic are as follows: VBによって必要なDLLは次の通りである. 16-BIT 32-BIT MQSeries Server MQM16.DLL MQMSTD.DLL MQSeries Client MQIC.DLL MQICSTD.DLL The correct installation of MQSeries to permit these DLLs to be used is the responsibilty of the system administrator. MQのインストールは,システム管理者の義務でこれらのDLLが使用されること を許すためにある. 32-BIT STDCALL AND CDECL 32bitのSTDCALLとCDECL The MQSeries 32-bit Windows libraries for C use the cdecl calling convention: MQM.DLL for the MQSeries server, MQIC.DLL for the MQSeries client. C言語の為の32bit Windowsライブラリで,CDECLを呼んでいる取り決めがあ る.MQ ServerではMQM.DLL,MQ ClientではMQIC.DLL. These DLLs are shipped as appropriate with all MQSeries servers. これらのDLLが全てが適切に組み込まれているものとしてMQサーバは稼働す る. They are not appropriate for calling from Visual Basic. これらのDLL(MQM.DLL,MQIC.DLL)は,VBから直接呼び出すのはダメ. The MQSeries for Windows 2.0 server product is shipped with the stdcall alternative MQMSTD.DLL. MQ Server2.0 for Winでは,STDCALLに変わってMQMSTD.DLLが使われる. The MQMSTD.DLL supplied with this SupportPac should not be installed for use with this product. このMQMSTD.DLLは,このサポートパックによってインストールされて使わ れるべきではない. The MQSeries for Windows NT server products do not ship with a stdcall library. MQのNTサーバ製品は,STDCALLライブラリを使ってメッセージ送信などを行 なう分けではない. MQMSTD.DLL shipped with this SupportPac acts as an interface convertor to permit calling from MQSeries for Windows NT from Visual Basic. このサポートパックでインストールされたMQMSTD.DLLは,WinNTからVBへイ ンタフェイスコンバータとして稼働するものである. The MQSeries for Windows NT server products do not ship with 32-bit Visual Basic client support (MQICSTD.DLL). MQ for WinNTS製品が,32bit VBクライアントをMQICSTD.DLLによって実現で きるというわけではない. MQICSTD.DLL shipped with this SupportPac acts as an interface convertor to permit calling the MQSeries 32-bit clients from Visual Basic. このサポートパックでインストールされたMQICSTD.DLLが,VBからMQの32bit クライアントとして呼び出すためのインタフェイスコンバータである. Even though common DLL names are used between the different MQSeries products to permit interoperability of applications using them, the DLLs are not identical. たとえ他のMQSeriesのプロダクトと結合して使っている場合に同じファイル 名のDLLを使っていたとしても,それらは相互運用が可能である. それは 同一のファイルではないからである. This should not cause any problems in normal production installations, but great care must be taken with path names etc where different MQSeries products are installed on a single machine for experimental purposes. The stacks below show the DLLs involved: これらは正常にMQをインストールしていれば問題にはならない. しかし,他のMQSeriesプロダクトとは,ファイルパス名等にとても気をつけ ておいて欲しい. 試験的なマシンを用意してインストールしてみて稼働確 認すればよいでしょう. 今回使用するDLLを以下に示します. MQSERIES C/VB 16/32 MQM-DLL THUNK-DLL MQ-DLL Windows C 16 MQM16 None AMQKERNW Windows VB 16 MQM16 None AMQKERNW Windows C 32 MQM MQM16T AMQKERNW Windows VB 32 MQMSTD MQMVB16T AMQKERNW Windows NT C 32 MQM None AMQZST Windows NT VB 32 MQMSTD None AMQZST 16 bit Client C 16 MQIC None None 16 bit Client VB 16 MQIC None None 32 bit Client C 32 MQIC32 None AMQRMQIA 32 bit Client VB 32 MQICSTD None AMQRMQIA MQMSTD.DLL and MQMICSTD.DLL is required for MQSeries for Windows NT and is supplied with this SupportPac. MQMSTD.DLLとMQMICSTD.DLLは,WindowsNTの為に必要で,このサポートパック で提供される. MQIC.DLL is now only a 16-bit client DLL. This avoids naming both a 16- bit and 32-bit version with the same name. MQIC.DLLは,現在は16bitクライアントのみのDLL. これは16bitと32bitで 同じ名前を付けることを避けるためである. IN CASE OF DIFFICULTIES 良く判らないときは,以下にアポを取ってください. Please contact: Simon Miller Mail Point 206 IBM UK Laboratories Hursley Park Hursley Winchester Hampshire England simon_miller@uk.ibm.com |