- Add samplify runonce.exe utility

svn path=/trunk/; revision=43710
This commit is contained in:
Dmitry Chapyshev 2009-10-24 12:58:07 +00:00
parent 5cb190acc6
commit 5325ee5eee
10 changed files with 246 additions and 0 deletions

View file

@ -0,0 +1,11 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
IDD_RUNONCE_DLG DIALOG DISCARDABLE 0, 0, 239, 170
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "ReactOS Setup"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "ReactOS is now setting up the following items:", -1, 38, 8, 196, 18
LISTBOX IDC_COMP_LIST, 36, 32, 197, 131, LBS_OWNERDRAWVARIABLE | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
ICON IDI_ICON, -1, 5, 6, 21, 20
END

View file

@ -0,0 +1,11 @@
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
IDD_RUNONCE_DLG DIALOG DISCARDABLE 0, 0, 239, 170
STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Óñòàíîâêà ReactOS"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "ReactOS íàñòðàèâàåò ñëåäóþùèå êîìïîíåíòû:", -1, 38, 8, 196, 18
LISTBOX IDC_COMP_LIST, 36, 32, 197, 131, LBS_OWNERDRAWVARIABLE | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
ICON IDI_ICON, -1, 5, 6, 21, 20
END

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View file

@ -0,0 +1,10 @@
#ifndef _RESOURCE_H__
#define _RESOURCE_H__
#define IDI_ICON 10
#define IDD_RUNONCE_DLG 100
#define IDC_COMP_LIST 1000
#endif /* _RESOURCE_H__ */

View file

@ -0,0 +1,2 @@
#include "lang/en-US.rc"
#include "lang/ru-RU.rc"

View file

@ -0,0 +1,180 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS runonce.exe
* FILE: base/system/runonce/runonce.c
* PROGRAMMER: Dmitry Chapyshev (dmitry@reactos.org)
*/
#include "runonce.h"
static
DWORD
WINAPI
StartApplication(LPVOID lpDlg)
{
HWND hList = GetDlgItem((HWND)lpDlg, IDC_COMP_LIST);
INT Index, Count = SendMessage(hList, LB_GETCOUNT, 0, 0);
PROCESS_INFORMATION pi;
STARTUPINFOW si;
TCHAR szData[MAX_PATH];
for (Index = 0; Index < Count; Index++)
{
SendMessage(hList, LB_GETTEXT, Index, (LPARAM)szData);
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.wShowWindow = SW_SHOW;
if (!CreateProcess(NULL, szData, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
continue;
WaitForSingleObjectEx(pi.hProcess, INFINITE, TRUE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
RegDeleteKey(HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\Setup"));
PostMessage((HWND)lpDlg, WM_CLOSE, 0, 0);
return 0;
}
static
VOID
InitDialog(HWND hDlg)
{
TCHAR szAppPath[MAX_PATH], szData[MAX_PATH];
DWORD dwIndex, dwSize, dwType, dwData, dwThreadId;
HKEY hKey;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\Setup"),
0,
KEY_QUERY_VALUE,
&hKey) == ERROR_SUCCESS)
{
for (dwIndex = 0; ; dwIndex++)
{
dwSize = sizeof(szAppPath);
dwData = sizeof(szData) / sizeof(TCHAR);
if (RegEnumValue(hKey,
dwIndex,
szAppPath,
&dwSize,
NULL,
&dwType,
(LPBYTE)szData,
&dwData) == ERROR_SUCCESS)
{
if (dwType != REG_SZ) continue;
SendMessage(GetDlgItem(hDlg, IDC_COMP_LIST), LB_ADDSTRING, 0, (LPARAM)szData);
}
}
RegCloseKey(hKey);
}
CloseHandle(CreateThread(NULL,
0,
StartApplication,
(LPVOID)hDlg,
0,
&dwThreadId));
}
static
INT_PTR
CALLBACK
RunOnceDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg)
{
case WM_INITDIALOG:
InitDialog(hDlg);
break;
case WM_CLOSE:
EndDialog(hDlg, 0);
break;
}
return 0;
}
INT
WINAPI
_tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
{
LPCTSTR lpCmd = GetCommandLine();
TCHAR szAppPath[MAX_PATH], szData[MAX_PATH];
DWORD dwIndex, dwSize, dwType, dwData;
PROCESS_INFORMATION pi;
STARTUPINFOW si;
BOOL bRunApps = FALSE;
HKEY hKey;
while (*lpCmd)
{
while (*lpCmd && *lpCmd != _T('/') && *lpCmd != _T('-')) lpCmd++;
if (!*lpCmd) break;
if (*++lpCmd == _T('r')) bRunApps = TRUE;
lpCmd++;
}
if (bRunApps)
{
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce"),
0,
KEY_QUERY_VALUE,
&hKey) == ERROR_SUCCESS)
{
for (dwIndex = 0; ; dwIndex++)
{
dwSize = sizeof(szAppPath);
dwData = sizeof(szData) / sizeof(TCHAR);
if (RegEnumValue(hKey,
dwIndex,
szAppPath,
&dwSize,
NULL,
&dwType,
(LPBYTE)szData,
&dwData) == ERROR_SUCCESS)
{
RegDeleteValue(hKey, szAppPath);
if (dwType != REG_SZ) continue;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.wShowWindow = SW_SHOW;
if (!CreateProcess(NULL, szData, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
continue;
WaitForSingleObjectEx(pi.hProcess, INFINITE, TRUE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
}
RegCloseKey(hKey);
}
return 1;
}
DialogBox(hInst, MAKEINTRESOURCE(IDD_RUNONCE_DLG), NULL, RunOnceDlgProc);
return 0;
}

View file

@ -0,0 +1,9 @@
#ifndef _RUNONCE_H__
#define _RUNONCE_H__
#include <windows.h>
#include <tchar.h>
#include "resource.h"
#endif /* _RUNONCE_H__ */

View file

@ -0,0 +1,8 @@
<module name="runonce" type="win32gui" installbase="system32" installname="runonce.exe" unicode="yes">
<include base="runonce">.</include>
<library>advapi32</library>
<library>kernel32</library>
<library>user32</library>
<file>runonce.c</file>
<file>runonce.rc</file>
</module>

View file

@ -0,0 +1,12 @@
#include "runonce.h"
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Run Once Wrapper\0"
#define REACTOS_STR_INTERNAL_NAME "runonce\0"
#define REACTOS_STR_ORIGINAL_FILENAME "runonce.exe\0"
#include <reactos/version.rc>
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDI_ICON ICON DISCARDABLE "res/icon.ico"
#include "rsrc.rc"

View file

@ -25,6 +25,9 @@
<directory name="rundll32">
<xi:include href="rundll32/rundll32.rbuild" />
</directory>
<directory name="runonce">
<xi:include href="runonce/runonce.rbuild" />
</directory>
<directory name="services">
<xi:include href="services/services.rbuild" />
</directory>