Server OS : Windows 2000
MQ Version 6.0
dll created in : VC++ 2008

Based on the instruction provided in the forum on To all newbie MQ Exit
developers

http://www.mqseries.net/phpBB2/viewt...cf65f115573a93



I have compiled the c program in VC++ 2008 express and created a test.dll

and copied in the following path
C:\Program Files\IBM\WebSphere MQ\exits

using MQ explorer. I have provided the exit name in "security exit name"
of my sender channel


I am getting following error message once i start the channel

Event Type: Error
Event Source: WebSphere MQ
Event Category: None
Event ID: 6175
Date: 7/8/2008
Time: 5:00:31 PM
User: N/A
Computer: SS-IC
Description:
The system could not dynamically load the library C:\Program
Files\IBM\WebSphere MQ\exits\test.dll. The system return code was
536895861. The queue manager will continue without this module.

This message applies to Windows NT and Windows 2000 systems only. The
dynamically loadable file C:\Program Files\IBM\WebSphere
MQ\exits\test.dll failed to load correctly due to an internal error. The
MQ error recording routine has been called.

Check that the file has not been corrupted then use the standard
facilities supplied with your system to record the problem identifier,
and to save the generated output files. Contact your IBM support center.
Do not discard these files until the problem has been resolved.
.. Do not discard these files until the problem has been resolved.


code

#include
#include
#include
#include
#include
#include
#include
#include
#include

extern void MQENTRY MQStart(void) {;}

#if defined (WIN32)
__declspec (dllexport) void MQENTRY SECEXIT (PMQCXP pChannelExitParms,
PMQCD pChannelDefinition,
PMQLONG pDataLength,
PMQLONG pAgentBufferLength,
PMQBYTE pAgentBuffer,
PMQLONG pExitBufferLength,
PMQPTR pExitBufferAddr);
#endif


void MQENTRY SECEXIT ( PMQCXP pChannelExitParms,
PMQCD pChannelDefinition,
PMQLONG pDataLength,
PMQLONG pAgentBufferLength,
PMQVOID pAgentBuffer,
PMQLONG pExitBufferLength,
PMQPTR pExitBufferAddr)
{
char outBuff[512];
char tempChl[MQ_EXIT_DATA_LENGTH + 1];
FILE* fh;
struct tm *newtime;
time_t tclock;
char *timeBuff;

PMQCXP pParms = pChannelExitParms;
PMQCD pChDef = pChannelDefinition;

// Attention newbie user: Make sure you select a valid directory and
filename!!!

// fh = fopen("C:\\Program Files\\IBM\\Websphere
MQ\\Exits\\SecExit.log", "a+");
fh = fopen("C:\\Temp\\SecExit.log", "a+");

time( &tclock );
newtime = localtime( &tclock );
timeBuff = asctime(newtime);
timeBuff[strlen(timeBuff) - 1] = '\0';

sprintf(outBuff, "%s : Now entering the security exit.\n", timeBuff);
fprintf(fh, outBuff);

memcpy(tempChl, pChannelDefinition->ChannelName,
MQ_CHANNEL_NAME_LENGTH);
tempChl[MQ_CHANNEL_NAME_LENGTH] = '\0';
sprintf(outBuff, "%s : Channel name is %s\n", timeBuff, tempChl);
fprintf(fh, outBuff);

if (pParms->ExitId == MQXT_CHANNEL_SEC_EXIT)
{
switch (pParms->ExitReason)
{
case MQXR_INIT:
pParms->ExitResponse = MQXCC_OK;
sprintf(outBuff, "%s : MQXR_INIT - Channel
Initialization\n", timeBuff);
fprintf(fh, outBuff);
break;
case MQXR_INIT_SEC:
pParms->ExitResponse = MQXCC_OK;
sprintf(outBuff, "%s : MQXR_INIT_SEC - Initialize
Secuity\n", timeBuff);
fprintf(fh, outBuff);
break;
case MQXR_SEC_MSG:
pParms->ExitResponse = MQXCC_OK;
sprintf(outBuff, "%s : MQXR_SEC_MSG - Security
Message\n", timeBuff);
fprintf(fh, outBuff);
break;
case MQXR_TERM:
pParms->ExitResponse = MQXCC_OK;
sprintf(outBuff, "%s : MQXR_TERM - Channel
Terminating\n", timeBuff);
fprintf(fh, outBuff);
break;
default:
pParms->ExitResponse = MQXCC_SUPPRESS_FUNCTION;
sprintf(outBuff, "%s : ERROR - Unknown Exit Reason\n",
timeBuff);
fprintf(fh, outBuff);
break;
}
}
else
{
pParms->ExitResponse = MQXCC_SUPPRESS_FUNCTION;
sprintf(outBuff, "%s : ERROR - Not invoked by a security
exit.\n", timeBuff);
fprintf(fh, outBuff);
return;
}

sprintf(outBuff, "%s : Now exiting the security exit.\n\n", timeBuff);
fprintf(fh, outBuff);
fclose(fh);

return;
}