ctypes WNetGetUniversalNameW

Gustavo gustavotabares at gmail.com
Wed Sep 2 13:24:10 EDT 2009


Hello,

I'm trying to call WNetGetUniversalNameW via the ctypes module but I'm
only causing the interpreter to crash. Unfortunately I don't have much
experience with the ctypes module and I'm still trying to figure it
out. I've searched for a solution to no avail. My confusion is
centered around the LPVOID buffer parameter and how this should be
created/used. Any help is appreciated.

# DWORD WNetGetUniversalName(
#  __in     LPCTSTR lpLocalPath,
#  __in     DWORD dwInfoLevel,
#  __out    LPVOID lpBuffer,
#  __inout  LPDWORD lpBufferSize
# );

import ctypes, win32netcon

LPDWORD = ctypes.POINTER(DWORD)

class UniversalNameInfo(ctypes.Structure):
    __fields__ = [("lpUniversalName", LPCWSTR)]

WNetGetUniversalNameW = ctypes.windll.mpr.WNetGetUniversalNameW

path = LPCWSTR('Y:')
level = DWORD(win32netcon.UNIVERSAL_NAME_INFO_LEVEL)
buffer_len = LPDWORD(DWORD(1024))
uni_struct = UniversalNameInfo()

ret = WNetGetUniversalNameW(path, level, uni_struct, buffer_len)



More information about the Python-list mailing list