b Displays the executable involved in creating each connection or listening port. a Displays all connections and listening ports. (Add -n to stop it trying to resolve hostnames, which will make it a lot faster.) UDP Get-Process -Id (Get-NetUDPEndpoint -LocalPort YourPortNumberHere).OwningProcess New answer, powershell TCP Get-Process -Id (Get-NetTCPConnection -LocalPort YourPortNumberHere).OwningProcess Print info.pName, '=>', info.pDescription Info = ctypes.cast(buffer, ctypes.POINTER(PRINTER_INFO_1)) Winspool.EnumPrintersW(PRINTER_ENUM_LOCAL, Name, Level, buffer, bufsize, Winspool.EnumPrintersW(PRINTER_ENUM_LOCAL, Name, Level, ref(info), 0,Ĭref(pcbNeeded), ref(pcReturned)) PcReturned = DWORD(0) # the number of PRINTER_INFO_1 structures retrieved # Invoke once with a NULL pointer to get buffer size. Name = None # ignored for PRINTER_ENUM_LOCAL Winspool = ctypes.WinDLL('winspool.drv') # for EnumPrintersW # Tested with CPython 2.7.10 and IronPython 2.7.5.įrom ctypes.wintypes import BYTE, DWORD, LPCWSTR # Use EnumPrintersW to list local printers with their names and descriptions. Here is a fully working ctypes version w/o error checking. You can use pywin32's win32print.EnumPrinters() (more convenient), or invoke the EnumPrinters() API via the ctypes module (low dependency).
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |