Sign in to follow this  
Followers 0
Colin

_GUICtrlTreeView_FindItem

5 posts in this topic

#1 ·  Posted (edited)

I'm just not having any luck with this Tree View control. I've had issues with both _GUICtrlTreeView and ControlTreeView. This issue is with the _GUICtrlTreeView_FindItem. I am using Computer Management as a test for right now, and when I use this function on it, I'm receiving an error.

First I get:

"Microsoft Management Console has encountered a problem and needs to close. We are sorry for the inconvenience."

Standard windows error...

Then:

"_WinAPI_ReadProcessMemory: Access is denied."

What do I do here? This seems to be an issue not with AutoIT itself, but in how the information is being pulled from the windows application. When it asks for the handle of the control in that window, it is failing.

Here is the code I am using just for referrence. It is a very simple test of the function. Removing the lined with $hItem, and that variable from the message box, causes the program to work fine with no errors, so it has to be something about that function.

#include <GuiTreeView.au3>

run ("cmd /c compmgmt.msc", @SystemDir, @SW_HIDE)
WinWaitActive("Computer Management")

$hWin = WinGetHandle("Computer Management")
$hTreeView = ControlGetHandle("Computer Management", "", 12785)

$hItem = _GUICtrlTreeView_FindItem($hTreeView, "Local Users and Groups", True)

MsgBox(1, "", $hTreeView & " " & $hItem)

Am I doing something wrong? Is there something I need to change in this code for it to work? Is it just that the windows application I am working with doesn't like this? Is there some other method of accessing this same data?

Thank you in advance for any help.

Edit: Looked up that function in the includes. It seems to be calling the ReadProcessMemory from the kernel32.dll. I looked that function up at the MSDN website and it mentions this:

"The entire area to be read must be accessible, and if it is not accessible, the function fails."

Any ideas on how to make the entire area to be read accessible?

Edited by Colin

Share this post


Link to post
Share on other sites



..... Is there some other method of accessing this same data?

.....

Hi,

Yes you could use shell/wmi object to get and set the same data your trying to access.

Here's a link to shell object samples which can easily be converted to use in autoit:

Groups

Users

Also if you search the Example Scripts thread you can find someone has already translated some of the basics already: Local account UDF, Manage local user accounts and groups

Cheers

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hmm, interesting... I guess I should have explained a bit more though. I'm using Computer Management as a test. The end goal of the overall project is to use Internet Information Services (IIS) on Windows Server. Is there a similar UDF for IIS? I have to access the virtual directory that had been created previously and allow write access (check the "write" box).

Good thing is I did actually have to check the Password never expires box on the local account as well. That will save a lot of time.

Edited by Colin

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Awesome, thanks for the help. Actually, I started getting into that yesterday. I was really close to what I needed, but couldn't quite get there. I struggled with it a bit this morning and just stumbled accross the problem... There are two classes, one for the Methods and Read-only properties, and one for all of the modifiable properties. I just needed to add the word "Setting" to the end of it. Seems like it's working for now.

Thank you so much for pointing me in this direction. I've been struggling with a way to do this for a few months now. I'm never going to touch Treeviews again! Heh.

Edited by Colin

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0