vatobeto Posted May 26, 2007 Share Posted May 26, 2007 (edited) I am still struggling with DLLs that have constant parameters. Currently, I find I need to change a directory (specified by user input so it is no longer Read-Only. The Win32 API info which I found for that follows. I have tried this: $FILE_ATTRIBUTE_DIRECTORY = 0x10 $FILE_ATTRIBUTE_HIDDEN = 0x2 $FILE_ATTRIBUTE_READONLY = 0x1 $filename = InputBox("","Enter file name:") $SetFileAttributes = 0x2f8 $dll = DllOpen("kernel32.dll") MsgBox(0,"","$dll = " & $dll) $result = DllCall("kernel32.dll","int", $SetFileAttributes,"str",$filename,"int",$FILE_ATTRIBUTE_READONLY) MsgBox(0,"","$result = " & $result) DllClose($dll) When I run that, the file/folder remains unchanged. Can a helpful DLL guru (well, really anybody) assist me with this? I couldn't locate any examples with constant parameters, and i don't quite get it yet. Thanks, if you can. I have worked up a headache over this. TIA vatobeto. SetFileAttributes The SetFileAttributes function sets the attributes for a file or directory. BOOL SetFileAttributes( LPCTSTR lpFileName, DWORD dwFileAttributes ); Parameters lpFileName [in] Pointer to a string that specifies the name of the file whose attributes are to be set. In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File. Windows Me/98/95: This string must not exceed MAX_PATH characters. dwFileAttributes [in] File attributes to set for the file. This parameter can be one or more of the following values. However, all other values override FILE_ATTRIBUTE_NORMAL. Attribute Meaning FILE_ATTRIBUTE_ARCHIVE A file or directory that is an archive file or a directory .Applications Use this attribute to mark files for backup or removal. FILE_ATTRIBUTE_HIDDEN The file or directory is hidden. It is not included in an ordinary Directory listing. FILE_ATTRIBUTE_NORMAL A file or directory that does not have other attributes set. This attribute is valid only when used alone. FILE_ATTRIBUTE_NOT_CONTENT_INDEXED The file or directory is not be indexed by the content indexing service. FILE_ATTRIBUTE_OFFLINE The data of a file or directory is not available immediately. This Attribute indicates that the file data is physically moved to offline storage. This attribute is used by Remote Storage, which is the hierarchical storage management software. Applications should not arbitrarily change this attribute. FILE_ATTRIBUTE_READONLY A file or directory that is read-only. For a file, applications can read the file, but cannot write to it or delete it. For a directory, applications cannot delete it. FILE_ATTRIBUTE_SYSTEM A file or directory that the operating system uses a part of, or uses exclusively. FILE_ATTRIBUTE_TEMPORARY A file or directory that is being used for temporary storage. File systems avoid writing data back to mass storage if sufficient cache memory is available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can entirely avoid writing the data. Otherwise, the data is written after the handle is closed. FILE_ATTRIBUTE_VIRTUAL A file is a virtual file. Return Value If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError. Edited May 26, 2007 by vatobeto Link to comment Share on other sites More sharing options...
BrettF Posted May 26, 2007 Share Posted May 26, 2007 FileSetAttrib should do your job. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
vatobeto Posted May 26, 2007 Author Share Posted May 26, 2007 FileSetAttrib should do your job. Well, yes and no...FileSetAttrib seems to work on files, but not folders - at least with regard to the Read-Only attribute.vatobeto. Link to comment Share on other sites More sharing options...
Rick Posted May 26, 2007 Share Posted May 26, 2007 thats normal, by default folders are readonly Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
vatobeto Posted May 26, 2007 Author Share Posted May 26, 2007 thats normal, by default folders are readonlyRight - knew that. But, does that make it impossible to delete folders with AutoIt? I did see the following line in the FileDelete help:Some file attributes can make the deletion impossible.Inquiring minds need to know... vatobeto. Link to comment Share on other sites More sharing options...
Rick Posted May 26, 2007 Share Posted May 26, 2007 (edited) check out "DirRemove" in the help file, yes, you can remove folders with autoIt, and check for if successful or not. Edited May 26, 2007 by Rick Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
vatobeto Posted May 26, 2007 Author Share Posted May 26, 2007 Right - knew that. But, does that make it impossible to delete folders with AutoIt? I did see the following line in the FileDelete help:Inquiring minds need to know... vatobeto. Oh...hello!I know - RTFM. Or at least read the whole page you're currently viewing!Last line of FileDelete help: RelatedFileCopy, FileMove, FileRecycle, DirRemove DirRemove was what was needed all along. Newbies are such a pain - huh?Mea maxima culpa - vatobeto. 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