home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 8 Other
/
08-Other.zip
/
WLSTART.ZIP
/
WLSTART.C
next >
Wrap
Text File
|
1991-04-22
|
2KB
|
95 lines
/* Start the Workstation Lock */
#define INCL_WIN
#define INCL_DOS
#include <os2.h>
#include <string.h>
#include <stdlib.h>
#define BUFFER 80
#define ID_GO 101
BOOL FindandStartWL(VOID);
int main(void)
{
HAB hab;
HMQ hmq;
hab=WinInitialize(0);
hmq=WinCreateMsgQueue(hab,DEFAULT_QUEUE_SIZE);
if(!FindandStartWL())
{
PSTARTDATA pstd;
PSZ pszPgm;
USHORT usSess,usID;
pstd=(PSTARTDATA)malloc(sizeof(*pstd));
pszPgm=(PSZ)malloc(CCHMAXPATH);
memset(pstd,0x00,sizeof(*pstd));
memset(pszPgm,0x00,CCHMAXPATH);
DosSearchPath(DSP_ENVIRONMENT,
"PATH",
"wl.exe",
pszPgm,
CCHMAXPATH);
pstd->Length=(USHORT)sizeof(STARTDATA);
pstd->FgBg=TRUE;
pstd->PgmName=pszPgm;
pstd->PgmInputs=NULL;
pstd->SessionType=3;
pstd->PgmControl=1;
DosStartSession(pstd,&usSess,&usID);
free(pstd);
free(pszPgm);
DosSleep(5000L);
FindandStartWL();
}
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
return 0;
}
BOOL FindandStartWL
(
VOID
)
{
HWND hwnd;
HWND hwndTitle;
HENUM henum;
CHAR p[BUFFER];
BOOL fFound;
fFound=FALSE;
henum=WinBeginEnumWindows(HWND_DESKTOP);
while(hwnd=WinGetNextWindow(henum))
{
memset(p,0x00,BUFFER);
hwndTitle=WinWindowFromID(hwnd,FID_TITLEBAR);
WinQueryWindowText(hwndTitle,BUFFER,p);
if(!strcmp(p,"W L"))
{
HMQ hmqWL=(HMQ)WinQueryWindowULong(hwnd,QWL_HMQ);
if(hmqWL)
{
WinPostQueueMsg(hmqWL,
WM_COMMAND,
MPFROMSHORT(ID_GO),
MPFROM2SHORT(CMDSRC_OTHER,FALSE));
fFound=TRUE;
}
break;
}
}
WinEndEnumWindows(henum);
return fFound;
}