ValueError: Procedure called with not enough arguments (4 bytes missing) or wrong calling convention

Posted on 2011-10-03
Last Modified: 2012-06-27
I'm trying to use SetThreadExecutionState to not allow windows to hibernate or go idle which reaks havoc with my program which runs for a long period of time with no data being entered but at times is suddenly called to action... I found this code and I want to us it but ... first I don't completely understand ctypes or kernel32.dll ... I keep getting this error  and How would I turn this into a safe thread ?

ValueError: Procedure called with not enough arguments (4 bytes missing) or wrong calling convention
File "C:\Python26\sign\", line 40, in <module>
File "C:\Python26\sign\", line 33, in main

Open in new window

I don't understand the error and there is not alot of python information on this topic ... anyone have any ideas ?

import os
import sys
import signal
import threading
import ctypes
import win32api
import time

ES_CONTINUOUS = 0x80000000

event = threading.Event()

def ctrlc(signum, frame) :

def main():
    Prevent system suspend when idle
    signal.signal(signal.SIGINT, ctrlc)
    kernel32 = ctypes.CDLL('kernel32.dll')
    #print kernel32
    print 'Bye!'

    return 0

if __name__ == '__main__' :

Open in new window

Question by:dolamitejenkins
    LVL 3

    Accepted Solution

    kernel32 = cdll.<dll name="kernel32.dll">

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    This article will show, step by step, how to integrate R code into a R Sweave document
    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now