Jump to content

_WinAPI_EnumProcessModules error 10


AutID
 Share

Recommended Posts

Hello,

I will put it as simple as possible

Why this code runs perfectly on 32bit and it fails on 64bit?

Local $hWND = WinGetProcess("[CLASS:LSS_app]")
ConsoleWrite($hWND & @LF)
Local $hModuleList = _WinAPI_EnumProcessModules($hWND)
If @error Then ConsoleWrite("Error: " & @error & @LF)
For $i = 0 To $hModuleList[0][0] - 1
;~  If StringInStr($hModuleList[$i][1], "sysCap64.dll") Then
        ConsoleWrite($hModuleList[$i][0] & @LF)
;~  EndIf
Next

As the title says EnumProcessModules returns error 10 which I have no clue what it is.

It must be something with autoit or my lack of coding because a similar code in C# will work like a charm on both x86 and x64

            Process[] Processes = Process.GetProcessesByName("winLSS64Cap");
            Process nProcess = Processes[0];
            Handle = OpenProcess(0x10, true, (uint)nProcess.Id);
            for(int i = 0; i < nProcess.Modules.Count; i++)
            {
                Console.WriteLine(nProcess.Modules[i].ModuleName);
            }

 

Edited by AutID
Link to comment
Share on other sites

Out of all the posts I've seen where someone tried to blame AutoIt, they've never been right.

#include <WinApiProc.au3>

Local $hWND1 = WinGetProcess("[CLASS:MozillaWindowClass]")
Local $hWND2 = WinGetProcess("[CLASS:QWidget]")
Local $hModuleList = _WinAPI_EnumProcessModules($hWND1)
ConsoleWrite("Error for $hWND1 (PID: " & $hWND1 & ") " & @error & @LF)
$hModuleList = _WinAPI_EnumProcessModules($hWND2)
ConsoleWrite("Error for $hWND2 (PID: " & $hWND2 & ") " & @error & @LF)

I get no error when I enum for FireFox but i do get an error when I enum for QWidget (VLC). Both PIDs are correct.

Link to comment
Share on other sites

32 minutes ago, InunoTaishou said:

Out of all the posts I've seen where someone tried to blame AutoIt, they've never been right.

#include <WinApiProc.au3>

Local $hWND1 = WinGetProcess("[CLASS:MozillaWindowClass]")
Local $hWND2 = WinGetProcess("[CLASS:QWidget]")
Local $hModuleList = _WinAPI_EnumProcessModules($hWND1)
ConsoleWrite("Error for $hWND1 (PID: " & $hWND1 & ") " & @error & @LF)
$hModuleList = _WinAPI_EnumProcessModules($hWND2)
ConsoleWrite("Error for $hWND2 (PID: " & $hWND2 & ") " & @error & @LF)

I get no error when I enum for FireFox but i do get an error when I enum for QWidget (VLC). Both PIDs are correct.

I don't know who is blaming autoit and I don't know what your post means.
In case you are talking about me and supposing I am that guy blablabla, how does your post prove the opposite?

Link to comment
Share on other sites

9 hours ago, JohnOne said:

Have you tried compiling code for 64 bit?

Just to eliminate that.

To me "The environment is incorrect" sounds like a bitness issue you see,

That solved it! However I need to compile it every time I need to test it. + consolewrite debugs won't do here.
Is there a way to avoid this issue on scite?

Big thanks mate

Link to comment
Share on other sites

#AutoIt3Wrapper_UseX64=Y, add this to your script and then run it in Scite, should be fine that way.

 

EDIT: You have to have installed Scite4AutoIt3 prior to using this directive.

Edited by BrewManNH

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 Gude
How 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

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
 Share

×
×
  • Create New...