Old 16th February 2017, 19:42   #1
alexmitev
Junior Member
 
Join Date: Feb 2017
Posts: 15
Get actual error code if ExecWait fails?

Hello,
I am interested in getting the actual Windows error code if ExecWait fails. In the docs it is said "ExecWait sets the error flag if an error occurs". As far as I can see, the error flag has 2 values: set and unset, and I need the Windows error code.
If I call GetLastError using System, will it returned the actual Windows error code that ExecWait triggered?
Regards,
Alex
alexmitev is offline   Reply With Quote
Old 16th February 2017, 20:59   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,473
No you cannot call GetLastError with the system plugin because the last error can change inside the system plugin code.

You must call CreateProcess yourself:
PHP Code:
!include LogicLib.nsh
Section 
!if "${NSIS_PTR_SIZE}<= 4
System
::Call '*(i,i,i,i)i.r0'
System::Alloc 68
pop 
$4
System
::Call "*$4(i 68)"
StrCpy $'"explorer.exe" /e,"$startmenu"'
System::Call 'kernel32::CreateProcess(i0,tr1,i0,i0,i0,i 0,i0,i0,ir4,ir0)i.r3?e' ;?e pushes GetLastError result on the stack
Pop 
$5
DetailPrint 
Return=$3,GetLastError=$5
System
::Free $4
${If} $<> 0
    System
::Call "*$0(i.r3,i.r4)"
    
System::Call 'kernel32::WaitForSingleObject(i $3, i -1)'
    
System::Call 'kernel32::CloseHandle(i $3)'
    
System::Call 'kernel32::CloseHandle(i $4)'
${EndIf}
System::Free $0
!endif
SectionEnd 

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