Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende ÜberarbeitungLetzte ÜberarbeitungBeide Seiten der Revision | ||
development:python:windows [2019-04-09 18:01] – angelegt Martin Prochnow | development:python:windows [2019-04-09 18:03] – Martin Prochnow | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
====== Windows ====== | ====== Windows ====== | ||
- | ===== Schnipsel | + | ===== COM-Wrapper-Klassen erstellen |
- | Modalen Dialog anzeigen: | + | |
+ | Um in Python auf COM-Schnittstellen zugreifen zu können, wird das Modul // | ||
<sxh python> | <sxh python> | ||
- | import | + | import sys |
+ | from win32com.client import makepy | ||
- | ctypes.windll.user32.MessageBoxA(0, | + | sys.argv = [" |
- | | + | |
- | os.path.abspath(os.curdir), | + | makepy.main() |
- | os.path.abspath(os.path.dirname(sys.argv[0])), | + | |
- | | + | |
- | ), "%s - Message" | + | |
- | ) | + | |
</ | </ | ||
+ | ===== Nutzung von IPv4 erzwingen ===== | ||
+ | Unter neueren Windows-Versionen wird unter Python bei der Namensauflösung für Windows-Rechner (z.B. auch // | ||
+ | |||
+ | Eine Lösung wäre es natürlich, IPv6 im Betriebssystem zu deaktivieren. Das hat aber was von "mit Kanonen auf Spatzen schießen" | ||
+ | |||
+ | <sxh python> | ||
+ | import socket | ||
+ | origGetAddrInfo = socket.getaddrinfo | ||
+ | |||
+ | def getAddrInfoWrapper(host, | ||
+ | return origGetAddrInfo(host, | ||
+ | |||
+ | socket.getaddrinfo = getAddrInfoWrapper | ||
+ | </ | ||
+ | |||
+ | [[http:// | ||
===== Windows-Service ===== | ===== Windows-Service ===== | ||
Zeile 24: | Zeile 39: | ||
import inspect | import inspect | ||
path = inspect.currentframe().f_code.co_filename | path = inspect.currentframe().f_code.co_filename | ||
+ | </ | ||
+ | |||
+ | ===== Schnipsel ===== | ||
+ | Modalen Dialog anzeigen: | ||
+ | <sxh python> | ||
+ | import os, sys, ctypes | ||
+ | |||
+ | ctypes.windll.user32.MessageBoxA(0, | ||
+ | " | ||
+ | os.path.abspath(os.curdir), | ||
+ | os.path.abspath(os.path.dirname(sys.argv[0])), | ||
+ | sys.winver, | ||
+ | ), "%s - Message" | ||
+ | ) | ||
</ | </ | ||
{{tag> | {{tag> | ||