469,568 Members | 1,394 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,568 developers. It's quick & easy.

How to call functions in Advapi32.dll using ctypes

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


Apr 8 '06 #1
2 4075
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?

Apr 8 '06 #2
> 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...

Apr 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Java and Swing | last post: by
3 posts views Thread by Morten | last post: by
1 post views Thread by Gerald Klix | last post: by
5 posts views Thread by Oliver Andrich | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.