How to call functions in Advapi32.dll using ctypes

Discussion in 'Python' started by Podi, Apr 8, 2006.

  1. Podi

    Podi Guest

    I have ctypes version 0.9.6 and Python 2.4.2 running on Windows XP
    Professional.

    When I tried to use some functions in the Advapi32.dll, some functions
    are available and some are not. Is this a bug or feature by design?

    In the example below, I am trying to examine the
    'InitiateSystemShutdown' function which is from Advapi32.dll as
    advertised by Microsoft
    http://msdn.microsoft.com/library/d...n-us/shutdown/base/initiatesystemshutdown.asp

    Thanks,
    P

    >>> import ctypes
    >>> advapi32 = ctypes.oledll.LoadLibrary('Advapi32.dll')
    >>> advapi32.InitiateSystemShutdown

    Traceback (most recent call last):
    File "<interactive input>", line 1, in ?
    File "C:\Python24\lib\site-packages\ctypes\__init__.py", line 395, in
    __getattr__
    func = self._OlecallFuncPtr(name, self)
    AttributeError: function 'InitiateSystemShutdown' not found
    >>>
     
    Podi, Apr 8, 2006
    #1
    1. Advertising

  2. Podi

    Serge Orlov Guest

    Podi wrote:
    > I have ctypes version 0.9.6 and Python 2.4.2 running on Windows XP
    > Professional.
    >
    > When I tried to use some functions in the Advapi32.dll, some functions
    > are available and some are not. Is this a bug or feature by design?


    Most likely feature by design. What you see in documentation for C
    library is not what your C code will actually use. For example when you
    write errno in C (that looks like global variable access) it is
    actually a call to __thread_safe_errno() function.

    Have you tried calling InitiateSystemShutdownA mentioned in the
    documentation?
     
    Serge Orlov, Apr 8, 2006
    #2
    1. Advertising

  3. Podi

    Podi Guest

    > Have you tried calling InitiateSystemShutdownA mentioned in the
    > documentation?


    Thanks! This function exists. However,
    advapi32.InitiateSystemShutdownA("", 'This is a test', 30, 1, 1)
    returns 0 though. I will need to play with it a bit more...
     
    Podi, Apr 10, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    1,395
    Joe Kaplan \(MVP - ADSI\)
    Sep 28, 2005
  2. Blacksheep
    Replies:
    1
    Views:
    2,222
    White Wolf
    Aug 28, 2003
  3. Replies:
    7
    Views:
    269
  4. C

    advapi32.dll / LogonUser

    C, May 16, 2006, in forum: ASP .Net Security
    Replies:
    3
    Views:
    917
    Henning Krause [MVP]
    May 17, 2006
  5. Alex Wolff

    Trying to use Lin ADVAPI32.DLL in ASP.

    Alex Wolff, Sep 21, 2004, in forum: ASP General
    Replies:
    0
    Views:
    230
    Alex Wolff
    Sep 21, 2004
Loading...

Share This Page