Rockwell Automation 1789-L10_L30_L60 SoftLogix 5800 System User Manual User Manual
Page 132

132
Rockwell Automation Publication 1789-UM002J-EN-P - December 2012
Chapter 7
Develop External Routines
void PlaySound(char * Snd)
{
HGLOBAL hResLoad;
// handle to loaded resource
HRSRC hRes;
// handle/ptr. to res. info. in hDLL
LPTSTR lpResLock;
// pointer to resource data
BOOL bRes = TRUE;
// By building the sound resourced into the dll and doing a load
// library on the dll we ensure that the resources are written
// down to the controller with the dll. This means that we do not
// have to worry about copying the resources to the controller on our own.
HINSTANCE MyLib = LoadLibrary("Sounds.dll");
if (MyLib == NULL)
{
return;
}
hRes = FindResource(MyLib, Snd, "SOUNDS");
if (hRes == NULL)
{
return;
}
hResLoad = LoadResource(MyLib, hRes);
if (hResLoad == NULL)
{
return;
}
lpResLock = (LPTSTR)LockResource(hResLoad);
if (lpResLock == NULL)
{
return;
}
sndPlaySound(lpResLock, SND_SYNC | SND_MEMORY);
FreeLibrary(MyLib);
}
void RungStateThread(void *p )
{
bool
exitThread = FALSE;
rungStates
oldRungState = rungState;
DWORD status;
HANDLE
hController = p;
HANDLE
hArrayHandles [2];
hArrayHandles[0] = hController;
hArrayHandles[1] = hTerminate; // used to check if thread should terminate.