SeunghunBaek Posted January 22, 2013 Posted January 22, 2013 I got a return value 0 when called DirCreate() function. I'd like to handle the error code according to error case. but I can't know what happened during the function call. could anyone please help me to catch the error case? is there GetLastError() function like MFC?
BrewManNH Posted January 22, 2013 Posted January 22, 2013 DirCreate only returns 1 or 0 depending on whether it succeeds or fails. Where are you trying to create the folder, and what OS are you using? If it's a protected location on Vista or above, such as C:Program Files you will probably need to run it under administrator's credentials. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
SeunghunBaek Posted January 22, 2013 Author Posted January 22, 2013 i'm using Autoit on Windows 7. What i want to know is about specific error case when errors occurred. i think there would be many error case. for example due to lack of disk space, wrong path, already existing directory... but i only know whether success or not in Autoit platform. i really want to know how to get a specific error code like win32 api or MFC. please help me.
JohnOne Posted January 22, 2013 Posted January 22, 2013 (edited) The API only sets 2 errors ERROR_ALREADY_EXISTS ERROR_PATH_NOT_FOUND Simply check those two things. FileExists() "due to lack of disk space" I don't think so, I don't even think a folder takes any space, it has no byte value, so if you don't have enough space to create a folder you have bigger problems than those you think you have. You can even test for the disk space if you really believe that to be an issue. Edited January 22, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
BrewManNH Posted January 22, 2013 Posted January 22, 2013 Well, if the folder already exists, then you should be checking for this before trying to create it. (FileExists works on folders too). Also, if the path is bad, you should be checking for that before trying to create a folder in invalid paths. After that, it is usually permissions issues on Windows 7. There is a whole slew of WinAPI functions in the help file, I don't use them much myself, but there might be one in there that could work for you. Unfortunately, natively, DirCreate doesn't tell you why it didn't work, just that it didn't, validity tests are your (the coder's) responsibility. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now