Create Folder and error codes
I want to check for an error code when I create a folder. I have been creating the folders with no problem, but thought it would wise to check for an error just in case.
I get an error code of 0 in my test installer made with SB72 after the create folder function. The folder already exists.
The help file says:
If the function succeeds, the %_SB_ERRORCODE% return value is nonzero.
If the function fails, the return value is zero.
Remarks
The Create Folder function can be used to create multiple nested directories at the same time.
An error occurs if the specified folder already exists.
Which one is it really? Maybe I do not need to check for an error when creating a folder in the CSIDL_COMMON_DOCUMENTS location. Or check for the creation of a share or grant access.
Jim
Re: Create Folder and error codes
Jim,
The "Create Folder" function returns "1" in %_SB_ERRORCODE% if the function succeeds (folder was created).
It returns "0" if the folder creation failed (e.g. if the folder already existed).
"An error occurs if the specified folder already exists" means the function returns "0" (= error) in %_SB_ERRORCODE%.
BTW, "Create Folder" is a wrapper around the CreateDirectoryA Windows API.
http://msdn.microsoft.com/en-us/libr...55(VS.85).aspx
Does this help?
Friedrich
Re: Create Folder and error codes
Yes. It makes since now.
Will we ever get an error if it just cannot create it, not because it already exists so it did not create it?
Re: Create Folder and error codes
Yes that was helpful.
Is there a specific error returned for it cannot create the folder?
Jimmy
Re: Create Folder and error codes
Jimmy,
No, there are only two possible return values:
1.) If the function succeeds, the return value is nonzero.
2.) If the function fails, the return value is zero.
Friedrich