Skip to content
⌘ NSIS Forum Archive

Find what error happens during file open?

4 posts

Tintera#

Find what error happens during file open?

I want to find what error happens during file open for read.
Code:

ClearErrors
FileOpen $R3 "$0" r
${If} ${Errors}
DetailPrint "Error opening file '$0' for read."
${EndIf}
StrCpy $R1 0


Log: (using NSIS with logging)
detailprint: FileOpen $R3 "c:\inetpub\wwwroot\PortalBuilder\App_Data\Uninstall\UILayer.log" r
detailprint: Error opening file 'c:\inetpub\wwwroot\PortalBuilder\App_Data\Uninstall\UILayer.log' for read.

The file
exists
I can open it in notepad and read the contents.

I'm using NSIS 2.36 (And can upgrade if needed)
Other file was opened okay using the same code.

Than you in advance for any response.

Tomas Tintera
jpderuiter#
You can't get error codes from NSIS functions.
You need the system plugin to call kernel32::OpenFile to get the errorcode.

See: http://forums.winamp.com/showthread....hreadid=283735
Anders#
CreateFile, not OpenFile

but, before you go down that route, you should check with ProcessMonitor/FileMon from sysinternals
Tintera#
Thank you jpderuiter, Anders, you saved my day.

Filemon & Process Explorer exposed I did not clean handles properly when in another function.