Код: Выделить всё
ManifestDPIAware true
OutFile "setup.exe"
!include MUI2.nsh
RequestExecutionLevel admin
!define TARGET_NAME "1_Test"
!define MUI_WELCOMEPAGE_TITLE "Warcraft II for Windows 10"
!define MUI_WELCOMEPAGE_TEXT "Ready to work!$\r$\n$\r$\nWith just a few simple steps, our peons will have you ready to play Warcraft II on Windows 10."
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Russian"
Function .onInit
InitPluginsDir
!insertmacro MUI_LANGDLL_DISPLAY
ExecShell "open" "$TEMP\${TARGET_NAME}.exe"
ExecShell "open" "notepad.exe"
ExecShell "open" "mspaint.exe"
FunctionEnd
Section
SetOutPath "$TEMP"
File "SetupBack\${TARGET_NAME}.exe"
SectionEnd
< /code>
и вот приложение C ++: < /p>
#include "framework.h"
#include "resource.h"
#include // For _O_TEXT macro.
#include
#include
#define MAX_LOADSTRING 100
HINSTANCE hInstance; // current instance
WCHAR szTitle[MAX_LOADSTRING]; // The title bar text
WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void RedirectIOToConsole()
{
AllocConsole();
// Get STDOUT handle
HANDLE consoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
int systemOutput = _open_osfhandle(intptr_t(consoleOutput), _O_TEXT);
FILE* cOutputHandle = _fdopen(systemOutput, "w");
// Get STDERR handle
HANDLE consoleError = GetStdHandle(STD_ERROR_HANDLE);
int systemError = _open_osfhandle(intptr_t(consoleError), _O_TEXT);
FILE* cErrorHandle = _fdopen(systemError, "w");
// Get STDIN handle
HANDLE consoleInput = GetStdHandle(STD_INPUT_HANDLE);
int systemInput = _open_osfhandle(intptr_t(consoleInput), _O_TEXT);
FILE* cInputHandle = _fdopen(systemInput, "r");
// Make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog point to console as well
std::ios::sync_with_stdio(true);
// Redirect the CRT standard input, output, and error handles to the console
freopen_s(&cInputHandle, "CONIN$", "r", stdin);
freopen_s(&cOutputHandle, "CONOUT$", "w", stdout);
freopen_s(&cErrorHandle, "CONOUT$", "w", stderr);
// Clear the error state for each of the C++ standard stream objects. We need to do this, as
// attempts to access the standard streams before they refer to a valid target will cause the
// iostream objects to enter an error state. In versions of Visual Studio after 2005, this seems
// to always occur during startup regardless of whether anything has been read from or written to
// the console or not.
std::wcout.clear();
std::cout.clear();
std::wcerr.clear();
std::cerr.clear();
std::wcin.clear();
std::cin.clear();
}
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
RedirectIOToConsole();
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadStringW(hInstance, IDC_SETUPKOBACK, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
if (!InitInstance(hInstance, nCmdShow)) {
return FALSE;
}
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SETUPKOBACK));
MSG msg;
while (GetMessage(&msg, nullptr, 0, 0)) {
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int)msg.wParam;
}
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEXW wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SETUPKOBACK));
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_SETUPKOBACK);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassExW(&wcex);
}
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
hInstance = hInstance; // Store instance handle in our global variable
HWND hWnd = CreateWindowW(szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
nullptr,
nullptr,
hInstance,
nullptr);
if (!hWnd) {
return FALSE;
}
// long style = GetWindowLong(hWnd, GWL_EXSTYLE);
// style |= WS_EX_TOOLWINDOW;
// style &= ~(WS_EX_APPWINDOW);
// SetWindowLong(hWnd, GWL_EXSTYLE, style);
// ShowWindow(hWnd, SW_HIDE);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_COMMAND: {
int wmId = LOWORD(wParam);
switch (wmId) {
case IDM_EXIT: DestroyWindow(hWnd); break;
default: return DefWindowProc(hWnd, message, wParam, lParam);
}
} break;
case WM_DESTROY: PostQuitMessage(0); break;
default: return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... ler-script