This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- CreateFile always return error code (-1) - please help
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Nov 17, 2014
03:18 AM
CreateFile always return error code (-1) - please help
Hello everyone,
I'm trying to write some logging activity to text file using the installscript.
Basically, it's should be a simple task (as seen on InstallShield help)
Here is my code:
logPath = "c:\\";
logFileName = "gil.log";
nvRet = CreateFile ( nvFileHandle, logPath, logFileName);
if ( nvRet < 0) then
NumToStr(nvRetStr,nvRet);
MessageBox("Error(" + nvRetStr + ") - Cannot create log file: " + logPath + logFileName,INFORMATION);
exit;
else
MessageBox("Successfully created log file: " + logPath + logFileName,INFORMATION);
endif;
The problem is that i always get -1 from CreateFile, i've tried to change file location, name, different PC, running in debug and release setup.exe, it always the same... error code -1.
I can't think of anything else which may causing this error, and furthermore - i can't seem to find proper documentation or list of error code and reasons.
Will appreciate any help or suggestions, Gil.
I'm trying to write some logging activity to text file using the installscript.
Basically, it's should be a simple task (as seen on InstallShield help)
Here is my code:
logPath = "c:\\";
logFileName = "gil.log";
nvRet = CreateFile ( nvFileHandle, logPath, logFileName);
if ( nvRet < 0) then
NumToStr(nvRetStr,nvRet);
MessageBox("Error(" + nvRetStr + ") - Cannot create log file: " + logPath + logFileName,INFORMATION);
exit;
else
MessageBox("Successfully created log file: " + logPath + logFileName,INFORMATION);
endif;
The problem is that i always get -1 from CreateFile, i've tried to change file location, name, different PC, running in debug and release setup.exe, it always the same... error code -1.
I can't think of anything else which may causing this error, and furthermore - i can't seem to find proper documentation or list of error code and reasons.
Will appreciate any help or suggestions, Gil.
(1) Reply
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Nov 17, 2014
09:28 AM
Sometimes you can get a clearer picture of what's taking place on the machine if you use a tool like Process Monitor. Similar information may be available in InstallScript through Err.LastDllError as well.
The one thing that jumps out at me with the path you mention (and is used in the example) is that it likely requires elevated privileges to write to that location. Depending on how your function is invoked, it's possible that it doesn't have the required privileges. By contrast, FOLDER_TEMP shouldn't require extra privileges, so maybe try that instead of "C:\\".
The one thing that jumps out at me with the path you mention (and is used in the example) is that it likely requires elevated privileges to write to that location. Depending on how your function is invoked, it's possible that it doesn't have the required privileges. By contrast, FOLDER_TEMP shouldn't require extra privileges, so maybe try that instead of "C:\\".