472,141 Members | 1,198 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,141 software developers and data experts.

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 4335
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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.