0

我想设置系统变量 MQSERVER 以使用 QTP 连接到 MQ。每次从 QTP 更改此值时,我都需要重新启动 QTP 以反映更改。

例如在系统变量窗口中,MQSERVER = ABCD

使用更改变量

 Set objWSH = CreateObject("WScript.Shell")
 Set objSystemVariables = objWSH.Environment("SYSTEM") 
 objSystemVariables(MQVariableName) = MQVariableValue

该变量设置正确,但在连接到 websphere MQ 时未反映在 QTP 代码中。

当我重新启动 QTP 时,QTP 立即正确读取了 env 变量。您能否让我知道如何使用以下 API 方法。我在 QTP 中遇到类型不匹配。

lnRetVal = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "Environment", 2, 1000, Null) 'Getting type mismatch here

使用连接到队列管理器的代码更新我的原始问题。

我想要做的最基本的事情是(如果不重新启动 QTP 就无法完成)

1) 连接到队列管理器

2)把消息

3) 连接到另一个队列管理器

4) 读取输出

Const MQOO_OUTPUT = 16
 Const MQOO_INPUT_AS_Q_DEF = 1
 Set MQS = CreateObject("MQAX200.MQSession")                          
 Set QM = MQS.AccessQueueManager(Environment.Value("MQName")) 'This will pass the queue name and  access the queue manager.
 Set MQQueue = QM.AccessQueue(strQueName, MQOO_INPUT_AS_Q_DEF Or MQOO_OUTPUT)
 Set PutOptions = MQS.AccessPutMessageOptions()
 PutOptions.Options = MQPMO_NO_SYNCPOINT
 Set PutMsg = MQS.AccessMessage() 
 PutMsg.CharacterSet = 1208
 PutMsg.MessageData = PutMsgStr 'the message text 
 PutMsg.ApplicationIdData = "INTF_0439B" 
 MQQueue.Put PutMsg, PutOptions 'write the message to queue.

另外,我的 websphere MQ 版本是 7.0.1.8

4

0 回答 0