473,804 Members | 3,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
'InitiateSystem Shutdown' 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.L oadLibrary('Adv api32.dll')
advapi32.Initia teSystemShutdow n Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "C:\Python24\li b\site-packages\ctypes \__init__.py", line 395, in
__getattr__
func = self._OlecallFu ncPtr(name, self)
AttributeError: function 'InitiateSystem Shutdown' not found


Apr 8 '06 #1
2 4534
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_e rrno() function.

Have you tried calling InitiateSystemS hutdownA mentioned in the
documentation?

Apr 8 '06 #2
> Have you tried calling InitiateSystemS hutdownA mentioned in the
documentation?


Thanks! This function exists. However,
advapi32.Initia teSystemShutdow nA("", '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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2753
by: Java and Swing | last post by:
Is there some other way, besides SWIG, which will allow me to call functions inside an Ansi C DLL? Example (C): defs.h ------- typedef unsigned long MY_DIGIT; myapp.c
7
29361
by: Vincent Nguyen | last post by:
Hi, Does anyone know how call Win32 native API GetTokenInformation() by using C#? Any sample code would be helpful. Thanks! Vincent
3
10757
by: Morten | last post by:
Hi! Has anyone been able to use LSA functions to grant or remove privileges to/from users? I'm trying to find a way to programmatically set the "Deny logon through Terminal Services" privilege for certain users. If someone has a small example of how to use these functions from C# it would be very helpful. Thanks in advance
1
1925
by: Gerald Klix | last post by:
I read the whol email thread carefully and could not find any sentence by Guido, which states that he does not accept ctypes for the standard library. He just declined to rewrite winreg. Did I miss something? Cya, Gerald -----Ursprüngliche Nachricht----- Von: python-list-bounces+gerald.klix=klix.ch@python.org Im Auftrag von
5
2022
by: Oliver Andrich | last post by:
Hi, hopefully someone with some ctypes experience can help me. I guess this is a trivial task again, but I have been googling, reading, experimenting the whole afternoon without any success. I have a given C function signature: char *MagickGetException(MagickWand *wand,ExceptionType *severity)
0
3223
by: malen | last post by:
Hi all! I'm building mouse movement filter program for Windows and Mac OS X. In Windows I use ctypes.windll.user32.getCursorPos(pointer) and ctypes.windll.user32.setCursorPos(x,y) to get and set the cursor position but I do not know what the library and functions are called in Mac OS X (I'm a complete noob when it comes to Mac :) ) To explain better (I hope) here is the windows code for a test program that forces the mouse to use a...
2
8420
by: rdilipk | last post by:
I am posting at the end of this post some code that P/Invoke's SetSystemTime to set the local system time. This call fails -- i.e the time is not set and the API returns false. However calling Marshal.GetLastWin32Error immediately afterwards returns an errorcode of 0 indicating that the operation somehow executed successfully. This is a plain vanilla console app written in C#. It runs on vista and has a manifest embedded in it that...
0
874
by: dudeja.rajat | last post by:
Hi, I'm using the ctypes module to load my dlls. I have some 10 dlls the names of those are passed to a fucntion which then loads the passed dll. Now every dll has a getversion function. eg: A.dll, B.dll, C.dll are the dlls and GetVersion functions are as:
0
890
by: Gabriel Genellina | last post by:
En Tue, 26 Aug 2008 07:42:50 -0300, <dudeja.rajat@gmail.comescribi�: Use getattr - same as with any other object. Suppose some_dll is your loaded DLL, then: function = getattr(some_dll, function_name) -- Gabriel Genellina
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10564
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10308
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10073
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9134
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5645
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.