49 #define STR_BUFFER 256
50 #define MAX_TIME_DATE 128
53 #define MAX_REGISTRY_KEY_SIZE 256
55 #define MSG_TIMEOUT 5000
56 #if (WINVER >= 0x0500)
57 #define MSG_TIMEOUT_OPTS (SMTO_ABORTIFHUNG|SMTO_NORMAL|SMTO_NOTIMEOUTIFNOTHUNG)
59 #define MSG_TIMEOUT_OPTS (SMTO_ABORTIFHUNG|SMTO_NORMAL)
80 for (; length--; location++)
82 *location = toupper(*location);
90 #define INVALID_ROUTINE 40
91 #define VALID_ROUTINE 0
111 #define CHECKARG(argexpctl, argexpcth) \
112 if ((argc < argexpctl) || (argc > argexpcth)) return HandleArgError(retstr, (argc > argexpcth))
116 #define RETC(retcode) { \
117 retstr->strlength = 1;\
118 if (retcode) retstr->strptr[0] = '1'; else retstr->strptr[0] = '0'; \
119 retstr->strptr[1] = '\0'; \
124 retstr->strlength = 1;\
125 retstr->strptr[0] = '1'; \
126 retstr->strptr[1] = '\0'; \
131 #define RETVAL(retvalue) { \
132 itoa(retvalue, retstr->strptr, 10); \
133 retstr->strlength = strlen(retstr->strptr);\
138 #define RET_HANDLE(retvalue) { \
139 pointer2string(retstr, retvalue); \
149 #define GET_HKEY(argum, ghk) { \
151 if (strstr(argum,"MACHINE")) ghk = HKEY_LOCAL_MACHINE; else \
152 if (strstr(argum,"CLASSES")) ghk = HKEY_CLASSES_ROOT; else \
153 if (strstr(argum,"CURRENT_USER")) ghk = HKEY_CURRENT_USER; else \
154 if (strstr(argum,"USERS")) ghk = HKEY_USERS; else \
155 if (strstr(argum,"PERFORMANCE")) ghk = HKEY_PERFORMANCE_DATA; else \
156 if (strstr(argum,"CURRENT_CONFIG")) ghk = HKEY_CURRENT_CONFIG; else \
157 if (strstr(argum,"DYN_DATA")) ghk = HKEY_DYN_DATA; else \
158 string2pointer(argum, (void **)&ghk); \
162 #define GET_HANDLE(argum, ghk) string2pointer(argum, (void **)&(ghk))
165 #define SET_VARIABLE(varname, data, retc) {\
166 shvb.shvnext = NULL; \
167 shvb.shvname.strptr = varname; \
168 shvb.shvname.strlength = strlen(varname); \
169 shvb.shvnamelen = shvb.shvname.strlength; \
170 shvb.shvvalue.strptr = data; \
171 shvb.shvvalue.strlength = strlen(data); \
172 shvb.shvvaluelen = strlen(data); \
173 shvb.shvcode = RXSHV_SYSET; \
175 if (RexxVariablePool(&shvb) == RXSHV_BADN) RETC(retc); \
179 #define GET_TYPE_INDEX(type, index) \
183 case EVENTLOG_ERROR_TYPE: \
186 case EVENTLOG_WARNING_TYPE: \
189 case EVENTLOG_INFORMATION_TYPE: \
192 case EVENTLOG_SUCCESS: \
195 case EVENTLOG_AUDIT_SUCCESS: \
198 case EVENTLOG_AUDIT_FAILURE: \
208 return ((value[0] ==
'0') && (toupper(value[1]) ==
'X'));
228 if ( strlen(
string) == 0 )
236 return (
string[1] ==
'x' ?
237 sscanf(
string,
"0x%p", pointer) == 1 : sscanf(
string,
"0X%p", pointer) == 1);
240 return sscanf(
string,
"%p", pointer) == 1;
246 if ( pointer == NULL )
254 sprintf(result->
strptr,
"0x%p", pointer);
284 if ( pointer == NULL )
286 sprintf(result,
"0");
290 sprintf(result,
"0x%p", pointer);
309 return c->String(buf);
331 if ( hkParent == NULL )
337 hkParent = c->ObjectToStringValue(rxHK);
340 else if ( !
isHex(hkParent) )
342 if ( StrStrI(hkParent,
"MACHINE") ) hk = HKEY_LOCAL_MACHINE;
343 else if ( StrStrI(hkParent,
"CLASSES") ) hk = HKEY_CLASSES_ROOT;
344 else if ( StrStrI(hkParent,
"CURRENT_USER") ) hk = HKEY_CURRENT_USER;
345 else if ( StrStrI(hkParent,
"USERS") ) hk = HKEY_USERS;
346 else if ( StrStrI(hkParent,
"PERFORMANCE") ) hk = HKEY_PERFORMANCE_DATA;
347 else if ( StrStrI(hkParent,
"CURRENT_CONFIG") ) hk = HKEY_CURRENT_CONFIG;
348 else if ( StrStrI(hkParent,
"DYN_DATA") ) hk = HKEY_DYN_DATA;
361 context->SetObjectVariable(
"CURRENT_KEY",
pointer2string(context, HKEY_LOCAL_MACHINE));
367 return context->GetObjectVariable(
"CURRENT_KEY");
372 context->SetObjectVariable(
"CURRENT_KEY", regKeyHandle);
378 return HKEY_LOCAL_MACHINE;
383 return HKEY_CURRENT_USER;
393 return HKEY_CLASSES_ROOT;
398 return HKEY_PERFORMANCE_DATA;
403 return HKEY_CURRENT_CONFIG;
429 if ( strcmp(context->GetMessageName(),
"DELETEKEY") == 0 )
431 return RegDeleteKey(hk, subKeyName);
435 return SHDeleteKey(hk, subKeyName);
472 dwAccess = KEY_ALL_ACCESS;
476 if (StrStrI(access,
"WRITE")) dwAccess |= KEY_WRITE;
477 if (StrStrI(access,
"READ")) dwAccess |= KEY_READ;
478 if (StrStrI(access,
"QUERY")) dwAccess |= KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS;
479 if (StrStrI(access,
"INQUIRE")) dwAccess |= KEY_QUERY_VALUE;
480 if (StrStrI(access,
"ENUMERATE")) dwAccess |= KEY_ENUMERATE_SUB_KEYS;
481 if (StrStrI(access,
"SET")) dwAccess |= KEY_SET_VALUE;
482 if (StrStrI(access,
"DELETE")) dwAccess |= KEY_SET_VALUE;
483 if (StrStrI(access,
"CREATE")) dwAccess |= KEY_CREATE_SUB_KEY;
484 if (StrStrI(access,
"NOTIFY")) dwAccess |= KEY_NOTIFY;
485 if (StrStrI(access,
"EXECUTE")) dwAccess |= KEY_EXECUTE;
486 if (StrStrI(access,
"LINK")) dwAccess |= KEY_CREATE_LINK;
490 HKEY hkResult = NULL;
492 if ( RegOpenKeyEx(hk, subKeyName, 0, dwAccess, &hkResult ) == ERROR_SUCCESS)
495 c->SetObjectVariable(
"CURRENT_KEY", result);
506 if ( strcmp(argv[0].strptr,
"CREATE") == 0 )
511 if (RegCreateKey(hk, argv[2].strptr, &hkResult ) == ERROR_SUCCESS)
520 else if ( strcmp(argv[0].strptr,
"CLOSE") == 0 )
523 if (RegCloseKey(hk) == ERROR_SUCCESS)
532 else if ( strcmp(argv[0].strptr,
"QUERY") == 0 )
535 DWORD retcode, cbClass, cSubKeys, cbMaxSubKeyLen,
536 cbMaxClassLen, cValues, cbMaxValueNameLen, cbMaxValueLen, cbSecurityDescriptor;
537 FILETIME ftLastWriteTime;
544 if ((retcode=RegQueryInfoKey(hk,
554 &cbSecurityDescriptor,
558 if (FileTimeToSystemTime(&ftLastWriteTime, &stTime))
561 sprintf(retstr->
strptr,
"%s, %ld, %ld, %04d/%02d/%02d, %02d:%02d:%02d",
562 Class, cSubKeys, cValues, stTime.wYear, stTime.wMonth, stTime.wDay,
563 stTime.wHour, stTime.wMinute, stTime.wSecond);
567 sprintf(retstr->
strptr,
"%s, %ld, %ld",Class, cSubKeys, cValues);
578 else if ( strcmp(argv[0].strptr,
"LIST") == 0 )
580 DWORD retcode, ndx=0;
588 retcode = RegEnumKey(hk,
592 if (retcode == ERROR_SUCCESS)
594 strcpy(sname, argv[2].strptr);
596 if (sname[argv[2].strlength - 1] !=
'.')
600 sprintf(sname + strlen(sname),
"%d", ndx);
603 else if (retcode != ERROR_NO_MORE_ITEMS)
607 }
while (retcode == ERROR_SUCCESS);
610 else if ( strcmp(argv[0].strptr,
"FLUSH") == 0 )
614 if (RegFlushKey(hk) == ERROR_SUCCESS)
637 if ( strcmp(argv[0].strptr,
"SET") == 0 )
646 if (!strcmp(argv[4].strptr,
"EXPAND")) valType = REG_EXPAND_SZ;
648 if (!strcmp(argv[4].strptr,
"MULTI")) valType = REG_MULTI_SZ;
650 if (!strcmp(argv[4].strptr,
"NUMBER")) valType = REG_DWORD;
652 if (!strcmp(argv[4].strptr,
"BINARY")) valType = REG_BINARY;
654 if (!strcmp(argv[4].strptr,
"LINK")) valType = REG_LINK;
656 if (!strcmp(argv[4].strptr,
"RESOURCELIST")) valType = REG_RESOURCE_LIST;
658 if (!strcmp(argv[4].strptr,
"RESOURCEDESC")) valType = REG_FULL_RESOURCE_DESCRIPTOR;
660 if (!strcmp(argv[4].strptr,
"RESOURCEREQS")) valType = REG_RESOURCE_REQUIREMENTS_LIST;
662 if (!strcmp(argv[4].strptr,
"BIGENDIAN")) valType = REG_DWORD_BIG_ENDIAN;
664 if (!strcmp(argv[4].strptr,
"NONE")) valType = REG_NONE;
668 if ((valType == REG_DWORD) || (valType == REG_DWORD_BIG_ENDIAN))
670 dwNumber = atoi(argv[3].strptr);
672 if (valType == REG_DWORD_BIG_ENDIAN)
677 data = (
const BYTE *) &dwNumber;
678 dataLen =
sizeof(dwNumber);
682 data = (
const BYTE *) argv[3].strptr;
688 case REG_RESOURCE_LIST:
689 case REG_FULL_RESOURCE_DESCRIPTOR:
690 case REG_RESOURCE_REQUIREMENTS_LIST:
691 dataLen = (DWORD)argv[3].strlength;
697 dataLen = (DWORD)argv[3].strlength+1;
702 if (RegSetValueEx(hk, argv[2].strptr, 0, valType, data, dataLen) == ERROR_SUCCESS)
712 else if ( strcmp(argv[0].strptr,
"QUERY") == 0 )
714 DWORD valType, cbData;
715 char * valData, *vType;
717 cbData =
sizeof(valData);
721 if (RegQueryValueEx(hk,
726 &cbData) == ERROR_SUCCESS)
728 valData = (
char *)GlobalAlloc(GPTR, cbData);
735 if (RegQueryValueEx(hk,
740 &cbData) == ERROR_SUCCESS)
744 if ( cbData +
sizeof(
"RESOURCEDESC, ") >
STR_BUFFER )
747 if ( retstr->
strptr == NULL )
757 sprintf(retstr->
strptr,
"%s, ",vType);
758 memcpy(&retstr->
strptr[strlen(retstr->
strptr)], valData, cbData);
762 sprintf(retstr->
strptr,
"%s, %ld",vType, *(DWORD *)valData);
766 sprintf(retstr->
strptr,
"%s, ",vType);
767 memcpy(&retstr->
strptr[strlen(retstr->
strptr)], valData, cbData);
771 sprintf(retstr->
strptr,
"%s, ",vType);
772 memcpy(&retstr->
strptr[strlen(retstr->
strptr)], valData, cbData);
776 sprintf(retstr->
strptr,
"%s, %s",vType, valData);
780 sprintf(retstr->
strptr,
"%s, %s",vType, valData);
782 case REG_RESOURCE_LIST:
783 vType =
"RESOURCELIST";
784 sprintf(retstr->
strptr,
"%s, ",vType);
785 memcpy(&retstr->
strptr[strlen(retstr->
strptr)], valData, cbData);
787 case REG_FULL_RESOURCE_DESCRIPTOR:
788 vType =
"RESOURCEDESC";
789 sprintf(retstr->
strptr,
"%s, ",vType);
790 memcpy(&retstr->
strptr[strlen(retstr->
strptr)], valData, cbData);
792 case REG_RESOURCE_REQUIREMENTS_LIST:
793 vType =
"RESOURCEREQS";
794 sprintf(retstr->
strptr,
"%s, ",vType);
795 memcpy(&retstr->
strptr[strlen(retstr->
strptr)], valData, cbData);
799 sprintf(retstr->
strptr,
"%s, ",vType);
800 memcpy(&retstr->
strptr[strlen(retstr->
strptr)], valData, cbData);
802 case REG_DWORD_BIG_ENDIAN:
806 dwNumber = * (DWORD *)valData;
808 sprintf(retstr->
strptr,
"%s, %ld",vType, dwNumber);
814 sprintf(retstr->
strptr,
"%s,",vType);
816 if ((valType == REG_MULTI_SZ) ||
817 (valType == REG_BINARY) ||
818 (valType == REG_RESOURCE_LIST) ||
819 (valType == REG_FULL_RESOURCE_DESCRIPTOR) ||
820 (valType == REG_RESOURCE_REQUIREMENTS_LIST) ||
821 (valType == REG_NONE))
823 retstr->
strlength = strlen(vType) + 2 + cbData;
842 else if ( strcmp(argv[0].strptr,
"LIST") == 0 )
844 DWORD retcode, ndx=0, valType, cbValue, cbData, initData = 1024;
845 char * valData, *
pTail, Name[256];
850 valData = (
char *)GlobalAlloc(GPTR, initData);
859 strcpy(sname, argv[2].strptr);
870 cbValue =
sizeof(Name);
871 retcode = RegEnumValue(hk,
880 if ((retcode == ERROR_MORE_DATA) && (cbData > initData))
884 valData = (
char *)GlobalAlloc(GPTR, cbData);
887 cbValue =
sizeof(Name);
888 retcode = RegEnumValue(hk,
898 if (retcode == ERROR_SUCCESS)
900 sprintf(
pTail,
"%d.Name", ndx);
903 sprintf(
pTail,
"%d.Type", ndx);
924 case REG_RESOURCE_LIST:
927 case REG_FULL_RESOURCE_DESCRIPTOR:
930 case REG_RESOURCE_REQUIREMENTS_LIST:
936 case REG_DWORD_BIG_ENDIAN:
943 sprintf(
pTail,
"%d.Data", ndx);
944 if ((valType == REG_MULTI_SZ) ||
945 (valType == REG_BINARY) ||
946 (valType == REG_LINK) ||
947 (valType == REG_RESOURCE_LIST) ||
948 (valType == REG_FULL_RESOURCE_DESCRIPTOR) ||
949 (valType == REG_RESOURCE_REQUIREMENTS_LIST) ||
950 (valType == REG_NONE))
954 shvb.
shvname.strlength = strlen(sname);
967 else if ((valType == REG_EXPAND_SZ) || (valType == REG_SZ))
971 else if ((valType == REG_DWORD) || (valType == REG_DWORD_BIG_ENDIAN))
976 dwNumber = *(DWORD *) valData;
977 if (valType == REG_DWORD_BIG_ENDIAN)
981 ltoa(dwNumber, tmp, 10);
989 else if (retcode != ERROR_NO_MORE_ITEMS)
994 }
while (retcode == ERROR_SUCCESS);
998 else if ( strcmp(argv[0].strptr,
"DELETE") == 0 )
1002 if ((rc = RegDeleteValue(hk, argv[2].strptr)) == ERROR_SUCCESS)
1023 TOKEN_PRIVILEGES tkp;
1027 if ( strcmp(argv[0].strptr,
"CONNECT") == 0 )
1032 if (RegConnectRegistry(argv[2].strptr, hk, &hkResult ) == ERROR_SUCCESS)
1041 else if ( strcmp(argv[0].strptr,
"SAVE") == 0 )
1045 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
1050 LookupPrivilegeValue(NULL, SE_BACKUP_NAME,&tkp.Privileges[0].Luid);
1052 tkp.PrivilegeCount = 1;
1053 tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
1057 AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
1058 (PTOKEN_PRIVILEGES) NULL, 0);
1060 if ((rc = GetLastError()) != ERROR_SUCCESS)
1066 if ((retc = RegSaveKey(hk, argv[2].strptr, NULL)) == ERROR_SUCCESS)
1075 else if ( strcmp(argv[0].strptr,
"LOAD") == 0 || strcmp(argv[0].strptr,
"RESTORE") == 0 ||
1076 strcmp(argv[0].strptr,
"REPLACE") == 0 || strcmp(argv[0].strptr,
"UNLOAD") == 0 )
1080 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
1085 LookupPrivilegeValue(NULL, SE_RESTORE_NAME,&tkp.Privileges[0].Luid);
1087 tkp.PrivilegeCount = 1;
1088 tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
1092 AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES) NULL, 0);
1094 if ((rc = GetLastError()) != ERROR_SUCCESS)
1099 if ( strcmp(argv[0].strptr,
"UNLOAD") == 0 )
1102 if ((retc = RegUnLoadKey(hk, argv[2].strptr)) == ERROR_SUCCESS)
1111 else if ( strcmp(argv[0].strptr,
"LOAD") == 0 )
1114 if ((retc = RegLoadKey(hk, argv[2].strptr, argv[3].strptr)) == ERROR_SUCCESS)
1123 else if ( strcmp(argv[0].strptr,
"RESTORE") == 0 )
1128 if (!strcmp(argv[3].strptr,
"VOLATILE")) vola = REG_WHOLE_HIVE_VOLATILE;
1131 if ((retc = RegRestoreKey(hk, argv[2].strptr, vola)) == ERROR_SUCCESS)
1140 else if ( strcmp(argv[0].strptr,
"REPLACE") == 0 )
1144 if (!strcmp(argv[2].strptr,
"%NULL%"))
1153 if ((retc = RegReplaceKey(hk, p, argv[3].strptr, argv[4].strptr)) == ERROR_SUCCESS)
1186 DWORD dwDDEInst = 0;
1195 ui = DdeInitialize(&dwDDEInst,
1197 CBF_FAIL_ALLSVRXACTIONS,
1200 if (ui != DMLERR_NO_ERROR)
return FALSE;
1204 hszProgman = DdeCreateStringHandle(dwDDEInst,
1208 hConv = DdeConnect(dwDDEInst,
1214 DdeFreeStringHandle(dwDDEInst, hszProgman);
1216 if (!hConv)
return FALSE;
1219 hExecData = DdeCreateDataHandle(dwDDEInst,
1228 exRes = DdeClientTransaction((LPBYTE)hExecData,
1238 DdeDisconnect(hConv);
1239 DdeUninitialize(dwDDEInst);
1250 if (lpszPath && lstrlen(lpszPath))
1253 "[CreateGroup(%s,%s)]",
1260 "[CreateGroup(%s)]",
1271 if (lpszGroup && lstrlen(lpszGroup))
1274 "[DeleteGroup(%s)]",
1285 if (lpszGroup && lstrlen(lpszGroup))
1288 "[ShowGroup(%s,%u)]",
1298 const char *lpszCaption,
1299 const char *lpszIconPath,
1301 const char *lpszDir,
1303 const char *lpszHotKey,
1304 const char *lpszModifier,
1310 if (bLast) Pos = -1;
else Pos = 0;
1312 if (lpszIconPath && lstrlen(lpszIconPath))
1315 "[AddItem(%s,%s,%s,%u,%d,%d,%s,%d,%d)]",
1322 MAKEWORD( atoi(lpszHotKey), atoi(lpszModifier)),
1328 "[AddItem(%s,%s,"","",%d,%d,%s,%d,%d)]",
1333 MAKEWORD( atoi(lpszHotKey), atoi(lpszModifier)),
1345 if (lpszItem && lstrlen(lpszItem))
1361 "[ExitProgman(%u)]",
1362 bSaveGroups ? 1 : 0);
1384 #define IDS_REGISTRY_KEY_CURRENT_SHELLFOLDER "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
1385 #define IDS_CURRENT_DESKTOP "Desktop"
1395 szDesktopDir[0] =
'\0';
1397 if ( (rc = RegOpenKeyEx(HKEY_CURRENT_USER,
1401 &hKey)) == ERROR_SUCCESS )
1403 if ( (rc = RegQueryValueEx(hKey,
1408 lpcbData)) == ERROR_SUCCESS )
1410 RegCloseKey ( hKey ) ;
1413 RegCloseKey ( hKey ) ;
1436 #define IDS_REGISTRY_KEY_ALL_NT_SHELLFOLDER "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
1437 #define IDS_ALL_NT_DESKTOP "Common Desktop"
1439 #define IDS_REGISTRY_KEY_ALL_9x_SHELLFOLDER ".DEFAULT\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
1440 #define IDS_ALL_9x_DESKTOP "Desktop"
1450 LPTSTR lpValueName ;
1452 szDesktopDir[0] =
'\0';
1455 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
1461 if ( rc == ERROR_SUCCESS )
1463 if ( (rc = RegQueryValueEx(hKey,
1468 lpcbData)) == ERROR_SUCCESS )
1470 RegCloseKey ( hKey ) ;
1473 RegCloseKey ( hKey ) ;
1512 const char *lpszProgram,
1513 const char *lpszIcon,
1515 const char *lpszWorkDir,
1516 const char *lpszLocation,
1517 const char *lpszArguments,
1520 const char *lpszRun )
1525 int iRun = SW_NORMAL;
1530 hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl);
1532 if (SUCCEEDED(hres))
1537 psl->SetPath(lpszProgram );
1540 psl->SetIconLocation(lpszIcon, iIconIndex);
1543 psl->SetArguments(lpszArguments );
1552 psl->SetHotkey(MAKEWORD( iScKey, iScModifier) );
1555 psl->SetWorkingDirectory(lpszWorkDir );
1558 if ( !stricmp(lpszRun,
"MAXIMIZED") )
1560 iRun = SW_SHOWMAXIMIZED;
1562 else if ( !stricmp(lpszRun,
"MINIMIZED") )
1564 iRun = SW_SHOWMINNOACTIVE;
1567 psl->SetShowCmd(iRun );
1571 hres = psl->QueryInterface(IID_IPersistFile, (
void **)&ppf);
1573 if (SUCCEEDED(hres))
1575 WCHAR wsz[MAX_PATH];
1576 CHAR szShortCutName[MAX_PATH];
1577 CHAR szDesktopDir[MAX_PATH];
1578 DWORD dwSize = MAX_PATH;
1581 if (strlen(lpszLocation)>5)
1585 if (!stricmp(lpszLocation,
"PERSONAL"))
1597 sprintf( szShortCutName,
"%s\\%s.lnk", szDesktopDir, lpszName);
1602 sprintf( szShortCutName,
"%s.lnk", lpszName);
1610 MultiByteToWideChar(CP_ACP, 0, szShortCutName, -1, wsz, MAX_PATH);
1613 hres = ppf->Save(wsz, TRUE);
1614 if (!SUCCEEDED(hres))
1661 CHAR szDesktopDir[MAX_PATH];
1662 CHAR szShortCutName[MAX_PATH];
1663 DWORD dwSize = MAX_PATH;
1667 if (!stricmp(lpszLocation,
"PERSONAL"))
1677 sprintf( szShortCutName,
"%s\\%s.lnk", szDesktopDir, lpszName);
1679 if (!DeleteFile(szShortCutName))
1681 return GetLastError();
1693 if (strcmp( argv[0].strptr,
"ADDGROUP") == 0 )
1697 else if ( strcmp(argv[0].strptr,
"DELGROUP") == 0 )
1701 else if ( strcmp(argv[0].strptr,
"SHOWGROUP") == 0 )
1704 if ( strcmp(argv[2].strptr,
"MAX") == 0 )
1708 else if ( strcmp(argv[2].strptr,
"MIN") == 0 )
1719 else if ( strcmp(argv[0].strptr,
"ADDITEM") == 0 )
1724 RETC(!
AddPMItem(argv[1].strptr, argv[2].strptr, argv[3].strptr, (WORD)atoi(argv[4].strptr), argv[5].strptr,\
1725 (BOOL)atoi(argv[6].strptr), argv[7].strptr, argv[8].strptr, (BOOL)atoi(argv[9].strptr)));
1729 RETC(!
AddPMItem(argv[1].strptr, argv[2].strptr, argv[3].strptr, (WORD)atoi(argv[4].strptr), argv[5].strptr,\
1730 (BOOL)atoi(argv[6].strptr),
"",
"", 0));
1734 else if ( strcmp(argv[0].strptr,
"DELITEM") == 0 )
1738 else if (strcmp(argv[0].strptr,
"LEAVE") == 0 )
1740 if ( strcmp(argv[1].strptr,
"SAVE") == 0 )
1749 else if ( strcmp(argv[0].strptr,
"ADDDESKTOPICON") == 0 )
1752 argv[5].strptr, argv[6].strptr, argv[7].strptr, atoi(argv[8].strptr),
1753 atoi(argv[9].strptr), argv[10].strptr ));
1755 else if ( strcmp(argv[0].strptr,
"DELDESKTOPICON") == 0 )
1774 #define WSEL_DEFAULT_EVENTS_ARRAY_SIZE 512
1775 #define WSEL_DEFAULT_SOURCE "Application"
1776 #define HANDLE_ATTRIBUTE "CURRENTHANDLE"
1777 #define RECORDS_ATTRIBUTE "EVENTS"
1778 #define INITCODE_ATTRIBUTE "INITCODE"
1779 #define MIN_READ_BUFFER_ATTRIBUTE "MINIMUMREADBUFFER"
1780 #define MIN_READ_MIN_ATTRIBUTE "MINIMUMREADMIN"
1781 #define MIN_READ_MAX_ATTRIBUTE "MINIMUMREADMAX"
1784 #define MAX_RECORD_SIZE 256 * 1024
1787 #define MAX_READ_KB_COUNT 256
1788 #define MAX_READ_BUFFER MAX_READ_KB_COUNT * 1024
1789 #define MIN_READ_KB_COUNT 16
1790 #define MIN_READ_BUFFER MIN_READ_KB_COUNT * 1024
1792 #define BAD_RECORD_ARRAY_MSG "The events attribute has been altered so it is no longer an array object"
1793 #define BAD_RECORD_START_MSG "Requested start exceeds number of records"
1794 #define TOO_SMALLBUFFER_MSG "An event log record is too large (%u) for the read buffer (%u.)"
1795 #define START_RECORD_OUT_OF_RANGE_MSG "The start record (%u) is out of range; (%u - %u)"
1796 #define END_RECORD_OUT_OF_RANGE_MSG "start and count produce an end record (%u) out of range; (%u - %u)"
1817 char eventLogKey[] =
"SYSTEM\\CurrentControlSet\\Services\\EventLog\\";
1820 DWORD valueType = REG_EXPAND_SZ;
1827 fileBuffer[0] =
'\0';
1830 pKey = (
char *)LocalAlloc(LPTR, strlen(eventLogKey) + strlen(logName) + 1 + strlen(source) + 1);
1831 sprintf(pKey,
"%s%s\\%s", eventLogKey, logName, source);
1833 if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, pKey, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS )
1836 if ( RegQueryValueEx(hKey, pValueName, NULL, &valueType, NULL, &dataSize) == ERROR_SUCCESS )
1840 valueData = (
char *)LocalAlloc(LPTR, dataSize);
1842 if ( RegQueryValueEx(hKey, pValueName, NULL, &valueType, (LPBYTE)valueData, &dataSize) == ERROR_SUCCESS )
1846 ExpandEnvironmentStrings(valueData, fileBuffer, MAX_PATH);
1848 LocalFree(valueData);
1874 char *pBuffer = NULL;
1879 if ( *files !=
'\0' )
1881 DWORD flags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ARGUMENT_ARRAY;
1882 DWORD langID = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
1884 pBuffer = (
char *)LocalAlloc(LPTR, strlen(files) + 1);
1885 if ( pBuffer != NULL )
1887 strcpy(pBuffer, files);
1890 while ( pTemp != NULL && count == 0 )
1892 pNext = strchr(pTemp,
';');
1893 if ( pNext != NULL )
1899 h = LoadLibrary(pTemp);
1902 count = FormatMessage(flags, h, msgID, langID, (LPTSTR)lpMsgBuf, 0, ppInserts);
1923 char *pchString = NULL;
1926 HINSTANCE hInstance = NULL;
1927 LPVOID lpMsgBuf = NULL;
1928 char *pSubstitutions[100];
1929 char chMessageFile[MAX_PATH];
1933 memset(pSubstitutions, 0,
sizeof(pSubstitutions));
1936 pchString = (
char*)pEvLogRecord + pEvLogRecord->StringOffset;
1945 for (
int i = 0; i < pEvLogRecord->NumStrings; i++ )
1952 if ( (pchPercent = strstr(pchString,
"%%")) )
1957 (
char *)pEvLogRecord +
sizeof(EVENTLOGRECORD), chMessageFile);
1959 DWORD flags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS;
1960 DWORD langID = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
1961 int id = atoi(pchPercent + 2);
1965 if ( (hInstance = LoadLibrary(chMessageFile)) != NULL )
1967 if ( FormatMessage(flags, hInstance,
id, langID, (LPTSTR)&pSubstitutions[i], 0, 0) == 0 )
1971 pSubstitutions[i] = (
char *)LocalAlloc(LPTR, 1);
1973 FreeLibrary(hInstance);
1980 pSubstitutions[i] = (
char *)LocalAlloc(LPTR, 1);
1984 iStringLen += (int)strlen(pSubstitutions[i]) + 1;
1990 iStringLen += (int)strlen(pchString) + 1;
1991 pSubstitutions[i] = (
char *)LocalAlloc(LMEM_FIXED, strlen(pchString) + 1);
1992 strcpy(pSubstitutions[i], pchString);
1995 pchString += strlen(pchString) + 1;
2000 (
char *)pEvLogRecord +
sizeof(EVENTLOGRECORD), chMessageFile);
2008 *ppMessage = (
char *)LocalAlloc(LPTR, strlen((
char*)lpMsgBuf) + 1);
2009 strcpy(*ppMessage, (
const char *)lpMsgBuf);
2013 LocalFree(lpMsgBuf);
2019 if ( pEvLogRecord->NumStrings )
2021 *ppMessage = (
char *)LocalAlloc(LPTR, iStringLen + 1);
2023 for (
int i = 0; i < pEvLogRecord->NumStrings; i++ )
2025 strcat(*ppMessage, pSubstitutions[i]);
2026 strcat(*ppMessage,
" ");
2033 *ppMessage = (
char *)LocalAlloc(LPTR, 1);
2038 for (
int i = 0; i < pEvLogRecord->NumStrings; i++ )
2040 LocalFree(pSubstitutions[i]);
2058 char *pUserID = NULL;
2060 char defUserID[] =
"N/A";
2063 SID_NAME_USE strDummy;
2064 char *pDomain = NULL;
2065 DWORD sizeDomain = 0;
2067 if ( pEvLogRecord->UserSidLength == 0 )
2070 pUserID = (
char *)LocalAlloc(LPTR, strlen(defUserID) + 1);
2071 strcpy(pUserID, defUserID);
2076 psid = (SID *)((
char*)pEvLogRecord + pEvLogRecord->UserSidOffset);
2079 LookupAccountSid(NULL, psid, pUserID, &sizeID, pDomain, &sizeDomain, &strDummy);
2081 pUserID = (
char *)LocalAlloc(LPTR, std::max(sizeID, (DWORD)strlen(defUserID) + 1));
2082 pDomain = (
char *)LocalAlloc(LPTR, sizeDomain);
2084 if ( LookupAccountSid(NULL, psid, pUserID, &sizeID, pDomain, &sizeDomain, &strDummy) == 0 )
2087 strcpy(pUserID, defUserID);
2119 if ( pEvLogRecord->DataLength != 0 )
2121 *ppBinData = (
char *)LocalAlloc(LPTR, (pEvLogRecord->DataLength + 1) * 2);
2124 pRecData = (
char*)pEvLogRecord + pEvLogRecord->DataOffset;
2126 for ( DWORD i = 0; i < pEvLogRecord->DataLength; i++ )
2128 _snprintf(pTemp,
sizeof(pTemp),
"%02x", *pRecData);
2129 memcpy(p, pTemp, 2);
2136 *ppBinData = (
char *)LocalAlloc(LPTR, 1);
2139 return (pEvLogRecord->DataLength * 2);
2155 c->ArrayOfFour(c->String(
"positional"), c->WholeNumberToObject(pos), c->String(list), actual));
2211 if ( ! c->ObjectToUnsignedInt32(ptr, &val) )
2236 if ( context->IsArray(ptr) )
2249 context->SendMessage0(records,
"EMPTY");
2289 bool didOpen =
false;
2294 if ( hEventLog == NULL )
2296 if ( server != NULL && strlen(server) == 0 )
2300 if ( source == NULL || strlen(source) == 0 )
2305 hEventLog = OpenEventLog(server, source);
2306 if ( hEventLog == NULL )
2308 *pRC = GetLastError();
2316 *pHandle = hEventLog;
2333 if ( hEventLog != NULL )
2335 rc = (CloseEventLog(hEventLog) == 0) ? GetLastError() : 0;
2367 bool didOpen =
getOpenEventLog(context, server, source, &hEventLog, &number);
2369 if ( hEventLog == NULL )
2378 success = GetNumberOfEventLogRecords(hEventLog, &count);
2381 retNum = -(
int32_t)GetLastError();
2392 success = GetOldestEventLogRecord(hEventLog, &oldest);
2395 retNum = -(
int32_t)GetLastError();
2399 switch ( numberType )
2410 retNum = oldest + count - 1;
2422 CloseEventLog(hEventLog);
2455 *flags = EVENTLOG_FORWARDS_READ;
2458 if ( stricmp(
"FORWARDS", direction) == 0 )
2462 else if ( stricmp(
"BACKWARDS", direction) == 0 )
2464 *flags = EVENTLOG_BACKWARDS_READ;
2486 *flags |= EVENTLOG_SEEK_READ;
2490 *flags |= EVENTLOG_SEQUENTIAL_READ;
2494 if ( GetNumberOfEventLogRecords(hLog, &totalRecords) == 0 )
2496 *rc = GetLastError();
2503 if ( *flags & EVENTLOG_SEEK_READ )
2506 if ( GetOldestEventLogRecord(hLog, &oldestRecord) == 0 )
2508 *rc = GetLastError();
2512 DWORD youngestRecord = oldestRecord + totalRecords - 1;
2515 if ( youngestRecord < start || start < oldestRecord )
2520 context->NewStringFromAsciiz(tmp));
2525 if ( *flags & EVENTLOG_FORWARDS_READ )
2527 endRecord = start + *count - 1;
2531 endRecord = start - *count + 1;
2534 if ( youngestRecord < endRecord || endRecord < oldestRecord )
2539 context->NewStringFromAsciiz(tmp));
2547 *count = totalRecords;
2554 return (
type == EVENTLOG_SUCCESS ||
2555 type == EVENTLOG_AUDIT_FAILURE ||
2556 type == EVENTLOG_AUDIT_SUCCESS ||
2557 type == EVENTLOG_ERROR_TYPE ||
2558 type == EVENTLOG_INFORMATION_TYPE ||
2559 type == EVENTLOG_WARNING_TYPE);
2606 if ( server != NULL && strlen(server) == 0 )
2610 if ( source == NULL || strlen(source) == 0 )
2615 HANDLE hEventLog = OpenEventLog(server, source);
2616 if ( hEventLog == NULL )
2618 return GetLastError();
2700 BOOL isFull = FALSE;
2707 EVENTLOG_FULL_INFORMATION efi;
2709 if ( GetEventLogInformation(hLog, EVENTLOG_FULL_INFO, (
void *)&efi,
sizeof(efi), &needed) != 0 )
2711 isFull = efi.dwFull ? TRUE : FALSE;
2717 CloseEventLog(hLog);
2750 OPTIONAL_CSTRING, backupFile)
2755 bool didOpen =
getOpenEventLog(context, server, source, &hEventLog, &rc);
2757 if ( hEventLog == NULL )
2762 if ( backupFile != NULL && strlen(backupFile) == 0 )
2772 char *pDupeName = NULL;
2773 if ( backupFile != NULL )
2775 pDupeName = (
char *)LocalAlloc(LPTR, MAX_PATH);
2781 strcpy(pDupeName, backupFile);
2782 PathAddExtension(pDupeName,
".evt");
2785 if ( ClearEventLog(hEventLog, pDupeName) == 0 )
2787 rc = GetLastError();
2791 LocalFree(pDupeName);
2795 CloseEventLog(hEventLog);
2827 OPTIONAL_uint16_t, t, OPTIONAL_uint16_t, category, OPTIONAL_uint32_t,
id,
2828 OPTIONAL_RexxStringObject, rawData,
ARGLIST, args)
2835 WORD countStrings = 0;
2836 const char **strings = NULL;
2840 if ( server != NULL && strlen(server) == 0 )
2844 if ( source == NULL || strlen(source) == 0 )
2856 dataSize = (DWORD)context->StringLength(rawData);
2857 data = malloc(dataSize);
2860 memcpy(data, (
void *)context->StringData(rawData), dataSize);
2868 size_t argc = context->ArraySize(args);
2871 strings = (
const char **)malloc((argc - 6) *
sizeof(
const char **));
2872 if ( strings != NULL )
2874 const char **p = strings;
2875 for (
size_t i = 7; i <= argc; i++, countStrings++)
2884 *p++ = context->ObjectToStringValue(obj);
2890 HANDLE hSource = RegisterEventSource(server, source);
2891 if ( hSource != NULL )
2893 if ( ReportEvent(hSource,
type, category,
id, NULL, countStrings, dataSize, strings, data) == 0 )
2895 rc = GetLastError();
2898 DeregisterEventSource(hSource);
2902 rc = GetLastError();
2909 if ( strings != NULL )
2930 context->RaiseException(
2932 context->ArrayOfFive(context->String(
"positional"),
2933 context->Int32ToObject(1),
2936 context->Int32ToObject(countKB)));
2988 OPTIONAL_CSTRING, source, OPTIONAL_uint32_t, start, OPTIONAL_uint32_t, count)
3002 if ( source == NULL )
3012 CloseEventLog(hLog);
3018 char evType[6][12]={
"Error",
"Warning",
"Information",
"Success",
"Failure",
"Unknown"};
3021 PEVENTLOGRECORD pEvLogRecord;
3022 PVOID pBuffer = NULL;
3023 DWORD bufferPos = 0;
3026 char * pchEventSource = NULL;
3027 char * pchComputerName = NULL;
3028 char * pchMessage = NULL;
3029 char * pBinaryData = NULL;
3032 struct tm * DateTime;
3033 char * pchStrBuf = NULL;
3034 char * pchUser = NULL;
3035 DWORD countRecords = 0;
3041 DWORD bufSize = count * 1024;
3044 bufSize = bufSize < minSize ? minSize : bufSize;
3046 pBuffer = LocalAlloc(LPTR, bufSize);
3047 if ( pBuffer == NULL )
3060 BOOL success = TRUE;
3064 while ( (countRecords < count) && (success = ReadEventLog(hLog, flags, start, pBuffer, bufSize, &bytesRead, &needed)) )
3066 pEvLogRecord = (PEVENTLOGRECORD)pBuffer;
3069 while ( (bufferPos < bytesRead) && (countRecords < count) )
3071 if (flags & EVENTLOG_FORWARDS_READ)
3073 start = pEvLogRecord->RecordNumber + 1;
3077 start = pEvLogRecord->RecordNumber - 1;
3095 DateTime = localtime((
const time_t *)&pEvLogRecord->TimeWritten);
3097 DateTime = _localtime32((
const __time32_t *)&pEvLogRecord->TimeWritten);
3103 pchEventSource = (
char*)pEvLogRecord +
sizeof(EVENTLOGRECORD);
3104 pchComputerName = pchEventSource + strlen(pchEventSource)+1;
3116 size_t len = strlen(evType[evTypeIndex]) + 1 +
3119 strlen(pchEventSource) + 3 +
3121 strlen(pchUser) + 1 +
3122 strlen(pchComputerName) + 1 +
3123 strlen(pchMessage) + 3 +
3126 pchStrBuf = (
char *)LocalAlloc(LPTR, len);
3133 "%s %s %s '%s' %u %s %s '%s' '",
3134 evType[evTypeIndex],
3138 LOWORD(pEvLogRecord->EventID),
3145 len = strlen(pchStrBuf);
3146 memcpy((pchStrBuf + len), pBinaryData, cch);
3149 *(pchStrBuf + len++) =
'\'';
3150 *(pchStrBuf + len) =
'\0';
3152 LocalFree(pchMessage);
3154 LocalFree(pBinaryData);
3159 context->ArrayPut(rxRecords, context->NewString(pchStrBuf, len), countRecords);
3161 LocalFree(pchStrBuf);
3164 bufferPos += pEvLogRecord->Length;
3165 pEvLogRecord = (PEVENTLOGRECORD)(((
char*)pEvLogRecord) + pEvLogRecord->Length);
3167 memset(pBuffer, 0, bufSize);
3172 rc = GetLastError();
3174 if ( rc == ERROR_INSUFFICIENT_BUFFER )
3182 else if ( rc == ERROR_HANDLE_EOF )
3194 CloseEventLog(hLog);
3214 const char key[] =
"SYSTEM\\CurrentControlSet\\Services\\EventLog\\";
3217 if ( ! context->IsOfType(obj,
"ARRAY") )
3223 context->SendMessage0(logNames,
"EMPTY");
3228 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_ENUMERATE_SUB_KEYS, &hKey);
3229 if ( rc == ERROR_SUCCESS )
3235 while ( (rc = RegEnumKeyEx(hKey, index, name, &cName, NULL, NULL, NULL, NULL)) == ERROR_SUCCESS )
3237 context->ArrayAppendString(logNames, name, strlen(name));
3242 if ( rc == ERROR_NO_MORE_ITEMS )
3250 context->SendMessage0(logNames,
"EMPTY");
3301 if (!strcmp(argv[0].strptr,
"DESK"))
3305 else if (!strcmp(argv[0].strptr,
"FIND"))
3308 hW = FindWindow(NULL, argv[1].strptr);
3311 else if (!strcmp(argv[0].strptr,
"FINDCHILD"))
3316 hW = FindWindowEx(thW, NULL, NULL, argv[2].strptr);
3319 else if (!strcmp(argv[0].strptr,
"SETFG"))
3322 hW = GetForegroundWindow();
3327 SetForegroundWindow(thW);
3331 else if (!strcmp(argv[0].strptr,
"GETFG"))
3335 else if (!strcmp(argv[0].strptr,
"TITLE"))
3343 RETC(!SetWindowText(hW, argv[2].strptr));
3369 tmp_ptr = (
char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT, retstr->
strlength + 1);
3374 retstr->
strptr = tmp_ptr;
3377 lResult = SendMessageTimeout(hW, WM_GETTEXT, retstr->
strlength + 1, (LPARAM)retstr->
strptr,
3406 curSel = (int) dwResult;
3408 if (curSel != LB_ERR)
3426 tmp_ptr = (
char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT, retstr->
strlength + 1);
3431 retstr->
strptr = tmp_ptr;
3454 RETC(!SetConsoleTitle(argv[2].strptr))
3463 else if (!strcmp(argv[0].strptr,
"CLASS"))
3473 else if (!strcmp(argv[0].strptr,
"SHOW"))
3480 if (!strcmp(argv[2].strptr,
"HIDE")) sw = SW_HIDE;
3482 if (!strcmp(argv[2].strptr,
"MAX")) sw = SW_SHOWMAXIMIZED;
3484 if (!strcmp(argv[2].strptr,
"MIN")) sw = SW_MINIMIZE;
3486 if (!strcmp(argv[2].strptr,
"RESTORE")) sw = SW_RESTORE;
3488 RETC(ShowWindow(hW, sw))
3491 else if (!strcmp(argv[0].strptr,
"HNDL"))
3499 if (!strcmp(argv[2].strptr,
"NEXT")) gw = GW_HWNDNEXT;
3500 else if (!strcmp(argv[2].strptr,
"PREV")) gw = GW_HWNDPREV;
3501 else if (!strcmp(argv[2].strptr,
"FIRSTCHILD")) gw = GW_CHILD;
3502 else if (!strcmp(argv[2].strptr,
"FIRST")) gw = GW_HWNDFIRST;
3503 else if (!strcmp(argv[2].strptr,
"LAST")) gw = GW_HWNDLAST;
3504 else if (!strcmp(argv[2].strptr,
"OWNER")) gw = GW_OWNER;
3513 else if (!strcmp(argv[0].strptr,
"ID"))
3520 else if (!strcmp(argv[0].strptr,
"ATPOS"))
3524 pt.x = atol(argv[1].strptr);
3525 pt.y = atol(argv[2].strptr);
3537 RET_HANDLE(ChildWindowFromPointEx(hW, pt, CWP_ALL));
3544 else if (!strcmp(argv[0].strptr,
"RECT"))
3550 if (hW && GetWindowRect(hW, &r))
3552 sprintf(retstr->
strptr,
"%d,%d,%d,%d",r.left, r.top, r.right, r.bottom);
3557 else if (!strcmp(argv[0].strptr,
"GETSTATE"))
3564 retstr->
strptr[0] =
'\0';
3565 if (!IsWindow(hW)) strcpy(retstr->
strptr,
"Illegal Handle");
3568 if (IsWindowEnabled(hW)) strcat(retstr->
strptr,
"Enabled ");
3569 else strcat(retstr->
strptr,
"Disabled ");
3570 if (IsWindowVisible(hW)) strcat(retstr->
strptr,
"Visible ");
3571 else strcat(retstr->
strptr,
"Invisible ");
3572 if (IsZoomed(hW)) strcat(retstr->
strptr,
"Zoomed ");
3573 else if (IsIconic(hW)) strcat(retstr->
strptr,
"Minimized ");
3574 if (GetForegroundWindow() == hW) strcat(retstr->
strptr,
"Foreground ");
3580 else if (!strcmp(argv[0].strptr,
"GETSTYLE"))
3588 wi.cbSize =
sizeof(WINDOWINFO);
3589 if ( GetWindowInfo(hW, &wi) )
3603 else if (!strcmp(argv[0].strptr,
"ENABLE"))
3609 RETC(EnableWindow(hW, atoi(argv[2].strptr)));
3612 else if (!strcmp(argv[0].strptr,
"MOVE"))
3619 if (!GetWindowRect(hW, &r))
3623 RETC(!MoveWindow(hW, atol(argv[2].strptr), atol(argv[3].strptr), r.right - r.left, r.bottom-r.top, TRUE))
3626 else if (!strcmp(argv[0].strptr,
"SIZE"))
3633 if (!GetWindowRect(hW, &r))
3637 RETC(!SetWindowPos(hW, NULL, r.left, r.top, atol(argv[2].strptr), atol(argv[3].strptr), SWP_NOMOVE | SWP_NOZORDER))
3651 if ( strcmp(argv[0].strptr,
"KEY") == 0 )
3660 k = (WPARAM)atoi(argv[2].strptr);
3663 l = strtol(argv[4].strptr,
'\0',16);
3684 if (argv[3].strptr[0] ==
'D')
3686 HwndFgWin = GetForegroundWindow();
3687 if ( hW == HwndFgWin)
3691 keybd_event((BYTE)k,0,KEYEVENTF_EXTENDEDKEY,0);
3695 keybd_event((BYTE)k,0,0,0);
3699 retstr->
strptr[1] =
'\0';
3703 itoa(PostMessage(hW,WM_KEYDOWN, k,l), retstr->
strptr, 10);
3706 else if (argv[3].strptr[0] ==
'U')
3708 HwndFgWin = GetForegroundWindow();
3709 if ( hW == HwndFgWin )
3713 keybd_event((BYTE)k,0,KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY,0);
3717 keybd_event((BYTE)k,0,KEYEVENTF_KEYUP,0);
3721 retstr->
strptr[1] =
'\0';
3725 itoa(PostMessage(hW,WM_KEYUP, k, l | 0xC0000000), retstr->
strptr, 10);
3727 retstr->
strptr[1] =
'\0';
3734 itoa(PostMessage(hW,WM_SYSKEYDOWN, k,l), retstr->
strptr, 10);
3735 itoa(PostMessage(hW,WM_SYSKEYUP, k,l), retstr->
strptr, 10);
3739 itoa(SendNotifyMessage(hW,WM_CHAR, k,l), retstr->
strptr, 10);
3745 else if ( strcmp(argv[0].strptr,
"MSG") == 0 )
3761 if ( argc > 5 && argv[5].strptr[0] ==
'E' )
3763 lp = (LPARAM)
"Environment";
3765 if ( SendNotifyMessage(hW, msg, wp, lp) )
3774 else if ( strcmp(argv[0].strptr,
"TO") == 0 )
3793 if ( argc > 6 && argv[6].strptr[0] ==
'E' )
3795 lp = (LPARAM)
"Environment";
3798 lResult = SendMessageTimeout(hW, msg, wp, lp,
MSG_TIMEOUT_OPTS, timeOut, &dwResult);
3804 DWORD err = GetLastError();
3816 else if ( strcmp(argv[0].strptr,
"MAP") == 0 )
3819 RETVAL(MapVirtualKey((UINT)atoi(argv[1].strptr), 2));
3831 if (!strcmp(argv[0].strptr,
"GET"))
3839 else if (!strcmp(argv[0].strptr,
"SYS"))
3847 else if (!strcmp(argv[0].strptr,
"SUB"))
3853 RET_HANDLE(GetSubMenu(hMenu, atoi(argv[2].strptr)));
3855 else if (!strcmp(argv[0].strptr,
"ID"))
3861 RETVAL(GetMenuItemID(hMenu, atoi(argv[2].strptr)));
3863 else if (!strcmp(argv[0].strptr,
"CNT"))
3869 RETVAL(GetMenuItemCount(hMenu));
3871 else if (!strcmp(argv[0].strptr,
"TEXT"))
3882 if (argv[3].strptr[0] ==
'C')
3884 flag = MF_BYCOMMAND;
3888 flag = MF_BYPOSITION;
3891 retstr->
strlength = GetMenuString(hM, atol(argv[2].strptr), retstr->
strptr, 255, flag);
3894 else if (!strcmp(argv[0].strptr,
"STATE"))
3909 UINT pos = atoi(argv[3].strptr);
3911 flags = GetMenuState(hMenu, pos, MF_BYPOSITION);
3913 if ( flags == 0xffffffff )
3919 if ( argv[2].strptr[0] ==
'M' )
3921 RETVAL((flags & MF_POPUP) ? 1 : 0);
3923 else if ( argv[2].strptr[0] ==
'C' )
3925 RETVAL((flags & MF_CHECKED) ? 1 : 0);
3929 RETVAL(((flags & MF_POPUP) == 0 && (flags & MF_SEPARATOR) != 0) ? 1 : 0);
3944 if (!strcmp(argv[0].strptr,
"COPY"))
3950 hmem = (
char *)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, argv[1].strlength + 1);
3951 membase = (
char *) GlobalLock(hmem);
3955 memcpy(membase, argv[1].strptr, argv[1].strlength + 1);
3956 if (OpenClipboard(NULL) && EmptyClipboard())
3958 ret = SetClipboardData(CF_TEXT, hmem) != NULL;
3960 GlobalUnlock(membase);
3965 else if (!strcmp(argv[0].strptr,
"PASTE"))
3969 if (IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL))
3971 hmem = GetClipboardData(CF_TEXT);
3972 membase = (
char *) GlobalLock(hmem);
3975 size_t s = GlobalSize(hmem);
3978 retstr->
strptr = (
char *)GlobalAlloc(GMEM_FIXED, s);
3979 if (retstr->
strptr == NULL)
3985 s = strlen(membase);
3986 memcpy(retstr->
strptr, membase, s+1);
3988 GlobalUnlock(membase);
4000 else if (!strcmp(argv[0].strptr,
"EMPTY"))
4002 if (IsClipboardFormatAvailable(CF_TEXT))
4005 if (!OpenClipboard(NULL))
4009 ret = !EmptyClipboard();
4015 else if (!strcmp(argv[0].strptr,
"AVAIL"))
4017 RETC(IsClipboardFormatAvailable(CF_TEXT))
4034 for (i = 0; i < iSize; i++)
4036 bTemp[i] = pbInt[iSize - i - 1];
4039 memcpy(pbInt, bTemp, iSize);
4078 REXX_METHOD(getPerformance_Data, getPerformance_Data),
4079 REXX_METHOD(getCurrent_Config, getCurrent_Config),
4080 REXX_METHOD(WSRegistry_delete, WSRegistry_delete),
4085 REXX_METHOD(WSEventLog_uninit, WSEventLog_uninit),
4089 REXX_METHOD(WSEventLog_readRecords, WSEventLog_readRecords),
4090 REXX_METHOD(WSEventLog_minimumReadSet, WSEventLog_minimumReadSet),
4091 REXX_METHOD(WSEventLog_minimumReadGet, WSEventLog_minimumReadGet),
4092 REXX_METHOD(WSEventLog_getNumber, WSEventLog_getNumber),
4093 REXX_METHOD(WSEventLog_getFirst, WSEventLog_getFirst),
4094 REXX_METHOD(WSEventLog_getLast, WSEventLog_getLast),
4095 REXX_METHOD(WSEventLog_isFull, WSEventLog_isFull),
4096 REXX_METHOD(WSEventLog_getLogNames, WSEventLog_getLogNames),
RexxReturnCode RexxEntry RexxVariablePool(PSHVBLOCK pshvblock)
#define argumentExists(i)
#define REXX_INTERPRETER_4_0_0
#define REXX_METHOD(n, e)
#define REXX_CLASSIC_ROUTINE(n, e)
#define argumentOmitted(i)
#define REXX_LAST_ROUTINE()
#define REXX_LAST_METHOD()
#define STANDARD_PACKAGE_HEADER
#define Rexx_Error_Incorrect_method_noclass
#define Rexx_Error_Incorrect_method_noarg
#define Rexx_Error_Invalid_argument_range
#define Rexx_Error_Execution_user_defined
#define Rexx_Error_Incorrect_method_list
#define Rexx_Error_System_service_user_defined
#define Rexx_Error_Incorrect_method_user_defined
struct _RexxStringObject * RexxStringObject
struct _RexxArrayObject * RexxArrayObject
struct _RexxObjectPtr * RexxObjectPtr
void *REXXENTRY RexxAllocateMemory(size_t)
struct _RexxPointerObject * RexxPointerObject
#define MIN_READ_KB_COUNT
void systemServiceException(RexxMethodContext *context, char *msg)
HKEY getParentKeyHandle(RexxMethodContext *c, CSTRING hkParent)
#define END_RECORD_OUT_OF_RANGE_MSG
#define WSEL_DEFAULT_EVENTS_ARRAY_SIZE
LONG HandleArgError(PRXSTRING r, BOOL ToMuch)
bool checkReadRecordsArgs(RexxMethodContext *context, HANDLE hLog, CSTRING direction, uint32_t start, uint32_t *count, DWORD *flags, DWORD *rc)
RexxMethod3(RexxObjectPtr, WSRegistry_open, OPTIONAL_CSTRING, hkParent, OPTIONAL_CSTRING, subKeyName, OPTIONAL_CSTRING, access)
bool getOpenEventLog(RexxMethodContext *context, const char *server, const char *source, HANDLE *pHandle, DWORD *pRC)
RexxMethod4(int, WSEventLog_test, RexxStringObject, data, OPTIONAL_CSTRING, server, OPTIONAL_CSTRING, source, ARGLIST, args)
#define SET_VARIABLE(varname, data, retc)
size_t RexxEntry InstWinSysFuncs(const char *funcname, size_t argc, CONSTRXSTRING *argv, const char *qname, RXSTRING *retstr)
#define BAD_RECORD_ARRAY_MSG
#define IDS_ALL_NT_DESKTOP
#define START_RECORD_OUT_OF_RANGE_MSG
BOOL AddPMItem(const char *lpszCmdLine, const char *lpszCaption, const char *lpszIconPath, WORD wIconIndex, const char *lpszDir, BOOL bLast, const char *lpszHotKey, const char *lpszModifier, BOOL bMin)
BOOL findAndFormatDescription(char *files, DWORD msgID, char **ppInserts, LPVOID *lpMsgBuf)
size_t RexxEntry WSRegistryFile(const char *funcname, size_t argc, CONSTRXSTRING argv[], const char *qname, PRXSTRING retstr)
void lookupMessageFile(char *pValueName, char *logName, char *source, char *fileBuffer)
#define IDS_REGISTRY_KEY_CURRENT_SHELLFOLDER
void setCurrentHandle(RexxMethodContext *context, HANDLE h)
RexxMethod7(uint32_t, WSEventLog_write, OPTIONAL_CSTRING, server, OPTIONAL_CSTRING, source, OPTIONAL_uint16_t, t, OPTIONAL_uint16_t, category, OPTIONAL_uint32_t, id, OPTIONAL_RexxStringObject, rawData, ARGLIST, args)
#define GET_HANDLE(argum, ghk)
RexxMethod0(RexxObjectPtr, WSRegistry_init)
#define GET_HKEY(argum, ghk)
RexxArrayObject getRecordArray(RexxMethodContext *context)
size_t RexxEntry WSProgManager(const char *funcname, size_t argc, CONSTRXSTRING argv[], const char *qname, PRXSTRING retstr)
#define INITCODE_ATTRIBUTE
OOREXX_GET_PACKAGE(rxwinsys)
BOOL AddPMGroup(const char *lpszGroup, const char *lpszPath)
size_t RexxEntry WSCtrlSend(const char *funcname, size_t argc, CONSTRXSTRING argv[], const char *qname, PRXSTRING retstr)
size_t RexxEntry WSRegistryKey(const char *funcname, size_t argc, CONSTRXSTRING argv[], const char *qname, PRXSTRING retstr)
BOOL LeavePM(BOOL bSaveGroups)
void pointer2string(PRXSTRING result, void *pointer)
char * getEventUserName(PEVENTLOGRECORD pEvLogRecord)
#define MAX_REGISTRY_KEY_SIZE
#define MAX_READ_KB_COUNT
DWORD getMinimumReadBufferSize(RexxMethodContext *c)
size_t RexxEntry WSCtrlMenu(const char *funcname, size_t argc, CONSTRXSTRING argv[], const char *qname, PRXSTRING retstr)
RexxMethod5(uint32_t, WSEventLog_readRecords, OPTIONAL_CSTRING, direction, OPTIONAL_CSTRING, server, OPTIONAL_CSTRING, source, OPTIONAL_uint32_t, start, OPTIONAL_uint32_t, count)
bool isGoodEventType(uint16_t type)
#define RET_HANDLE(retvalue)
size_t RexxEntry WSRegistryValue(const char *funcname, size_t argc, CONSTRXSTRING argv[], const char *qname, PRXSTRING retstr)
RexxPackageEntry rxwinsys_package_entry
size_t getEventBinaryData(PEVENTLOGRECORD pEvLogRecord, char **ppBinData)
#define TOO_SMALLBUFFER_MSG
HDDEDATA CALLBACK DDECallback(UINT wType, UINT wFmt, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hDDEData, DWORD dwData1, DWORD dwData2)
BOOL GetAllUserDesktopLocation(LPBYTE szDesktopDir, LPDWORD lpcbData)
bool isHex(CSTRING value)
BOOL DeletePMItem(const char *lpszItem)
BOOL AddPMDesktopIcon(const char *lpszName, const char *lpszProgram, const char *lpszIcon, int iIconIndex, const char *lpszWorkDir, const char *lpszLocation, const char *lpszArguments, int iScKey, int iScModifier, const char *lpszRun)
INT DelPMDesktopIcon(const char *lpszName, const char *lpszLocation)
BOOL ShowPMGroup(const char *lpszGroup, WORD wCmd)
RexxMethod1(RexxObjectPtr, setCurrent_Key, RexxStringObject, regKeyHandle)
RexxMethod2(uint32_t, WSRegistry_delete, OPTIONAL_CSTRING, hkParent, CSTRING, subKeyName)
size_t dwordPtrToRexx(DWORD_PTR val, PRXSTRING r)
#define CHECKARG(argexpctl, argexpcth)
int32_t getEventLogNumber(RexxMethodContext *context, LogNumberOp numberType, CSTRING server, CSTRING source)
unsigned int wrongClassException(RexxMethodContext *c, int pos, const char *n)
void getEventDescription(PEVENTLOGRECORD pEvLogRecord, const char *pchSource, char **ppMessage)
size_t RexxEntry WSClipboard(const char *funcname, size_t argc, CONSTRXSTRING argv[], const char *qname, PRXSTRING retstr)
void outOfMemoryException(RexxMethodContext *c)
#define MIN_READ_MAX_ATTRIBUTE
void wrongArgValueException(RexxMethodContext *c, int pos, const char *list, RexxObjectPtr actual)
BOOL DeletePMGroup(const char *lpszGroup)
HANDLE getCurrentHandle(RexxMethodContext *context)
#define WSEL_DEFAULT_SOURCE
BOOL GetCurrentUserDesktopLocation(LPBYTE szDesktopDir, LPDWORD lpcbData)
size_t RexxEntry WSCtrlWindow(const char *funcname, size_t argc, CONSTRXSTRING argv[], const char *qname, PRXSTRING retstr)
#define IDS_REGISTRY_KEY_ALL_NT_SHELLFOLDER
DWORD closeEventLog(RexxMethodContext *context)
#define RECORDS_ATTRIBUTE
#define MIN_READ_MIN_ATTRIBUTE
#define IDS_CURRENT_DESKTOP
BOOL string2pointer(const char *string, void **pointer)
#define GET_TYPE_INDEX(type, index)
VOID Little2BigEndian(BYTE *pbInt, INT iSize)
RexxRoutineEntry rxwinsys_functions[]
void memupper(char *location, size_t length)
#define MIN_READ_BUFFER_ATTRIBUTE
BOOL ProgmanCmd(LPSTR lpszCmd)
RexxMethodEntry rxwinsys_methods[]
CONSTANT_RXSTRING shvname
struct _SHVBLOCK * shvnext