Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to call functions in Advapi32.dll using ctypes

Reply
Thread Tools

How to call functions in Advapi32.dll using ctypes

 
 
Podi
Guest
Posts: n/a
 
      04-07-2006
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/de...emshutdown.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
>>>


 
Reply With Quote
 
 
 
 
Serge Orlov
Guest
Posts: n/a
 
      04-08-2006
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?

 
Reply With Quote
 
 
 
 
Podi
Guest
Posts: n/a
 
      04-10-2006
> 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...

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
ctypes: How to call unexported functions in a dll Coert Klaver (DT) Python 1 01-05-2010 03:02 PM
WindowsXP/ CTypes - How to convert ctypes array to a string? dudeja.rajat@gmail.com Python 0 08-19-2008 10:20 AM
RE: [ctypes-users] [Ann] ctypes 0.9.0 released Henk Punt Python 0 07-23-2004 10:34 PM
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM



Advertisments