Old 22nd January 2015, 12:29   #1
shilya
Junior Member
 
Join Date: Apr 2013
Posts: 2
Runing exe file by Exec/ExecShell

Hi,
Runing my exe-file in NSIS with command 'Exec' exe-file recieves 'SW_SHOWMINIMIZED'
Exec 'test.exe'..

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int showcmd)....

And i can't understand why
I expected recieve SW_SHOWNORMAL or SW_SHOWDEFAULT

Using ExecShell i can set parameter 'SW_SHOWNORMAL' and everything is ok but its elevated process (

Could you explain me what i do wrong?
thanks
shilya is offline   Reply With Quote
Old 22nd January 2015, 15:52   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,539
Did you start the NSIS installer minimized?

Exec does not specify STARTF_USESHOWWINDOW in its STARTINFO when calling CreateProcess so what happens might be up to your C-runtime (WinMain is not the real start of a Windows application). However, if STARTF_USESHOWWINDOW is set then ShowWindow() is supposed to use the value from STARTINFO and not the parameter you passed it the first time you call it! Is it possible the problem is in your app?

With a simple app like this:
Quote:
TRACE3A(...) {...}
... WinMainCRTStartup()
{
STARTUPINFO si;
si.cb = sizeof(si), si.wShowWindow = 0x666;
GetStartupInfo(&si);
TRACE3A("cb=%u dwFlags=%#x wShowWindow=%#x\n", si.cb, si.dwFlags, si.wShowWindow);
HWND hwnd = CreateWindowEx(0, TEXT("STATIC"), 0, WS_OVERLAPPEDWINDOW|WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0);
ShowWindow(hwnd, SW_SHOWNORMAL);
SetTimer(hwnd, 1, 3333, (TIMERPROC)ExitProcess); // This is a super ugly hack, don't ever do this
for (MSG msg; IsWindow(hwnd) && GetMessage(&msg, 0, 0, 0);) DispatchMessage(&msg); // Another hack!
ExitProcess(0);
}
and this NSIS code:
Quote:
Exec '"$temp\test.exe"'
!include WinMessages.nsh
System::Call 'KERNEL32::WinExec(m "$temp\test.exe", i ${SW_SHOWMINNOACTIVE})' ; Note: There is no Unicode version of this function!
I get this:
Quote:
cb=68 dwFlags=0x0 wShowWindow=0x0
cb=68 dwFlags=0x1 wShowWindow=0x7
You complaints about ExecShell are strange. If UAC is on then the only scenario where ExecShell will elevate and Exec will start normally is if you are not a member of the administrators group and the requested execution level is set to highestAvailable.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump