- NSIS Discussion
- How can I do something when NSIS compiler terminates?
Archive: How can I do something when NSIS compiler terminates?
rarefluid
24th December 2002 17:54 UTC
How can I do something when NSIS compiler terminates?
Hi people!
I'm calling the NSIS compiler from a VisualBasic exe which is basically a GUI for making an installer for a specific program.
I have a lot of trouble with the ShellExecuteA excution of the compiler to make the installer, but it works now.
What need is that the compiler gives some kind of feedback when he has finished making the exe. A messagebox or an ShellExecute to open the output folder or something...
My GUI-program may have already terminated and I can't let it wait for 10 minutes till a big installer file finished compiling...
Any (simple) ideas?
kichik
24th December 2002 18:06 UTC
For now you can use CreateProcess and WaitForSingle object instead of ShellExecute. Later you will be able to pass /NOTIFYHWND to makensis.exe and it will let you know when it finishes, what is the output script, and what's the input script. Mayeb some other stuff later...
rarefluid
24th December 2002 18:11 UTC
Sorry to bother, but
Do you have a short example... ;-)
kichik
24th December 2002 18:20 UTC
Not in VB... :(
But NSIS uses it for ExecWait (see Source\exehead\exec.c line 835) so you can look in the C source and try to see what you can get from it.
rarefluid
24th December 2002 18:27 UTC
Because VisualBasic is a major pain in the a$%& when it comes to using API functions... ;-)
Thank you anyways...
case EW_EXECUTE:
{
HANDLE hProc;
char *buf0=process_string_fromparm_tobuf(0x00);
log_printf2("Exec: command=\"%s\"",buf0);
update_status_text_from_lang(LANG_EXECUTE,buf0);
hProc=myCreateProcess(buf0,state_output_directory);
if (hProc)
{
log_printf2("Exec: success (\"%s\")",buf0);
if (parm1)
{
DWORD lExitCode;
while (WaitForSingleObject(hProc,100) == WAIT_TIMEOUT)
{
static MSG msg;
while (PeekMessage(&msg,NULL,WM_PAINT,WM_PAINT,PM_REMOVE))
DispatchMessage(&msg);
}
GetExitCodeProcess(hProc, &lExitCode);
if (parm2>=0) myitoa(var2,lExitCode);
else if (lExitCode) exec_errorflag++;
}
CloseHandle( hProc );
}
else
{
exec_errorflag++;
log_printf2("Exec: failed createprocess (\"%s\")",buf0);
}
}
return 0;
This is it... OK
Another question : What errorcodes does NSIS return on success or errors... Would be good to know... Are they round some where the files (ah, yes sure they are...)? Where?
rarefluid
24th December 2002 18:41 UTC
If anyone except me is interested,
M$ has a good article about this in the Knowledge base:
HOWTO: Use a 32-Bit Application to Determine When a Shelled Process Ends
http://support.microsoft.com/default...b;EN-US;129796
Does exactly this... Enjoy...
Still I hate VB... ;-)
kichik
24th December 2002 18:43 UTC
It's all in MakeNSISw... It basically returns 0 if everything is ok, and 1 otherwise.
kichik
24th December 2002 19:27 UTC
In the latest CVS version makensis sends WM_COPYDATA messages to a window specified by /NOTIFYHWND hwnd in the command line. Possible dwData values are:
enum {
MAKENSIS_NOTIFY_SCRIPT, // script full path
MAKENSIS_NOTIFY_WARNING, // warning
MAKENSIS_NOTIFY_ERROR, // error
MAKENSIS_NOTIFY_OUTPUT // output full path
};
MAKENSIS_NOTIFY_SCRIPT = 0, grows by 1 for each other define in the enum.
The lpData value is set according to dwData.
rarefluid
24th December 2002 19:39 UTC
Thanks. I already did it with the createprocess stuff...
Works ok...
Maybe I'll try implementing the method of listening to a WM_COPYDATA message, as it is a better way.
Later...
Merry Christmas + Happy New Year!
kichik
24th December 2002 19:42 UTC
Hmm... You will have to wait on the new stuf, I am having problems with CVS :(
Merry Christmas and a Happy New Year! Ho Ho Ho :D
kichik
24th December 2002 20:37 UTC
Aight, Joost uploaded it.