FreeFry Posted June 20, 2007 Share Posted June 20, 2007 Hi, just for testing purposes I tried to make a script using the GetAllUsersProfileDirectory function.Problem is, that the script crashes when I try to run it(something wrong in the DllCall..)This is the code I have so far:$lpProfileDir = DllStructCreate("char[255]") If @error Then MsgBox(0, "Error", @error) Exit EndIf $a = DllCall("Userenv.dll", "int", "GetAllUsersProfileDirectory", "ptr", DllStructGetPtr($lpProfileDir), "dword", 255) If @error Then MsgBox(0, "Error", @error) Exit EndIf MsgBox(0, "AllUsers Dir", DllStructGetData($lpProfileDir, 0))Documentation about the function can be found here:http://msdn2.microsoft.com/en-us/library/bb507783.aspxI hope someone experienced in using DllCall could respond to this, as I also have some other questions regarding how c++ structures and calling syntax(es) converts to AutoIt's DllCall usage. Link to comment Share on other sites More sharing options...
piccaso Posted June 20, 2007 Share Posted June 20, 2007 you allmost had it $lpProfileDir = DllStructCreate("char[256]") ; +1 for the terminating null If @error Then MsgBox(0, "Error", @error) Exit EndIf ; LPDWORD -> long_ptr $a = DllCall("Userenv.dll", "int", "GetAllUsersProfileDirectory", "ptr", DllStructGetPtr($lpProfileDir), "long_ptr", 255) If @error Then MsgBox(0, "Error", @error) Exit EndIf ; Element index starts with 1 MsgBox(0, "AllUsers Dir", DllStructGetData($lpProfileDir, 1)) CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
FreeFry Posted June 20, 2007 Author Share Posted June 20, 2007 I forgot to say that the script crashed for some weird reason :S"+1 for the terminating null" I suspected that, but I wasn't really sure."LPDWORD -> long_ptr"Yes, I thought the LP stood for "long pointer", but when I tried it, the script still crashed... but I only tested it on the first parameter (whops )But I don't get how the "easier" way works, the documentation doesn't say that it will return the value as it's return value if the first parameter is NULL :S Care to explain to me?"Element index starts with 1"whops, careless misstake on my part, but the script was still crashing because of the DllCall... :SI'm a little confused, anyways thanks for your help in sorting those problems out for me. Link to comment Share on other sites More sharing options...
piccaso Posted June 20, 2007 Share Posted June 20, 2007 can you be a bit more specific in your question on the easy way, because i don't understand it CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map 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