PDA

View Full Version : Create Folder and error codes



jim
06-20-2010, 11:40 PM
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

linder
06-21-2010, 01:33 AM
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/library/aa363855(VS.85).aspx

Does this help?

Friedrich

jim
06-21-2010, 12:46 PM
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?

jim
06-21-2010, 06:37 PM
Yes that was helpful.

Is there a specific error returned for it cannot create the folder?

Jimmy

linder
06-21-2010, 11:57 PM
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