Jump to content
Sign in to follow this  
Negative1

problem with _winapi_openprocess

Recommended Posts

Negative1

Hi all,

Heres a snippet of the code that throws up the error:

#include <WinAPI.au3>
    $core = 1
    if $core=1 Then
        $sPID=processexists("Processor Benchmarking2.exe")
        $hProc = _WinAPI_OpenProcess($PROCESS_ALL_ACCESS, False, $sPID)
        $aRet = _WinAPI_GetProcessAffinityMask($hProc)
        _WinAPI_SetProcessAffinityMask($hProc,0x01);Set affinity for dual core
        _WinAPI_CloseHandle($hProc)
    Elseif $core=2  Then
        $sPID=processexists("Processor Benchmarking2.exe")
        $hProc = _WinAPI_OpenProcess($PROCESS_ALL_ACCESS, False, $sPID)
        $aRet = _WinAPI_GetProcessAffinityMask($hProc)
        _WinAPI_SetProcessAffinityMask($hProc,0x03);Set affinity for dual core
        _WinAPI_CloseHandle($hProc)
    EndIf

the Error reported:

C:\Documents and Settings\Gray_Paul\My Documents\Scripting\Testbed\processor benchmarking2.au3(386,51) : WARNING: $PROCESS_ALL_ACCESS: possibly used before declaration.

$hProc = _WinAPI_OpenProcess($PROCESS_ALL_ACCESS,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\Gray_Paul\My Documents\Scripting\Testbed\processor benchmarking2.au3(386,51) : ERROR: $PROCESS_ALL_ACCESS: undeclared global variable.

$hProc = _WinAPI_OpenProcess($PROCESS_ALL_ACCESS,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Now the strange thing is i took this code from another one of my programs that works absolutely fine.

Any ideas?

thanks in advance

-1


What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Share this post


Link to post
Share on other sites
ChrisFromBoston

Doesn't look like you're defining PROCESS_ALL_ACCESS anywhere. I googled for the value, and I think this should work:

Global Const $PROCESS_ALL_ACCESS = 0x1f0fff

Also, you should check $sPID before you try and call OpenProcess, if it doesn't exist as a process, your script will bomb.

Share this post


Link to post
Share on other sites
Negative1

Doesn't look like you're defining PROCESS_ALL_ACCESS anywhere. I googled for the value, and I think this should work:

Global Const $PROCESS_ALL_ACCESS = 0x1f0fff

Also, you should check $sPID before you try and call OpenProcess, if it doesn't exist as a process, your script will bomb.

No go with that but thanks for the idea... Strange thing though is im using this code in another program and it works...

Also in the main script i check processexsists first.


What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Share this post


Link to post
Share on other sites
ChrisFromBoston

No go with that but thanks for the idea... Strange thing though is im using this code in another program and it works...

Well now that you're defining it, you should at least be getting a different error, no?

Share this post


Link to post
Share on other sites
Negative1

#include <Constants.au3>

damn damn damn....sorry all for the wasting of forum space ^_^


What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Share this post


Link to post
Share on other sites
rajeshontheweb

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  

×