Can anyone tell me how to create message queues during setup installation?
I want to do it using MSMQ but have no idea where to start with.
Thanks in advance
This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Create MSMQ queue during installation
Started by
Murali
, Mar 06 2002 14:57
2 replies to this topic
Posted 07 March 2002 - 23:21
Here is VBScript code that I have written to both create and delete Private Queues.
You could easily modify it to get the Queue names from a Property, my particular implementation required the Names to be something specific, so I hard coded them.
You would then need to author a Custom Action to call the respective functions.
Code Sample |
Sub CreatePrivateQueues dim oQue set oQue = CreateObject ("MSMQ.MSMQQueueInfo") if IsObject(oQue) then oQue.PathName = ".\PRIVATE$\QueueName" oQue.Create False, True end if Set oQue = Nothing End Sub sub DeletePrivateQueues dim oQue On Error Resume Next set oQue = CreateObject ("MSMQ.MSMQQueueInfo") if IsObject(oQue) then oQue.PathName = ".\PRIVATE$\QueueName" oQue.Delete Err.Clear end if Set oQue = Nothing End Sub |
You could easily modify it to get the Queue names from a Property, my particular implementation required the Names to be something specific, so I hard coded them.
You would then need to author a Custom Action to call the respective functions.
Posted 20 March 2002 - 06:01
Thanks a lot Scott.
For those of you who are interested in VC code...
----------------------------------------------
#include <atlbase.h>
#import "mqoa.dll" no_namespace
UINT stdcall CreateQueue(MSIHANDLE hInstall)
{
wchar_t * pszwPath = NULL;
TCHAR szQueuePath[MAX_PATH] = {0};
DWORD dwSize = MAX_PATH;
BSTR sDummy = NULL;
//initialize ole...
OleInitialize(NULL);
IMSMQQueueInfoPtr pMSMQ("MSMQ.MSMQQueueInfo");
//read the property QUEUENAME
MsiGetProperty(hInstall, TEXT("QUEUENAME"), szQueuePath, &dwSize);
if (!szQueuePath)
{
//show error
}
pszwPath = szQueuePath;
try
{
pMSMQ->PathName = pszwPath;
pMSMQ->Create();
}
catch (_com_error &e)
{
//dummy catch...
sDummy = e.Description();
}
}
UINT stdcall RemoveQueue(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
TCHAR szQueuePath[MAX_PATH] = {0};
DWORD dwSize = MAX_PATH;
wchar_t * pszwPath = NULL;
//initialize ole...
OleInitialize(NULL);
IMSMQQueueInfoPtr pMSMQ("MSMQ.MSMQQueueInfo");
//get the property for MSMQ path
MsiGetProperty(hInstall, TEXT("QUEUENAME"), szQueuePath, &dwSize);
if (!szQueuePath)
{
//show error...
}
pszwPath = szQueuePath;
//set the queue path
pMSMQ->PathName = pszwPath;
//delete...
hr = pMSMQ->Delete();
//check for failure...
if (FAILED(hr))
{
//show error...
}
}
For those of you who are interested in VC code...
----------------------------------------------
#include <atlbase.h>
#import "mqoa.dll" no_namespace
UINT stdcall CreateQueue(MSIHANDLE hInstall)
{
wchar_t * pszwPath = NULL;
TCHAR szQueuePath[MAX_PATH] = {0};
DWORD dwSize = MAX_PATH;
BSTR sDummy = NULL;
//initialize ole...
OleInitialize(NULL);
IMSMQQueueInfoPtr pMSMQ("MSMQ.MSMQQueueInfo");
//read the property QUEUENAME
MsiGetProperty(hInstall, TEXT("QUEUENAME"), szQueuePath, &dwSize);
if (!szQueuePath)
{
//show error
}
pszwPath = szQueuePath;
try
{
pMSMQ->PathName = pszwPath;
pMSMQ->Create();
}
catch (_com_error &e)
{
//dummy catch...
sDummy = e.Description();
}
}
UINT stdcall RemoveQueue(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
TCHAR szQueuePath[MAX_PATH] = {0};
DWORD dwSize = MAX_PATH;
wchar_t * pszwPath = NULL;
//initialize ole...
OleInitialize(NULL);
IMSMQQueueInfoPtr pMSMQ("MSMQ.MSMQQueueInfo");
//get the property for MSMQ path
MsiGetProperty(hInstall, TEXT("QUEUENAME"), szQueuePath, &dwSize);
if (!szQueuePath)
{
//show error...
}
pszwPath = szQueuePath;
//set the queue path
pMSMQ->PathName = pszwPath;
//delete...
hr = pMSMQ->Delete();
//check for failure...
if (FAILED(hr))
{
//show error...
}
}
[b]Murali[b]