mrider Posted September 26, 2013 Share Posted September 26, 2013 (edited) Greetings: I searched forum and didn't find this - however I'm willing to concede that this is probably a "you didn't search well enough" problem. The following code shows a different answer for "C:" than "C:" (see image at bottom of page): MsgBox(0, "Attribs", FileGetAttrib("C:") & @LF & FileGetAttrib("C:\")) However, the following C code does not: #include <stdio.h> #include <Windows.h> void print_attributes(const char * file) { DWORD attribs = GetFileAttributes(file); if(attribs == INVALID_FILE_ATTRIBUTES) { printf("%s did not return valid attributes\n", file); } else { printf("%c%c%c%c%c%c%c%c%c\n", (attribs & FILE_ATTRIBUTE_READONLY) ? 'R' : ' ', (attribs & FILE_ATTRIBUTE_ARCHIVE) ? 'A' : ' ', (attribs & FILE_ATTRIBUTE_SYSTEM) ? 'S' : ' ', (attribs & FILE_ATTRIBUTE_HIDDEN) ? 'H' : ' ', (attribs & FILE_ATTRIBUTE_NORMAL) ? 'N' : ' ', (attribs & FILE_ATTRIBUTE_DIRECTORY) ? 'D' : ' ', (attribs & FILE_ATTRIBUTE_OFFLINE) ? 'O' : ' ', (attribs & FILE_ATTRIBUTE_COMPRESSED) ? 'C' : ' ', (attribs & FILE_ATTRIBUTE_TEMPORARY) ? 'T' : ' ' ); } } int main(void) { print_attributes("C:"); print_attributes("C:\\"); return 0; } So what gives? (BTW, Windows XP 32 bit, SP3, pretty much all latest patches and hotfixes...) (BTW2, the C code shows S, H, and D for both) Edited September 26, 2013 by mrider How's my riding? Dial 1-800-Wait-There Trying to use a computer with McAfee installed is like trying to read a book at a rock concert. Link to comment Share on other sites More sharing options...
BrewManNH Posted September 26, 2013 Share Posted September 26, 2013 C: is the root of drive C:, whereas C: is the current directory the working directory is currently set to. MsgBox(0, "Attribs", FileGetAttrib("C:") & @LF & FileGetAttrib("C:\") & @LF & FileGetAttrib(@WorkingDir)) 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 Link to comment Share on other sites More sharing options...
mrider Posted September 26, 2013 Author Share Posted September 26, 2013 (edited) I only actually rely in the "D", so my code works and this doesn't cause me any problems whatsoever. But I guess what I found surprising is that AutoIt and the Windows API return different things. I would have expected AutoIt to use the Windows API. However, looking more closely at the API for GetFileAttributes, I see that the minimum client is Windows XP. So presumably AutoIt uses an older API that I don't know about (I almost never write C in Windows...). C: is the root of drive C:, whereas C: is the current directory the working directory is currently set to. That makes sense in light of the fact that the AutoIt developers are probably using a different API call than I am. Edited September 26, 2013 by mrider How's my riding? Dial 1-800-Wait-There Trying to use a computer with McAfee installed is like trying to read a book at a rock concert. Link to comment Share on other sites More sharing options...
BrewManNH Posted September 27, 2013 Share Posted September 27, 2013 When I ran your C code from the first post I get this as the output. D SH D They both give the same results on my Win7 x64 machine. 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 Link to comment Share on other sites More sharing options...
mrider Posted September 27, 2013 Author Share Posted September 27, 2013 Well then - curiouser and curiouser. Thanks for trying it. How's my riding? Dial 1-800-Wait-There Trying to use a computer with McAfee installed is like trying to read a book at a rock concert. Link to comment Share on other sites More sharing options...
isosmart Posted September 27, 2013 Share Posted September 27, 2013 Thanks I will try it later. You are the boss Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 27, 2013 Share Posted September 27, 2013 Where are you running your C compiled executable from? The working directory will make a difference. Link to comment Share on other sites More sharing options...
mrider Posted September 27, 2013 Author Share Posted September 27, 2013 Where are you running your C compiled executable from? The working directory will make a difference. I don't understand that, considering that I have "C:" and "C:" hard-coded. However, I'm certainly willing to throw it into a few different directories to see what happens... As I say, this isn't a problem for me. Just something that I found surprising. How's my riding? Dial 1-800-Wait-There Trying to use a computer with McAfee installed is like trying to read a book at a rock concert. Link to comment Share on other sites More sharing options...
wraithdu Posted September 27, 2013 Share Posted September 27, 2013 Since 'C:' refers to the current working directory, it doesn't matter that it's hard coded. So if you run the example from the root of drive C:, in that case C: and C: are equivalent. But if you run it anywhere else, you should see the difference. Link to comment Share on other sites More sharing options...
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