CTypes wnetaddconnection2
Matthias Janes
matthiasjanes at lycos.com
Mon May 26 06:24:17 EDT 2003
I have one question about the usage of "CTypes"
I have some scripts using the "Mark Hammond's win32all"
win32all-153.exe extention.
I would like for certain reason to use the CTypes module.
Could not figure out some things - maybe you could help me - with some
kind of hints.
1. FIRST get Remote Access to a PC : parts of my script at this moment
#!/usr/bin/env python
#________________________________________________________________________#
#
# BEGIN: get privileged user access to Pc
#
import win32net, win32netcon, win32wnet
IP = "10.199.61.3"
LocalName = None
RemoteMachine = "\\\\" + IP
ProviderName = None
win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_ANY,LocalName,RemoteMachine,ProviderName,"PrivilegedUser","PrivilegedUserPassword")
#
# END:get privileged user access to Pc
#________________________________________________________________________#
CTypes so far:get privileged user access to Pc
MS-INFO:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetaddconnection2.asp
DWORD WNetAddConnection2(
LPNETRESOURCE lpNetResource,
LPCTSTR lpPassword,
LPCTSTR lpUsername,
DWORD dwFlags
);
MS-INFO END!
#!/usr/bin/env python
#________________________________________________________________________#
#
# BEGIN: CTypes: get privileged user access to Pc
#
import ctypes
IP = "10.199.61.3"
LocalName = None
RemoteMachine = "\\\\" + IP
ProviderName = None
RESOURCETYPE_ANY = 0x0
a=ctypes.windll.mpr.WNetAddConnection2A(RESOURCETYPE_ANY,LocalName,RemoteMachine,ProviderName,"PrivilegedUser","PrivilegedUserPassword")
#
# END:get privileged user access to Pc
#________________________________________________________________________#
GET error:
ValueError: Procedure probably called with too many arguments (8 bytes
in excess)
I'm not sure - do I have to make for the 'lpNetResource'
DWORD WNetAddConnection2(
LPNETRESOURCE lpNetResource,
LPCTSTR lpPassword,
LPCTSTR lpUsername,
DWORD dwFlags
);
something like a Structure and how would this be ???
class RECT(Structure):
_fields_ = [("upperleft", POINT),
"lowerright", POINT)]
Thanks for any help.
regards,
Matthias Janes
More information about the Python-list
mailing list